You can subscribe to this list here.
2003 |
Jan
(30) |
Feb
(20) |
Mar
(151) |
Apr
(86) |
May
(23) |
Jun
(25) |
Jul
(107) |
Aug
(141) |
Sep
(55) |
Oct
(85) |
Nov
(65) |
Dec
(2) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2004 |
Jan
(22) |
Feb
(18) |
Mar
(3) |
Apr
(16) |
May
(69) |
Jun
(3) |
Jul
(1) |
Aug
(3) |
Sep
(1) |
Oct
|
Nov
(6) |
Dec
(1) |
2005 |
Jan
(2) |
Feb
(16) |
Mar
|
Apr
|
May
|
Jun
(47) |
Jul
(1) |
Aug
|
Sep
(6) |
Oct
(4) |
Nov
|
Dec
(34) |
2006 |
Jan
(39) |
Feb
|
Mar
(2) |
Apr
|
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
(5) |
Oct
|
Nov
(4) |
Dec
|
2007 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(1) |
2008 |
Jan
|
Feb
|
Mar
(26) |
Apr
(1) |
May
(1) |
Jun
|
Jul
(5) |
Aug
(2) |
Sep
(8) |
Oct
(8) |
Nov
(22) |
Dec
(30) |
2009 |
Jan
(10) |
Feb
(13) |
Mar
(14) |
Apr
(14) |
May
(32) |
Jun
(25) |
Jul
(36) |
Aug
(10) |
Sep
(2) |
Oct
|
Nov
|
Dec
(10) |
2010 |
Jan
(9) |
Feb
(4) |
Mar
(2) |
Apr
(1) |
May
(2) |
Jun
(2) |
Jul
(1) |
Aug
(4) |
Sep
|
Oct
(1) |
Nov
|
Dec
|
From: <kr_...@us...> - 2003-08-21 23:42:29
|
Update of /cvsroot/htoolkit/gio/src/Graphics/UI/GIO In directory sc8-pr-cvs1:/tmp/cvs-serv26881/gio/src/Graphics/UI/GIO Modified Files: CommonDialogs.hs Controls.hs Events.hs Layout.hs Window.hs Log Message: Implementation for CompoundControl Index: CommonDialogs.hs =================================================================== RCS file: /cvsroot/htoolkit/gio/src/Graphics/UI/GIO/CommonDialogs.hs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** CommonDialogs.hs 12 Aug 2003 17:38:12 -0000 1.5 --- CommonDialogs.hs 20 Aug 2003 21:37:25 -0000 1.6 *************** *** 24,27 **** --- 24,28 ---- import Graphics.UI.GIO.Types import Graphics.UI.GIO.Attributes + import Graphics.UI.GIO.Layout import Graphics.UI.GIO.Window import qualified Graphics.UI.Port as Lib Index: Controls.hs =================================================================== RCS file: /cvsroot/htoolkit/gio/src/Graphics/UI/GIO/Controls.hs,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** Controls.hs 17 Jul 2003 19:30:04 -0000 1.18 --- Controls.hs 20 Aug 2003 21:37:26 -0000 1.19 *************** *** 22,25 **** --- 22,26 ---- , CheckGroup, checkGroup, checkLayout , RadioGroup, radioGroup, radioLayout + , CompoundControl, compoundControl -- * Primitive , Check, check *************** *** 31,35 **** import Graphics.UI.GIO.Attributes import Graphics.UI.GIO.Events ! import Graphics.UI.GIO.Window import Graphics.UI.GIO.Layout import Control.Monad(when, mapM_, filterM) --- 32,36 ---- import Graphics.UI.GIO.Attributes import Graphics.UI.GIO.Events ! import Graphics.UI.GIO.Canvas import Graphics.UI.GIO.Layout import Control.Monad(when, mapM_, filterM) *************** *** 61,65 **** -- | Create a text label. ! label :: [Prop Label] -> Window -> IO Label label props w = do lab <- do hlab <- Port.createLabel (hwindow w) --- 62,66 ---- -- | Create a text label. ! label :: Container w => [Prop Label] -> w -> IO Label label props w = do lab <- do hlab <- Port.createLabel (hwindow w) *************** *** 99,103 **** -- | Create a button. ! button :: [Prop Button] -> Window -> IO Button button props w = do but <- do hbut <- Port.createButton (hwindow w) --- 100,104 ---- -- | Create a button. ! button :: Container w => [Prop Button] -> w -> IO Button button props w = do but <- do hbut <- Port.createButton (hwindow w) *************** *** 141,145 **** -- | Create an entry. ! entry :: [Prop Entry] -> Window -> IO Entry entry props w = do e <- do hentry <- Port.createEdit (hwindow w) --- 142,146 ---- -- | Create an entry. ! entry :: Container w => [Prop Entry] -> w -> IO Entry entry props w = do e <- do hentry <- Port.createEdit (hwindow w) *************** *** 189,193 **** -- | Create a popup selection box. ! popup :: [Prop Popup] -> Window -> IO Popup popup props w = do p <- do hpop <- Port.createPopUp (hwindow w) --- 190,194 ---- -- | Create a popup selection box. ! popup :: Container w => [Prop Popup] -> w -> IO Popup popup props w = do p <- do hpop <- Port.createPopUp (hwindow w) *************** *** 269,273 **** -- | Create a list box. ! listBox :: Bool -> [Prop ListBox] -> Window -> IO ListBox listBox multi props w = do lb <- do --- 270,274 ---- -- | Create a list box. ! listBox :: Container w => Bool -> [Prop ListBox] -> w -> IO ListBox listBox multi props w = do lb <- do *************** *** 356,360 **** -- The items are specified by their label, their initial check state and their -- event handlers (that receive the current check state as an argument). ! checkGroup :: [(String,Bool,Bool -> IO ())] -> [Prop CheckGroup] -> Window -> IO CheckGroup checkGroup items props w = do cg <- do cs <- mapM (\(txt,c,cmd) -> check txt [checked =: c, on command =:: checkCommand cmd] w) items --- 357,361 ---- -- The items are specified by their label, their initial check state and their -- event handlers (that receive the current check state as an argument). ! checkGroup :: Container w => [(String,Bool,Bool -> IO ())] -> [Prop CheckGroup] -> w -> IO CheckGroup checkGroup items props w = do cg <- do cs <- mapM (\(txt,c,cmd) -> check txt [checked =: c, on command =:: checkCommand cmd] w) items *************** *** 410,414 **** -- | Create a new radio control group that is initially layed out vertically. ! radioGroup :: [(String,IO ())] -> [Prop RadioGroup] -> Window -> IO RadioGroup radioGroup items props w = do rg <- do rs <- mapM (\(first,(txt,cmd)) -> radioEx first txt [] w) (zip (True:repeat False) items) --- 411,415 ---- -- | Create a new radio control group that is initially layed out vertically. ! radioGroup :: Container w => [(String,IO ())] -> [Prop RadioGroup] -> w -> IO RadioGroup radioGroup items props w = do rg <- do rs <- mapM (\(first,(txt,cmd)) -> radioEx first txt [] w) (zip (True:repeat False) items) *************** *** 465,469 **** -- | Create a check control with a certain label. ! check :: String -> [Prop Check] -> Window -> IO Check check txt props w = do c <- do hcheck <- Port.createCheckBox (hwindow w) txt --- 466,470 ---- -- | Create a check control with a certain label. ! check :: Container w => String -> [Prop Check] -> w -> IO Check check txt props w = do c <- do hcheck <- Port.createCheckBox (hwindow w) txt *************** *** 500,504 **** -- | Create a radio control with a certain label. ! radio :: String -> [Prop Radio] -> Window -> IO Radio radio txt props w = radioEx True txt props w --- 501,505 ---- -- | Create a radio control with a certain label. ! radio :: Container w => String -> [Prop Radio] -> w -> IO Radio radio txt props w = radioEx True txt props w *************** *** 506,510 **** -- | Create a radio control. Takes an extra argument that specifies -- that this is the first control in a group. ! radioEx :: Bool -> String -> [Prop Radio] -> Window -> IO Radio radioEx first txt props w = do r <- do hradio <- Port.createRadioBox (hwindow w) first txt --- 507,511 ---- -- | Create a radio control. Takes an extra argument that specifies -- that this is the first control in a group. ! radioEx :: Container w => Bool -> String -> [Prop Radio] -> w -> IO Radio radioEx first txt props w = do r <- do hradio <- Port.createRadioBox (hwindow w) first txt *************** *** 556,560 **** -- | Create a horizontal slider control. ! hslider :: [Prop Slider] -> Window -> IO Slider hslider props w = do r <- do shandle <- Port.createHorzSlider (hwindow w) --- 557,561 ---- -- | Create a horizontal slider control. ! hslider :: Container w => [Prop Slider] -> w -> IO Slider hslider props w = do r <- do shandle <- Port.createHorzSlider (hwindow w) *************** *** 564,568 **** -- | Create a vertical slider control. ! vslider :: [Prop Slider] -> Window -> IO Slider vslider props w = do r <- do shandle <- Port.createVertSlider (hwindow w) --- 565,569 ---- -- | Create a vertical slider control. ! vslider :: Container w => [Prop Slider] -> w -> IO Slider vslider props w = do r <- do shandle <- Port.createVertSlider (hwindow w) *************** *** 599,603 **** -- | Create a horizontal progress bar. -- The boolean parameter specify whether the bar shows continuous or discrete values. ! hProgressBar :: Bool -> [Prop ProgressBar] -> Window -> IO ProgressBar hProgressBar smooth props w = do r <- do pbhandle <- Port.createHorzProgressBar (hwindow w) smooth --- 600,604 ---- -- | Create a horizontal progress bar. -- The boolean parameter specify whether the bar shows continuous or discrete values. ! hProgressBar :: Container w => Bool -> [Prop ProgressBar] -> w -> IO ProgressBar hProgressBar smooth props w = do r <- do pbhandle <- Port.createHorzProgressBar (hwindow w) smooth *************** *** 610,614 **** -- | Create a vertical progress bar. -- The boolean parameter specify whether the bar shows continuous or discrete values. ! vProgressBar :: Bool -> [Prop ProgressBar] -> Window -> IO ProgressBar vProgressBar smooth props w = do r <- do pbhandle <- Port.createVertProgressBar (hwindow w) smooth --- 611,615 ---- -- | Create a vertical progress bar. -- The boolean parameter specify whether the bar shows continuous or discrete values. ! vProgressBar :: Container w => Bool -> [Prop ProgressBar] -> w -> IO ProgressBar vProgressBar smooth props w = do r <- do pbhandle <- Port.createVertProgressBar (hwindow w) smooth *************** *** 636,637 **** --- 637,750 ---- instance Control ProgressBar where pack w = stdPack (pbparent w) (Port.getProgressBarRequestSize (pbhandle w)) (Port.moveResizeControl (pbhandle w)) + + + -------------------------------------------------------------------- + -- CompoundControl + -------------------------------------------------------------------- + -- | A compound control. + data CompoundControl = CompoundControl + { cchandle :: !WindowHandle + , ccparent :: !WindowHandle + , vdomain :: Var Size + , vautosize :: Var Bool + , vpen :: Var Pen + , vbufferMode :: Var BufferMode + , vpaint :: Var PaintFunction + , vlayout :: Var Layout + } + + -- | Create a window + compoundControl :: Container w => [Prop CompoundControl] -> w -> IO CompoundControl + compoundControl props w + = do c <- do cchandle <- Port.createCompoundControl (hwindow w) + vpaint <- newVar (\_ _ _ -> return ()) + vautosize <- newVar True + vlayout <- newVar empty + vdomain <- newVar (sz 0 0) + vpen <- newVar defaultPen + vbufferMode<- newVar UnBuffered + return (CompoundControl cchandle (hwindow w) vdomain vautosize vpen vbufferMode vpaint vlayout) + recolorCompound c + set c [on relayout =:: relayoutCompound] + -- just by setting a dummy paint function, we will at least intialize the canvas properly on a repaint + set c [on paint =: (\_ _ _ -> return ())] + set c props + return c + + relayoutCompound :: CompoundControl -> IO () + relayoutCompound c + = do frame <- Port.getControlFrame (cchandle c) + domain <- get c domain + lay <- getVar (vlayout c) + needed <- getLayoutSize lay + let d1 = maxSize domain needed + d2 = maxSize d1 (rectSize frame) + Port.setWindowDomainSize (cchandle c) d1 + layoutInRect (rectOfSize d2) lay + return () + + recolorCompound :: CompoundControl -> IO () + recolorCompound c + = do col <- get c color + bgcol <- get c bgcolor + hat <- get c hatch + Port.setWindowColor (cchandle c) col bgcol hat + repaint c + relayoutCompound c + + instance Scrollable CompoundControl where + scroll = newScrollEvent cchandle + domain = newAttr (\c -> getVar (vdomain c)) + (\c x -> setVar (vdomain c) x >> relayoutCompound c) + origin = newAttr (Port.getWindowScrollOrigin . cchandle) (Port.setWindowScrollOrigin . cchandle) + + instance Dimensions CompoundControl where + frame = newAttr (Port.getControlFrame . cchandle) (Port.moveResizeControl . cchandle) + + instance Drawn CompoundControl where + pen = newAttr (getVar . vpen) (\w pen -> setVar (vpen w) pen >> recolorCompound w) + + bufferMode = newAttr (getVar . vbufferMode) (setVar . vbufferMode) + + instance HasFont CompoundControl where + font = mapAttr penFont (\pen c -> pen{penFont=c}) pen + + instance Reactive CompoundControl where + mouse = newMouseEvent cchandle + keyboard = newKeyboardEvent cchandle + contextMenu = newContextMenuEvent cchandle + + instance Paint CompoundControl where + repaint c = do Port.invalidateWindow (cchandle c) + paint = newPaintEvent vpaint wndpaint cchandle + where + wndpaint c paintfun hcanvas updArea + = do pen <- get c pen + bmode <- get c bufferMode + withCanvas bmode pen hcanvas $ \can -> paintfun can updArea [] + paintIn c bmode f = do + pen <- get c pen + Port.drawInWindow (cchandle c) (\hcanvas -> withCanvas bmode pen hcanvas f) + + instance Able CompoundControl where + enabled = newAttr (Port.getControlEnabled . cchandle) (Port.setControlEnabled . cchandle) + + instance Container CompoundControl where + layout + = writeAttr "layout" (\w c -> do + let lay = pack c + autosize <- get w autosize + domain <- get w domain + needed <- getLayoutSize lay + let d = maxSize domain needed + Port.setWindowDomainSize (cchandle w) d + frame <- Port.getControlFrame (cchandle w) + layoutInRect (rectOfSize (maxSize d (rectSize frame))) lay + setVar (vlayout w) lay) + autosize = readAttr "autosize" (\c -> return False) + layoutSize = readAttr "layoutSize" (\c -> getVar (vlayout c) >>= getLayoutSize) + relayout = stdWindowEvent Port.getWindowReLayoutHandler Port.setWindowReLayoutHandler Port.setWindowReLayoutDefHandler cchandle + hwindow c = cchandle c + + instance Control CompoundControl where + pack w = stdPack (ccparent w) (Port.getCompoundControlRequestSize (cchandle w)) (Port.moveResizeControl (cchandle w)) Index: Events.hs =================================================================== RCS file: /cvsroot/htoolkit/gio/src/Graphics/UI/GIO/Events.hs,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** Events.hs 17 Jul 2003 19:30:05 -0000 1.14 --- Events.hs 20 Aug 2003 21:37:26 -0000 1.15 *************** *** 73,78 **** , mouse, keyboard, contextMenu ! -- ** Form ! , Form, activate, deactivate, scroll, resize -- ** Dismissible --- 73,81 ---- , mouse, keyboard, contextMenu ! -- ** TopLevel ! , TopLevel, activate, deactivate, resize, resizeable ! ! -- ** Scrollable ! , Scrollable, scroll, domain, origin -- ** Dismissible *************** *** 85,89 **** -- ** Paint ! , Paint, paint, repaint , PaintFunction --- 88,92 ---- -- ** Paint ! , Paint, paint, repaint, paintIn , PaintFunction *************** *** 160,163 **** --- 163,167 ---- class Commanding w where command :: Event w (IO ()) + -- | The widgets which are members of 'DynamicUpdate' class has 'update' *************** *** 166,176 **** update :: Event w (IO ()) ! -- | A form is a visible window on the screen. ! class Form w where ! activate :: Event w (IO ()) ! deactivate:: Event w (IO ()) ! scroll :: Event w (Point -> IO ()) ! resize :: Event w (Size -> IO ()) -- | The Dismissible widgets can be dissmissed class Dismissible w where --- 170,199 ---- update :: Event w (IO ()) ! ! -- | A top level widget is a widget which doesn't have parents. ! class TopLevel w where ! activate :: Event w (IO ()) ! deactivate :: Event w (IO ()) ! resize :: Event w (Size -> IO ()) + -- | Sets\/Gets whether the user can resize a widget. + -- Widgets are user resizable by default. + resizeable :: Attr w Bool + + + class Scrollable w where + -- | The event is generated when the user change the current + -- position of the scollbars + scroll :: Event w (Point -> IO ()) + + -- | The size of view domain of the widget. If it is larger than + -- the current view size, scroll bars will appear automatically. + domain :: Attr w Size + + -- | The current position of the scrollbars. The position is given + -- relatively to the begining of the domain. + origin :: Attr w Point + + -- | The Dismissible widgets can be dissmissed class Dismissible w where *************** *** 181,184 **** --- 204,208 ---- dismiss :: Event w (IO ()) + -- | The Deadly widgets can be destroyed. class Deadly w where *************** *** 188,191 **** --- 212,216 ---- destroy :: Event w (IO ()) + -- | Reactive widgets react to mouse and keyboard events class Reactive w where *************** *** 194,197 **** --- 219,223 ---- contextMenu :: Event w (Point -> Modifiers -> IO ()) + -- | Widgets that can be repainted. class Paint w where *************** *** 201,204 **** --- 227,235 ---- -- | Explicitly force a 'paint' event. repaint :: w -> IO () + + -- | The paintIn executes the given function with canvas + -- associated with the given widget. + paintIn :: w -> BufferMode -> (Canvas -> IO a) -> IO a + -- | A paint function takes a canvas, the update bound rectangle Index: Layout.hs =================================================================== RCS file: /cvsroot/htoolkit/gio/src/Graphics/UI/GIO/Layout.hs,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Layout.hs 2 Jul 2003 20:04:45 -0000 1.6 --- Layout.hs 20 Aug 2003 21:37:26 -0000 1.7 *************** *** 9,13 **** The layout module helps to position controls (i.e. buttons, listboxes, etc) on ! a widget. Allthough it is possible to position them by hand using the 'Dimensions' class, it is much easier to position them using layout combinators. Furthermore, the parent widget will automatically reposition them when for example the size of --- 9,13 ---- The layout module helps to position controls (i.e. buttons, listboxes, etc) on ! a container. Allthough it is possible to position them by hand using the 'Dimensions' class, it is much easier to position them using layout combinators. Furthermore, the parent widget will automatically reposition them when for example the size of *************** *** 88,91 **** --- 88,98 ---- , pack , Layout + -- * Containers + , Container + , layout + , autosize + , layoutSize + , relayout + , hwindow -- * Operators , (^^^^), (<<<<), (^^^), (<<<) *************** *** 121,124 **** --- 128,132 ---- import Graphics.UI.GIO.Types import Graphics.UI.GIO.Attributes + import Graphics.UI.GIO.Events infixl 7 <<<, <<<< *************** *** 163,170 **** --------------------------------------------------------------------} ! -- | Controls can be layed out on other widgets. See for example 'Graphics.UI.GIO.Window.layout'. class Control w where -- | Create a 'Layout' from a normal control. pack :: w -> Layout instance Control Layout where --- 171,206 ---- --------------------------------------------------------------------} ! -- | Controls can be layed out on containers. class Control w where -- | Create a 'Layout' from a normal control. pack :: w -> Layout + + + -- | The container is a widget which can layout other widget + class Container w where + -- | The layout of controls within the window. This + -- attribute is write-only. If a control is not assigned + -- to the layout, it will not show up + -- (unless explicitly positioned using its 'Dimensions'). + -- The window will automatically update the layout when + -- resized or when a control changes its appearance. + layout :: Control c => Attr w c + + -- | Controls whether the widget will automatically resize + -- to display all controls. + autosize :: Attr w Bool + + -- | The layoutSize of widget is the minimum size needed to + -- layout the controls assigned to it. This + -- attribute is read-only. + layoutSize :: Attr w Size + + -- | The 'relayout' event is called whenever the controls in the window need to + -- be repositioned. For example, when the window is resized or when a control changes + -- its appearance. + relayout :: Event w (IO ()) + + -- | Internal + hwindow :: w -> WindowHandle instance Control Layout where Index: Window.hs =================================================================== RCS file: /cvsroot/htoolkit/gio/src/Graphics/UI/GIO/Window.hs,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** Window.hs 13 Jul 2003 10:22:56 -0000 1.21 --- Window.hs 20 Aug 2003 21:37:26 -0000 1.22 *************** *** 11,21 **** -} ----------------------------------------------------------------------------------------- ! module Graphics.UI.GIO.Window ! ( Window, window, domain, origin, resizeable, view, layout, autosize, layoutSize ! , dialog, runDialog ! , drawInWindow ! -- * Internal ! , hwindow ! ) where import qualified Graphics.UI.Port as Lib --- 11,15 ---- -} ----------------------------------------------------------------------------------------- ! module Graphics.UI.GIO.Window (Window, window, dialog, runDialog) where import qualified Graphics.UI.Port as Lib *************** *** 31,35 **** --------------------------------------------------------------------} -- | A main window widget. ! data Window = Window{ hwindow :: WindowHandle , vdomain :: Var Size , vresizeable :: Var Bool --- 25,29 ---- --------------------------------------------------------------------} -- | A main window widget. ! data Window = Window{ hwnd :: WindowHandle , vdomain :: Var Size , vresizeable :: Var Bool *************** *** 108,137 **** - -- | Controls whether the window will automatically resize to display all controls. - autosize :: Attr Window Bool - autosize - = varAttr vautosize - instance Titled Window where title = newAttr (\w -> Lib.getWindowTitle (hwindow w)) (\w x -> Lib.setWindowTitle (hwindow w) x) ! -- | The view domain of the window. If it is larger than the current view size, scroll bars ! -- will appear automatically. ! domain :: Attr Window Size ! domain ! = newAttr (\w -> getVar (vdomain w)) ! (\w x -> setVar (vdomain w) x >> relayoutWindow w) ! ! origin :: Attr Window Point ! origin = newAttr (Lib.getWindowScrollOrigin . hwindow) (Lib.setWindowScrollOrigin . hwindow) ! ! -- | Can the window be resized? ! resizeable :: Attr Window Bool ! resizeable ! = newAttr (\w -> getVar (vresizeable w)) ! (\w x -> do resize <- get w resizeable ! when (x /= resize) (do Lib.setWindowResizeable (hwindow w) x ! setVar (vresizeable w) x)) -- | The size of the current view area. --- 102,114 ---- instance Titled Window where title = newAttr (\w -> Lib.getWindowTitle (hwindow w)) (\w x -> Lib.setWindowTitle (hwindow w) x) ! instance Scrollable Window where ! scroll = newScrollEvent hwindow ! domain = newAttr (\w -> getVar (vdomain w)) ! (\w x -> setVar (vdomain w) x >> relayoutWindow w) ! origin = newAttr (Lib.getWindowScrollOrigin . hwindow) (Lib.setWindowScrollOrigin . hwindow) -- | The size of the current view area. *************** *** 166,175 **** contextMenu = newContextMenuEvent hwindow ! instance Form Window where activate = newActivateEvent hwindow deactivate= newDeactivateEvent hwindow - scroll = newScrollEvent hwindow resize = newResizeEvent hwindow ! instance Paint Window where repaint w = do Lib.invalidateWindow (hwindow w) --- 143,156 ---- contextMenu = newContextMenuEvent hwindow ! instance TopLevel Window where activate = newActivateEvent hwindow deactivate= newDeactivateEvent hwindow resize = newResizeEvent hwindow ! resizeable ! = newAttr (\w -> getVar (vresizeable w)) ! (\w x -> do resize <- get w resizeable ! when (x /= resize) (do Lib.setWindowResizeable (hwindow w) x ! setVar (vresizeable w) x)) ! instance Paint Window where repaint w = do Lib.invalidateWindow (hwindow w) *************** *** 180,204 **** bmode <- get w bufferMode withCanvas bmode pen hcanvas $ \can -> paintfun can updArea [] ! instance Able Window where enabled = newAttr (Lib.getWindowEnabled . hwindow) (Lib.setWindowEnabled . hwindow) ! ! -- layout ! -- | The 'relayout' event is called whenever the controls in the window need to ! -- be repositioned. For example, when the window is resized or when a control changes ! -- its appearance. ! relayout :: Event Window (IO ()) ! relayout ! = stdWindowEvent Lib.getWindowReLayoutHandler Lib.setWindowReLayoutHandler Lib.setWindowReLayoutDefHandler hwindow ! ! ! -- | The layout of controls within the window. This attribute is write-only. If a control ! -- is not assigned to the layout, it will not show up (unless explicitly positioned using ! -- its 'Dimensions'). The window will automatically update the layout when resized or ! -- when a control changes its appearance. See also "Graphics.UI.GIO.Layout". ! layout :: Control c => Attr Window c ! layout ! = writeAttr "layout" (\w c -> do let lay = pack c autosize <- get w autosize --- 161,174 ---- bmode <- get w bufferMode withCanvas bmode pen hcanvas $ \can -> paintfun can updArea [] ! paintIn w bmode f = do ! pen <- get w pen ! Lib.drawInWindow (hwindow w) (\hcanvas -> withCanvas bmode pen hcanvas f) ! instance Able Window where enabled = newAttr (Lib.getWindowEnabled . hwindow) (Lib.setWindowEnabled . hwindow) ! instance Container Window where ! layout ! = writeAttr "layout" (\w c -> do let lay = pack c autosize <- get w autosize *************** *** 211,225 **** layoutInRect (rectOfSize (maxSize d view)) lay setVar (vlayout w) lay) ! ! -- | The layoutSize of window is the minimum size needed to layout ! -- the controls assigned to it. ! layoutSize :: Attr Window Size ! layoutSize ! = readAttr "layoutSize" (\w -> getVar (vlayout w) >>= getLayoutSize) ! ! -- | The drawInWindow executes the given function with canvas ! -- associated with given window. ! drawInWindow :: BufferMode -> Window -> (Canvas -> IO a) -> IO a ! drawInWindow bmode w f = do ! pen <- get w pen ! Lib.drawInWindow (hwindow w) (\hcanvas -> withCanvas bmode pen hcanvas f) --- 181,186 ---- layoutInRect (rectOfSize (maxSize d view)) lay setVar (vlayout w) lay) ! autosize = varAttr vautosize ! layoutSize = readAttr "layoutSize" (\w -> getVar (vlayout w) >>= getLayoutSize) ! relayout = stdWindowEvent Lib.getWindowReLayoutHandler Lib.setWindowReLayoutHandler Lib.setWindowReLayoutDefHandler hwindow ! hwindow w = hwnd w |
From: <kr_...@us...> - 2003-08-21 23:42:28
|
Update of /cvsroot/htoolkit/port/src/Port In directory sc8-pr-cvs1:/tmp/cvs-serv26881/port/src/Port Modified Files: Controls.hs Log Message: Implementation for CompoundControl Index: Controls.hs =================================================================== RCS file: /cvsroot/htoolkit/port/src/Port/Controls.hs,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** Controls.hs 17 Jul 2003 19:30:03 -0000 1.16 --- Controls.hs 20 Aug 2003 21:37:26 -0000 1.17 *************** *** 28,31 **** --- 28,33 ---- * ProgressBar + + * CompoundControl -} ----------------------------------------------------------------------------------------- *************** *** 78,81 **** --- 80,85 ---- , createHorzProgressBar, createVertProgressBar, getProgressBarRequestSize , setProgressBarFraction, getProgressBarFraction + -- * CompoundControl + , createCompoundControl, getCompoundControlRequestSize ) where *************** *** 402,403 **** --- 406,418 ---- return (fromCInt pos) foreign import ccall osGetProgressBarFraction :: WindowHandle -> CInt -> CInt -> IO CInt + + ----------------------------------------------------------------------------------------- + -- CompoundControl + ----------------------------------------------------------------------------------------- + + -- | Create a new compound control + foreign import ccall "osCreateCompoundControl" createCompoundControl :: WindowHandle -> IO WindowHandle + + getCompoundControlRequestSize :: WindowHandle -> IO Size + getCompoundControlRequestSize hwnd = withCSizeResult (osGetCompoundControlReqSize hwnd) + foreign import ccall osGetCompoundControlReqSize :: WindowHandle -> Ptr CInt -> IO () |
From: <kr_...@us...> - 2003-08-21 21:39:24
|
Update of /cvsroot/htoolkit/port/src/cbits/Win32 In directory sc8-pr-cvs1:/tmp/cvs-serv15930/port/src/cbits/Win32 Modified Files: CheckBox.c RadioBox.c Window.c Log Message: Simplified API for RadioBox. The new API is much like the API for ToolGroup and MenuGroup Index: CheckBox.c =================================================================== RCS file: /cvsroot/htoolkit/port/src/cbits/Win32/CheckBox.c,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** CheckBox.c 10 Feb 2003 22:42:10 -0000 1.3 --- CheckBox.c 21 Aug 2003 17:34:01 -0000 1.4 *************** *** 1,6 **** #include "CheckBox.h" #include "Internals.h" ! WindowHandle osCreateCheckBox(WindowHandle window, char *title) { HWND hCheckBox; --- 1,7 ---- #include "CheckBox.h" #include "Internals.h" + #include "Handlers_stub.h" ! WindowHandle osCreateCheckBox(WindowHandle window) { HWND hCheckBox; *************** *** 8,12 **** hCheckBox = CreateWindow( "BUTTON", ! title, WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX | WS_TABSTOP, 0,0,0,0, --- 9,13 ---- hCheckBox = CreateWindow( "BUTTON", ! NULL, WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX | WS_TABSTOP, 0,0,0,0, *************** *** 36,39 **** --- 37,54 ---- res[0] = sz.cx + ((tm.tmHeight+tm.tmDescent)*3)/2; res[1] = tm.tmHeight+tm.tmDescent; + }; + + char *osGetCheckBoxText(WindowHandle checkbox) + { + int nLen = GetWindowTextLength(checkbox); + char *buffer = (char *) rmalloc(nLen+1); + GetWindowText(checkbox, buffer, nLen+1); + return buffer; + }; + + void osSetCheckBoxText(WindowHandle checkbox, char *txt) + { + SetWindowText(checkbox, txt); + handleWindowReLayout(GetParent(checkbox)); }; Index: RadioBox.c =================================================================== RCS file: /cvsroot/htoolkit/port/src/cbits/Win32/RadioBox.c,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** RadioBox.c 10 Feb 2003 22:42:10 -0000 1.3 --- RadioBox.c 21 Aug 2003 17:34:01 -0000 1.4 *************** *** 1,6 **** #include "RadioBox.h" #include "Internals.h" ! WindowHandle osCreateRadioBox(WindowHandle window, BOOL isFirst, char *title) { HWND hCheckBox; --- 1,7 ---- #include "RadioBox.h" #include "Internals.h" + #include "Handlers_stub.h" ! WindowHandle osCreateRadioBox(WindowHandle window) { HWND hCheckBox; *************** *** 8,13 **** hCheckBox = CreateWindow( "BUTTON", ! title, ! WS_CHILD | WS_VISIBLE | BS_AUTORADIOBUTTON | WS_TABSTOP | (isFirst ? WS_GROUP : 0), 0,0,0,0, window, --- 9,14 ---- hCheckBox = CreateWindow( "BUTTON", ! NULL, ! WS_CHILD | WS_VISIBLE | BS_AUTORADIOBUTTON | WS_TABSTOP, 0,0,0,0, window, *************** *** 16,19 **** --- 17,21 ---- NULL ); + SetWindowLong(hCheckBox, GWL_USERDATA, (LONG) hCheckBox); return checkWindow(hCheckBox, "RADIOBOX"); }; *************** *** 38,41 **** --- 40,57 ---- }; + char *osGetRadioBoxText(WindowHandle radiobox) + { + int nLen = GetWindowTextLength(radiobox); + char *buffer = (char *) rmalloc(nLen+1); + GetWindowText(radiobox, buffer, nLen+1); + return buffer; + }; + + void osSetRadioBoxText(WindowHandle radiobox, char *txt) + { + SetWindowText(radiobox, txt); + handleWindowReLayout(GetParent(radiobox)); + }; + BOOL osGetRadioBoxState(WindowHandle radiobox) { *************** *** 46,48 **** --- 62,94 ---- { SendMessage(radiobox,BM_SETCHECK,state ? BST_CHECKED : BST_UNCHECKED,0); + }; + + void osSetRadioBoxGroup(WindowHandle *handles) + { + WindowHandle first, next, child, handle, *phandle; + + phandle=handles; + for (;;) + { + handle = *phandle; + + first = (WindowHandle) GetWindowLong(handle, GWL_USERDATA); + child = first; + for (;;) + { + next = (WindowHandle) GetWindowLong(child, GWL_USERDATA); + if (next == handle) break; + child = next; + } + SetWindowLong(child, GWL_USERDATA, (LONG) first); + + phandle++; + if (*phandle) + SetWindowLong(handle, GWL_USERDATA, (LONG) *phandle); + else + { + SetWindowLong(handle, GWL_USERDATA, (LONG) *handles); + break; + } + } }; Index: Window.c =================================================================== RCS file: /cvsroot/htoolkit/port/src/cbits/Win32/Window.c,v retrieving revision 1.39 retrieving revision 1.40 diff -C2 -d -r1.39 -r1.40 *** Window.c 20 Aug 2003 21:37:27 -0000 1.39 --- Window.c 21 Aug 2003 17:34:01 -0000 1.40 *************** *** 183,187 **** --- 183,201 ---- else if (_stricmp(buffer, "Button") == 0) + { + if ((GetWindowLong(hCtrl, GWL_STYLE) & BS_AUTORADIOBUTTON) == BS_AUTORADIOBUTTON) + { + HWND hNextCtrl = hCtrl; + for (;;) + { + hNextCtrl = (WindowHandle) GetWindowLong(hNextCtrl, GWL_USERDATA); + if (hNextCtrl == hCtrl) break; + + SendMessage(hNextCtrl,BM_SETCHECK,BST_UNCHECKED,0); + } + } + handleControlCommand(hCtrl); + } } else |
From: <kr_...@us...> - 2003-08-21 21:39:24
|
Update of /cvsroot/htoolkit/port/src/Port In directory sc8-pr-cvs1:/tmp/cvs-serv15930/port/src/Port Modified Files: Controls.hs Log Message: Simplified API for RadioBox. The new API is much like the API for ToolGroup and MenuGroup Index: Controls.hs =================================================================== RCS file: /cvsroot/htoolkit/port/src/Port/Controls.hs,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** Controls.hs 20 Aug 2003 21:37:26 -0000 1.17 --- Controls.hs 21 Aug 2003 17:34:01 -0000 1.18 *************** *** 55,64 **** --- 55,67 ---- -- * Check box , createCheckBox, getCheckBoxRequestSize + , getCheckBoxText, setCheckBoxText , getCheckBoxSelectState , setCheckBoxSelectState -- * Radio item , createRadioBox, getRadioBoxRequestSize + , getRadioBoxText, setRadioBoxText , setRadioBoxSelectState , getRadioBoxSelectState + , setRadioBoxGroup -- * Pop up box , createPopUp, getPopUpRequestSize *************** *** 147,151 **** ----------------------------------------------------------------------------------------- -- | Create a button control. An event handler for button clicks can be ! -- installed with 'registerButtonClick'. foreign import ccall "osCreateButton" createButton :: WindowHandle -> IO WindowHandle --- 150,154 ---- ----------------------------------------------------------------------------------------- -- | Create a button control. An event handler for button clicks can be ! -- installed with 'setControlCommandHandler'. foreign import ccall "osCreateButton" createButton :: WindowHandle -> IO WindowHandle *************** *** 170,179 **** -- CheckBox ----------------------------------------------------------------------------------------- ! -- | Create a check box with a label. ! -- An event handler for check box clicks can be ! -- installed with 'registerCheckBoxClick'. ! createCheckBox :: WindowHandle -> String -> IO WindowHandle ! createCheckBox hwnd label = withCString label (osCreateCheckBox hwnd) ! foreign import ccall osCreateCheckBox :: WindowHandle -> CString -> IO WindowHandle getCheckBoxRequestSize :: WindowHandle -> IO Size --- 173,179 ---- -- CheckBox ----------------------------------------------------------------------------------------- ! -- | Create a check box. An event handler for check box clicks can be ! -- installed with 'setControlCommandHandler'. ! foreign import ccall "osCreateCheckBox" createCheckBox :: WindowHandle -> IO WindowHandle getCheckBoxRequestSize :: WindowHandle -> IO Size *************** *** 181,184 **** --- 181,192 ---- foreign import ccall osGetCheckBoxReqSize :: WindowHandle -> Ptr CInt -> IO () + getCheckBoxText :: WindowHandle -> IO String + getCheckBoxText hwnd = resultCString (osGetCheckBoxText hwnd) + foreign import ccall osGetCheckBoxText :: WindowHandle -> IO CString + + setCheckBoxText :: WindowHandle -> String -> IO () + setCheckBoxText hwnd txt = withCString txt (osSetCheckBoxText hwnd) + foreign import ccall osSetCheckBoxText :: WindowHandle -> CString -> IO () + getCheckBoxSelectState :: WindowHandle -> IO Bool getCheckBoxSelectState hwnd *************** *** 228,235 **** -- radio control of its group and a label as its arguments. -- An event handler for radio box clicks can be ! -- installed with 'registerRadioBoxClick'. ! createRadioBox :: WindowHandle -> Bool -> String -> IO WindowHandle ! createRadioBox hwnd selected label = withCString label (osCreateRadioBox hwnd selected) ! foreign import ccall osCreateRadioBox :: WindowHandle -> Bool -> CString -> IO WindowHandle getRadioBoxRequestSize :: WindowHandle -> IO Size --- 236,241 ---- -- radio control of its group and a label as its arguments. -- An event handler for radio box clicks can be ! -- installed with 'setControlCommandHandler'. ! foreign import ccall "osCreateRadioBox" createRadioBox :: WindowHandle -> IO WindowHandle getRadioBoxRequestSize :: WindowHandle -> IO Size *************** *** 237,240 **** --- 243,254 ---- foreign import ccall osGetRadioBoxReqSize :: WindowHandle -> Ptr CInt -> IO () + getRadioBoxText :: WindowHandle -> IO String + getRadioBoxText hwnd = resultCString (osGetRadioBoxText hwnd) + foreign import ccall osGetRadioBoxText :: WindowHandle -> IO CString + + setRadioBoxText :: WindowHandle -> String -> IO () + setRadioBoxText hwnd txt = withCString txt (osSetRadioBoxText hwnd) + foreign import ccall osSetRadioBoxText :: WindowHandle -> CString -> IO () + getRadioBoxSelectState :: WindowHandle -> IO Bool getRadioBoxSelectState hwnd *************** *** 247,250 **** --- 261,268 ---- foreign import ccall osSetRadioBoxState :: WindowHandle -> CBool -> IO () + setRadioBoxGroup :: [WindowHandle] -> IO () + setRadioBoxGroup handles = withArray0 nullHandle handles osSetRadioBoxGroup + foreign import ccall osSetRadioBoxGroup :: Ptr WindowHandle -> IO () + ----------------------------------------------------------------------------------------- *************** *** 254,258 **** -- selection are allowed. -- An event handler for list box clicks can be ! -- installed with 'registerListBoxClick'. foreign import ccall "osCreateListBox" createListBox :: WindowHandle -> Bool -> IO WindowHandle --- 272,276 ---- -- selection are allowed. -- An event handler for list box clicks can be ! -- installed with 'setControlCommandHandler'. foreign import ccall "osCreateListBox" createListBox :: WindowHandle -> Bool -> IO WindowHandle *************** *** 308,312 **** -- | Create a new popup box. -- An event handler for pop up clicks can be ! -- installed with 'registerPopUpClick'. foreign import ccall "osCreatePopUp" createPopUp :: WindowHandle -> IO WindowHandle --- 326,330 ---- -- | Create a new popup box. -- An event handler for pop up clicks can be ! -- installed with 'setControlCommandHandler'. foreign import ccall "osCreatePopUp" createPopUp :: WindowHandle -> IO WindowHandle |
From: <kr_...@us...> - 2003-08-21 18:22:07
|
Update of /cvsroot/htoolkit/port/src/include In directory sc8-pr-cvs1:/tmp/cvs-serv15930/port/src/include Modified Files: CheckBox.h RadioBox.h Log Message: Simplified API for RadioBox. The new API is much like the API for ToolGroup and MenuGroup Index: CheckBox.h =================================================================== RCS file: /cvsroot/htoolkit/port/src/include/CheckBox.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** CheckBox.h 23 Jan 2003 20:19:32 -0000 1.2 --- CheckBox.h 21 Aug 2003 17:34:02 -0000 1.3 *************** *** 4,9 **** #include "Types.h" ! WindowHandle osCreateCheckBox(WindowHandle window, char *title); void osGetCheckBoxReqSize(WindowHandle checkbox, int *res); BOOL osGetCheckBoxState(WindowHandle checkbox); void osSetCheckBoxState(WindowHandle checkbox, BOOL state); --- 4,11 ---- #include "Types.h" ! WindowHandle osCreateCheckBox(WindowHandle window); void osGetCheckBoxReqSize(WindowHandle checkbox, int *res); + char *osGetCheckBoxText(WindowHandle checkbox); + void osSetCheckBoxText(WindowHandle checkbox, char *txt); BOOL osGetCheckBoxState(WindowHandle checkbox); void osSetCheckBoxState(WindowHandle checkbox, BOOL state); Index: RadioBox.h =================================================================== RCS file: /cvsroot/htoolkit/port/src/include/RadioBox.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** RadioBox.h 23 Jan 2003 20:19:32 -0000 1.2 --- RadioBox.h 21 Aug 2003 17:34:02 -0000 1.3 *************** *** 4,11 **** #include "Types.h" ! WindowHandle osCreateRadioBox(WindowHandle window, BOOL isFirst, char *title); void osGetRadioBoxReqSize(WindowHandle radiobox, int *res); BOOL osGetRadioBoxState(WindowHandle radiobox); void osSetRadioBoxState(WindowHandle radiobox, BOOL state); #endif --- 4,14 ---- #include "Types.h" ! WindowHandle osCreateRadioBox(WindowHandle window); void osGetRadioBoxReqSize(WindowHandle radiobox, int *res); + char *osGetRadioBoxText(WindowHandle checkbox); + void osSetRadioBoxText(WindowHandle checkbox, char *txt); BOOL osGetRadioBoxState(WindowHandle radiobox); void osSetRadioBoxState(WindowHandle radiobox, BOOL state); + void osSetRadioBoxGroup(WindowHandle *handles); #endif |
From: <kr_...@us...> - 2003-08-17 22:10:10
|
Update of /cvsroot/htoolkit/port/src/cbits/Win32 In directory sc8-pr-cvs1:/tmp/cvs-serv27976/src/cbits/Win32 Modified Files: Menu.c Log Message: Generate "update" menu before popup menu tracking Index: Menu.c =================================================================== RCS file: /cvsroot/htoolkit/port/src/cbits/Win32/Menu.c,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** Menu.c 17 Aug 2003 16:45:07 -0000 1.13 --- Menu.c 17 Aug 2003 22:10:05 -0000 1.14 *************** *** 1,527 **** ! #include "Menu.h" ! #include "Window.h" ! #include "Internals.h" ! #include "Handlers_stub.h" ! ! ! #define CHECK_MENU_TYPE(handle,mask,ret) \ ! if (((handle ? handle->type : MENU_SUBMENU) & (mask)) == 0) \ ! { \ ! printf("Invalid menu handle type."); \ [...1041 lines suppressed...] ! ! CHECK_MENU_TYPE_V(handle, MENU_ITEM); ! ! pFrameData = (FrameData *) GetWindowLong(ghWndFrame,GWL_USERDATA); ! handle->bitmap = bitmap; ! ! memset(&mii,0,sizeof(mii)); ! mii.cbSize = sizeof(mii); ! mii.fMask = MIIM_FTYPE; ! mii.fType = bitmap ? MFT_OWNERDRAW : MFT_STRING; ! SetMenuItemInfo(getParentHMENU(handle), getMenuPos(pFrameData->pMenuHandlesMap, handle), TRUE, &mii); ! ! updateMenuBar(handle->parent); ! } ! ! int osGetMenuItemPos(MenuHandle handle) ! { ! FrameData *pFrameData = (FrameData *) GetWindowLong(ghWndFrame,GWL_USERDATA); ! return getMenuPos(pFrameData->pMenuHandlesMap, handle); ! } |
From: <kr_...@us...> - 2003-08-17 22:02:49
|
Update of /cvsroot/htoolkit/port/src/cbits/GTK In directory sc8-pr-cvs1:/tmp/cvs-serv26896/src/cbits/GTK Modified Files: Menu.c ToolBar.c Log Message: Implementation for popup menus and dropdown tool buttons for GNOME Index: Menu.c =================================================================== RCS file: /cvsroot/htoolkit/port/src/cbits/GTK/Menu.c,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** Menu.c 17 Aug 2003 19:27:57 -0000 1.10 --- Menu.c 17 Aug 2003 22:02:45 -0000 1.11 *************** *** 19,23 **** } else ! parent = gtk_menu_item_get_submenu(GTK_MENU_ITEM(parent)); return parent; --- 19,24 ---- } else ! if (GTK_IS_MENU_ITEM(parent)) ! parent = gtk_menu_item_get_submenu(GTK_MENU_ITEM(parent)); return parent; *************** *** 72,75 **** --- 73,116 ---- } + MenuHandle osCreatePopupMenu() + { + GtkWidget *popUpMenu = gtk_menu_new(); + gtk_signal_connect (GTK_OBJECT(popUpMenu), "destroy", + GTK_SIGNAL_FUNC(handleMenuDestroy), + NULL); + gtk_signal_connect (GTK_OBJECT(popUpMenu), "show", + GTK_SIGNAL_FUNC(menu_show), + NULL); + return popUpMenu; + } + + struct PositioningParams + { + int x, y; + GtkWidget *widget; + }; + + static void menu_positioning(GtkMenu *menu, gint *x, gint *y, gboolean *push_in, struct PositioningParams *params) + { + gdk_window_get_origin(params->widget->window, x, y); + *x += params->x; + *y += params->y; + + *push_in = TRUE; + free(params); + } + + void osTrackPopupMenu(MenuHandle handle, WindowHandle hwnd, int x, int y) + { + struct PositioningParams *params = malloc(2*sizeof(struct PositioningParams)); + if (params) + { + params->x = x; + params->y = y; + params->widget = hwnd; + gtk_menu_popup(GTK_MENU(handle), NULL, NULL, menu_positioning, params, 0, gtk_get_current_event_time()); + } + } + MenuHandle osInsertMenu(MenuHandle parent, int pos) { *************** *** 227,236 **** void osSetMenuItemEnabled(MenuHandle item, BOOL bState) { ! gtk_widget_set_sensitive(item,bState); }; BOOL osGetMenuItemEnabled(MenuHandle item) { ! return GTK_WIDGET_SENSITIVE(item); }; --- 268,281 ---- void osSetMenuItemEnabled(MenuHandle item, BOOL bState) { ! if (GTK_IS_MENU_ITEM(item)) ! gtk_widget_set_sensitive(item,bState); }; BOOL osGetMenuItemEnabled(MenuHandle item) { ! if (GTK_IS_MENU_ITEM(item)) ! return GTK_WIDGET_SENSITIVE(item); ! else ! return TRUE; }; *************** *** 247,258 **** void osSetMenuLabel(MenuHandle item, char* title) { ! gchar *szText = toMnemonicString(title); ! gtk_label_set_text_with_mnemonic(GTK_LABEL(GTK_BIN(item)->child), szText); ! rfree(szText); } char *osGetMenuLabel(MenuHandle item) { ! return fromMnemonicString(gtk_label_get_text(GTK_LABEL(GTK_BIN(item)->child))); }; --- 292,309 ---- void osSetMenuLabel(MenuHandle item, char* title) { ! if (GTK_IS_MENU_ITEM(item)) ! { ! gchar *szText = toMnemonicString(title); ! gtk_label_set_text_with_mnemonic(GTK_LABEL(GTK_BIN(item)->child), szText); ! rfree(szText); ! } } char *osGetMenuLabel(MenuHandle item) { ! if (GTK_IS_MENU_ITEM(item)) ! return fromMnemonicString(gtk_label_get_text(GTK_LABEL(GTK_BIN(item)->child))); ! else ! return NULL; }; Index: ToolBar.c =================================================================== RCS file: /cvsroot/htoolkit/port/src/cbits/GTK/ToolBar.c,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** ToolBar.c 16 Aug 2003 16:01:36 -0000 1.5 --- ToolBar.c 17 Aug 2003 22:02:46 -0000 1.6 *************** *** 114,117 **** --- 114,137 ---- } + void tool_dropdown_button_clicked(GtkWidget *widget, gpointer user_data) + { + gtk_menu_popup(GTK_MENU(user_data), NULL, NULL, NULL, NULL, 0, gtk_get_current_event_time()); + } + + ToolHandle osInsertToolDropDownButton(WindowHandle toolbar, MenuHandle hmenu, int pos) + { + GtkToolItem *item = gtk_tool_button_new("", gtk_image_new()); + gtk_signal_connect (GTK_OBJECT(GTK_TOOL_BUTTON(item)->button), "clicked", + GTK_SIGNAL_FUNC(tool_dropdown_button_clicked), + hmenu); + gtk_signal_connect (GTK_OBJECT(item), "destroy", + GTK_SIGNAL_FUNC(handleToolDestroy), + NULL); + gtk_tool_button_set_label_widget(GTK_TOOL_BUTTON(item), gtk_label_new("")); + gtk_toolbar_insert(GTK_TOOLBAR(toolbar), item, pos); + gtk_widget_show_all(GTK_WIDGET(item)); + return GTK_WIDGET(item); + } + ToolHandle osInsertToolLine(WindowHandle toolbar, int pos) { |
From: <kr_...@us...> - 2003-08-17 19:28:00
|
Update of /cvsroot/htoolkit/port/src/cbits/GTK In directory sc8-pr-cvs1:/tmp/cvs-serv17930/src/cbits/GTK Modified Files: Menu.c Log Message: Code clearing Index: Menu.c =================================================================== RCS file: /cvsroot/htoolkit/port/src/cbits/GTK/Menu.c,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** Menu.c 16 Aug 2003 08:01:14 -0000 1.9 --- Menu.c 17 Aug 2003 19:27:57 -0000 1.10 *************** *** 206,282 **** void osDestroyMenu(MenuHandle handle) { ! GtkWidget *item, *menu; ! ! if (GTK_WIDGET_VISIBLE(handle)) ! gtk_widget_destroy(handle); ! else ! { ! menu = gtk_widget_get_parent(handle); ! ! for (;;) ! { ! GList *children = GTK_MENU_SHELL(menu)->children; ! ! while (children && children->data != handle) ! children = children->next; ! ! if (!children || !children->next) ! return; ! ! item = (GtkWidget *) children->next->data; ! ! if (!GTK_WIDGET_VISIBLE(item)) ! { ! gtk_widget_destroy(item); ! gtk_widget_destroy((GtkWidget *) children->data); ! return; ! } ! gtk_widget_destroy(item); ! } ! } } int osGetMenuItemCount(MenuHandle handle) { - BOOL b; int count; GList *children; - GtkWidget *menu; count = 0; ! ! if (!handle || GTK_WIDGET_VISIBLE(handle)) ! { ! menu = getMenu(handle); ! children = GTK_MENU_SHELL(menu)->children; ! ! b = TRUE; ! while (children) ! { ! if (b) count++; ! ! if (!GTK_WIDGET_VISIBLE((GtkWidget*) children->data)) ! { ! b = !b; ! } ! ! children = children->next; ! } ! } ! else { ! menu = gtk_widget_get_parent(handle); ! children = GTK_MENU_SHELL(menu)->children; ! ! while (children && children->data != handle) ! children = children->next; ! ! while (children && GTK_WIDGET_VISIBLE((GtkWidget *) children->data)) ! { ! count++; ! children = children->next; ! } ! ! count--; } --- 206,223 ---- void osDestroyMenu(MenuHandle handle) { ! gtk_widget_destroy(handle); } int osGetMenuItemCount(MenuHandle handle) { int count; GList *children; count = 0; ! children = GTK_MENU_SHELL(getMenu(handle))->children; ! while (children) { ! count++; ! children = children->next; } *************** *** 304,361 **** }; - void osSetMenuRadioGroupSelection(MenuHandle handle, int index) - { - GList *children; - GtkWidget *menu; - - menu = gtk_widget_get_parent(handle); - children = GTK_MENU_SHELL(menu)->children; - - while (children && children->data != handle) - children = children->next; - - if (!children || !children->next) - return; - - children = children->next; - while (children && GTK_WIDGET_VISIBLE((GtkWidget *) children->data) && index > 0) - { - index--; - children = children->next; - } - - if (children) - gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM((GtkWidget *) children->data), TRUE); - } - - int osGetMenuRadioGroupSelection(MenuHandle handle) - { - int index; - GList *children; - GtkWidget *menu; - - menu = gtk_widget_get_parent(handle); - children = GTK_MENU_SHELL(menu)->children; - - while (children && children->data != handle) - children = children->next; - - if (!children || !children->next) - return -1; - - index = 0; - children = children->next; - while (children && GTK_WIDGET_VISIBLE((GtkWidget *) children->data)) - { - if (gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM((GtkWidget *) children->data))) - return index; - - index++; - children = children->next; - } - - return -1; - } - void osSetMenuLabel(MenuHandle item, char* title) { --- 245,248 ---- *************** *** 541,587 **** int osGetMenuItemPos(MenuHandle handle) { - BOOL b; int pos; GList *children; - GtkWidget *menu; pos = 0; ! menu = getMenu(handle); ! children = GTK_MENU_SHELL(menu)->children; ! ! ! if (GTK_IS_RADIO_MENU_ITEM(handle)) ! { ! while (children && children->data != handle) ! { ! if (GTK_WIDGET_VISIBLE((GtkWidget*) children->data)) ! pos++; ! else ! pos = 0; ! ! children = children->next; ! } ! } ! else { ! b = TRUE; ! while (children && children->data != handle) ! { ! if (GTK_WIDGET_VISIBLE((GtkWidget*) children->data)) ! { ! if (b) pos++; ! } ! else ! { ! b = !b; ! } ! ! children = children->next; ! } } ! if (!children) pos = -1; ! ! return pos; } - --- 428,442 ---- int osGetMenuItemPos(MenuHandle handle) { int pos; GList *children; pos = 0; ! children = GTK_MENU_SHELL(getMenu(handle))->children; ! while (children && children->data != handle) { ! pos++; ! children = children->next; } ! return (children ? pos : -1); } |
From: <kr_...@us...> - 2003-08-17 18:15:12
|
Update of /cvsroot/htoolkit/gio/src/Graphics/UI/GIO In directory sc8-pr-cvs1:/tmp/cvs-serv6679/gio/src/Graphics/UI/GIO Modified Files: Menu.hs ToolBar.hs Log Message: Add support for ToolDropDownButton Index: Menu.hs =================================================================== RCS file: /cvsroot/htoolkit/gio/src/Graphics/UI/GIO/Menu.hs,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** Menu.hs 17 Aug 2003 16:45:07 -0000 1.11 --- Menu.hs 17 Aug 2003 18:15:09 -0000 1.12 *************** *** 25,28 **** --- 25,30 ---- -- ** Menu separator , MenuLine, menulineAt, menuline + -- * internal + , hmenu ) where Index: ToolBar.hs =================================================================== RCS file: /cvsroot/htoolkit/gio/src/Graphics/UI/GIO/ToolBar.hs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ToolBar.hs 16 Aug 2003 09:59:41 -0000 1.2 --- ToolBar.hs 17 Aug 2003 18:15:09 -0000 1.3 *************** *** 18,21 **** --- 18,22 ---- , ToolCheckButton, toolCheckButtonAt, toolCheckButton , ToolRadioButton, toolRadioButtonAt, toolRadioButton, setToolRadioGroup + , ToolDropDownButton, toolDropDownButtonAt, toolDropDownButton , ToolLine, toolLineAt, toolLine , DockPlace(..) *************** *** 25,28 **** --- 26,30 ---- import Graphics.UI.GIO.Events import Graphics.UI.GIO.Types + import Graphics.UI.GIO.Menu import qualified Graphics.UI.Port as Lib import Graphics.UI.Port(DockPlace(..)) *************** *** 167,174 **** instance Deadly ToolRadioButton where destroyWidget t = Lib.destroyToolItem (hradio t) ! destroy = newEvent (Lib.getToolDestroyHandler . hradio) (Lib.setToolDestroyHandler . hradio) (Lib.setToolDestroyDefHandler . hradio) setToolRadioGroup :: [ToolRadioButton] -> IO () setToolRadioGroup btns = Lib.setToolRadioGroup (map hradio btns) -------------------------------------------------------------------- --- 169,211 ---- instance Deadly ToolRadioButton where destroyWidget t = Lib.destroyToolItem (hradio t) ! destroy = newEvent (Lib.getToolDestroyHandler . hradio) (Lib.setToolDestroyHandler . hradio) (Lib.setToolDestroyDefHandler . hradio) setToolRadioGroup :: [ToolRadioButton] -> IO () setToolRadioGroup btns = Lib.setToolRadioGroup (map hradio btns) + + -------------------------------------------------------------------- + -- ToolDropDownButton + -------------------------------------------------------------------- + + data ToolDropDownButton = ToolDropDownButton {hdropdown :: ToolHandle} + + toolDropDownButtonAt :: Maybe Int -> Menu -> [Prop ToolDropDownButton] -> ToolBar -> IO ToolDropDownButton + toolDropDownButtonAt pos menu props (ToolBar hwnd) = do + btn <- do hbtn <- Lib.insertToolDropDownButton hwnd (hmenu menu) pos + return (ToolDropDownButton hbtn) + set btn props + return btn + + toolDropDownButton :: Menu -> [Prop ToolDropDownButton] -> ToolBar -> IO ToolDropDownButton + toolDropDownButton = toolDropDownButtonAt Nothing + + instance Able ToolDropDownButton where + enabled = newAttr (Lib.getToolButtonEnabled . hdropdown) (Lib.setToolButtonEnabled . hdropdown) + + instance HasIcon ToolDropDownButton where + icon = newAttr (Lib.getToolButtonBitmap . hdropdown) (Lib.setToolButtonBitmap . hdropdown) + + instance Positioned ToolDropDownButton where + pos = readAttr "pos" (Lib.getToolItemPos . hdropdown) + + instance ToolTip ToolDropDownButton where + tooltip = newAttr (Lib.getToolButtonTip . hdropdown) (Lib.setToolButtonTip . hdropdown) + + instance Titled ToolDropDownButton where + title = newAttr (Lib.getToolButtonText . hdropdown) (Lib.setToolButtonText . hdropdown) + + instance Deadly ToolDropDownButton where + destroyWidget t = Lib.destroyToolItem (hdropdown t) + destroy = newEvent (Lib.getToolDestroyHandler . hdropdown) (Lib.setToolDestroyHandler . hdropdown) (Lib.setToolDestroyDefHandler . hdropdown) -------------------------------------------------------------------- |
From: <kr_...@us...> - 2003-08-17 18:15:12
|
Update of /cvsroot/htoolkit/port/src/cbits/Win32 In directory sc8-pr-cvs1:/tmp/cvs-serv6679/port/src/cbits/Win32 Modified Files: DockBar.c Internals.h ToolBar.c Log Message: Add support for ToolDropDownButton Index: DockBar.c =================================================================== RCS file: /cvsroot/htoolkit/port/src/cbits/Win32/DockBar.c,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** DockBar.c 17 Aug 2003 17:10:37 -0000 1.4 --- DockBar.c 17 Aug 2003 18:15:08 -0000 1.5 *************** *** 171,175 **** handle = (ToolHandle) tbbi.lParam; ! osActivateToolItem(handle); } break; --- 171,194 ---- handle = (ToolHandle) tbbi.lParam; ! if (handle) osActivateToolItem(handle); ! } ! break; ! case WM_NOTIFY: ! { ! ToolHandle handle; ! TBBUTTONINFO tbbi; ! LPNMTOOLBAR lpNMToolBar = (LPNMTOOLBAR) lParam; ! ! if (lpNMToolBar->hdr.code == TBN_DROPDOWN) ! { ! tbbi.cbSize = sizeof(tbbi); ! tbbi.dwMask = TBIF_LPARAM; ! tbbi.lParam = 0; ! SendMessage(lpNMToolBar->hdr.hwndFrom, TB_GETBUTTONINFO, lpNMToolBar->iItem, (LPARAM) &tbbi); ! ! handle = (ToolHandle) tbbi.lParam; ! if (handle) ! osActivateToolItem(handle); ! } } break; Index: Internals.h =================================================================== RCS file: /cvsroot/htoolkit/port/src/cbits/Win32/Internals.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Internals.h 12 Aug 2003 19:09:56 -0000 1.5 --- Internals.h 17 Aug 2003 18:15:08 -0000 1.6 *************** *** 44,47 **** --- 44,55 ---- #endif + #ifndef BTNS_WHOLEDROPDOWN + #define BTNS_WHOLEDROPDOWN 0x0080 + #endif + + #ifndef TBN_DROPDOWN + #define TBN_DROPDOWN (TBN_FIRST - 10) + #endif + extern HMODULE ghModule; extern HWND ghWndFrame; Index: ToolBar.c =================================================================== RCS file: /cvsroot/htoolkit/port/src/cbits/Win32/ToolBar.c,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** ToolBar.c 16 Aug 2003 20:48:54 -0000 1.14 --- ToolBar.c 17 Aug 2003 18:15:08 -0000 1.15 *************** *** 20,23 **** --- 20,31 ---- static int nNextToolButtonID = 0; + enum TOOL_TYPE + { TOOL_SUBMENU = 1 + , TOOL_SEPARATOR = 2 + , TOOL_ITEM = 4 + , TOOL_CHECK_ITEM = 8 + , TOOL_RADIO_ITEM = 16 + }; + struct ToolHandle { *************** *** 25,30 **** HWND hToolBar; BitmapHandle bitmap; ! BOOL bRadio; ToolHandle nextInGroup; }; --- 33,39 ---- HWND hToolBar; BitmapHandle bitmap; ! enum TOOL_TYPE type; ToolHandle nextInGroup; + MenuHandle menu; }; *************** *** 815,820 **** btn->nCommand = ++nNextToolButtonID; btn->hToolBar = toolBar; btn->bitmap = NULL; ! btn->bRadio = FALSE; btn->nextInGroup = btn; --- 824,830 ---- btn->nCommand = ++nNextToolButtonID; btn->hToolBar = toolBar; + btn->menu = NULL; btn->bitmap = NULL; ! btn->type = TOOL_ITEM; btn->nextInGroup = btn; *************** *** 845,850 **** btn->nCommand = ++nNextToolButtonID; btn->hToolBar = toolBar; btn->bitmap = NULL; ! btn->bRadio = FALSE; btn->nextInGroup = btn; --- 855,861 ---- btn->nCommand = ++nNextToolButtonID; btn->hToolBar = toolBar; + btn->menu = NULL; btn->bitmap = NULL; ! btn->type = TOOL_CHECK_ITEM; btn->nextInGroup = btn; *************** *** 875,880 **** btn->nCommand = ++nNextToolButtonID; btn->hToolBar = toolBar; btn->bitmap = NULL; ! btn->bRadio = TRUE; btn->nextInGroup = btn; --- 886,892 ---- btn->nCommand = ++nNextToolButtonID; btn->hToolBar = toolBar; + btn->menu = NULL; btn->bitmap = NULL; ! btn->type = TOOL_RADIO_ITEM; btn->nextInGroup = btn; *************** *** 920,929 **** } void osActivateToolItem(ToolHandle toolButton) { ! if (toolButton->bRadio) osSetToolButtonChecked(toolButton, TRUE); ! else handleToolCommand(toolButton); } --- 932,992 ---- } + ToolHandle osInsertToolDropDownButton(WindowHandle toolBar, MenuHandle hmenu, int pos) + { + TBBUTTON tbb; + ToolHandle btn; + + btn = malloc(sizeof(struct ToolHandle)); + if (!btn) return NULL; + + btn->nCommand = ++nNextToolButtonID; + btn->hToolBar = toolBar; + btn->menu = hmenu; + btn->bitmap = NULL; + btn->type = TOOL_SUBMENU; + btn->nextInGroup = btn; + + tbb.iBitmap = I_IMAGENONE; + tbb.idCommand = btn->nCommand; + tbb.fsState = TBSTATE_ENABLED; + tbb.fsStyle = TBSTYLE_BUTTON | BTNS_WHOLEDROPDOWN; + tbb.dwData = (DWORD)btn; + tbb.iString = 0; + + if (pos > 0) + SendMessage(toolBar,TB_INSERTBUTTON,pos,(LPARAM)&tbb); + else + SendMessage(toolBar,TB_ADDBUTTONS, 1, (LPARAM)&tbb); + + RelayoutFrameBars(); + return btn; + } + void osActivateToolItem(ToolHandle toolButton) { ! switch (toolButton->type) ! { ! case TOOL_RADIO_ITEM: osSetToolButtonChecked(toolButton, TRUE); ! break; ! case TOOL_SUBMENU: ! { ! RECT rect; ! int nBtnPos; ! ! memset(&rect, 0, sizeof(rect)); ! nBtnPos = SendMessage(toolButton->hToolBar, TB_COMMANDTOINDEX, toolButton->nCommand, 0); ! SendMessage(toolButton->hToolBar, TB_GETITEMRECT, nBtnPos, (LPARAM)&rect); ! ! ClientToScreen(toolButton->hToolBar, ((POINT *) &rect)); ! ClientToScreen(toolButton->hToolBar, ((POINT *) &rect)+1); ! ! TrackPopupMenu(toolButton->menu->hMenu, TPM_LEFTALIGN | TPM_TOPALIGN, rect.left, rect.bottom, 0, ghWndFrame, NULL); ! } ! break; ! default: handleToolCommand(toolButton); + break; + } } *************** *** 939,942 **** --- 1002,1006 ---- btn->nCommand = ++nNextToolButtonID; btn->hToolBar = toolBar; + btn->menu = NULL; btn->bitmap = NULL; btn->nextInGroup = btn; |
From: <kr_...@us...> - 2003-08-17 18:15:11
|
Update of /cvsroot/htoolkit/port/src/include In directory sc8-pr-cvs1:/tmp/cvs-serv6679/port/src/include Modified Files: ToolBar.h Log Message: Add support for ToolDropDownButton Index: ToolBar.h =================================================================== RCS file: /cvsroot/htoolkit/port/src/include/ToolBar.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** ToolBar.h 16 Aug 2003 09:59:41 -0000 1.5 --- ToolBar.h 17 Aug 2003 18:15:09 -0000 1.6 *************** *** 12,15 **** --- 12,16 ---- ToolHandle osInsertToolCheckButton(WindowHandle toolbar, int pos); ToolHandle osInsertToolRadioButton(WindowHandle toolBar, int pos); + ToolHandle osInsertToolDropDownButton(WindowHandle toolBar, MenuHandle hmenu, int pos); ToolHandle osInsertToolLine(WindowHandle toolbar, int pos); void osSetToolRadioGroup(ToolHandle *handles); |
From: <kr_...@us...> - 2003-08-17 18:15:11
|
Update of /cvsroot/htoolkit/port/src/Port In directory sc8-pr-cvs1:/tmp/cvs-serv6679/port/src/Port Modified Files: ToolBar.hs Log Message: Add support for ToolDropDownButton Index: ToolBar.hs =================================================================== RCS file: /cvsroot/htoolkit/port/src/Port/ToolBar.hs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** ToolBar.hs 16 Aug 2003 09:59:41 -0000 1.3 --- ToolBar.hs 17 Aug 2003 18:15:08 -0000 1.4 *************** *** 22,25 **** --- 22,26 ---- , insertToolCheckButton , insertToolRadioButton + , insertToolDropDownButton , insertToolLine , setToolRadioGroup *************** *** 72,75 **** --- 73,80 ---- setToolRadioGroup handles = withArray0 nullHandle handles osSetToolRadioGroup foreign import ccall osSetToolRadioGroup :: Ptr ToolHandle -> IO () + + insertToolDropDownButton :: WindowHandle -> MenuHandle -> Maybe Int -> IO ToolHandle + insertToolDropDownButton toolBar menu pos = osInsertToolDropDownButton toolBar menu (fromMaybe (-1) pos) + foreign import ccall osInsertToolDropDownButton :: WindowHandle -> MenuHandle -> Int -> IO ToolHandle insertToolLine :: WindowHandle -> Maybe Int -> IO ToolHandle |
From: <kr_...@us...> - 2003-08-17 17:10:40
|
Update of /cvsroot/htoolkit/port/src/cbits/Win32 In directory sc8-pr-cvs1:/tmp/cvs-serv29553/src/cbits/Win32 Modified Files: DockBar.c Log Message: formatting Index: DockBar.c =================================================================== RCS file: /cvsroot/htoolkit/port/src/cbits/Win32/DockBar.c,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** DockBar.c 16 Aug 2003 20:48:54 -0000 1.3 --- DockBar.c 17 Aug 2003 17:10:37 -0000 1.4 *************** *** 170,174 **** SendMessage(hToolBar, TB_GETBUTTONINFO, LOWORD(wParam), (LPARAM) &tbbi); ! handle = (ToolHandle) tbbi.lParam; osActivateToolItem(handle); } --- 170,174 ---- SendMessage(hToolBar, TB_GETBUTTONINFO, LOWORD(wParam), (LPARAM) &tbbi); ! handle = (ToolHandle) tbbi.lParam; osActivateToolItem(handle); } |
From: <kr_...@us...> - 2003-08-17 16:45:11
|
Update of /cvsroot/htoolkit/gio/src/Graphics/UI/GIO In directory sc8-pr-cvs1:/tmp/cvs-serv25012/gio/src/Graphics/UI/GIO Modified Files: Menu.hs Log Message: Implementation for popup menus Index: Menu.hs =================================================================== RCS file: /cvsroot/htoolkit/gio/src/Graphics/UI/GIO/Menu.hs,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** Menu.hs 15 Aug 2003 21:24:54 -0000 1.10 --- Menu.hs 17 Aug 2003 16:45:07 -0000 1.11 *************** *** 13,27 **** module Graphics.UI.GIO.Menu ( -- * Menus ! Menu, mainMenu, menu, menuAt, itemCount -- * Menu items ! -- ** Menu item ! , MenuItem, menuitem, menuitemAt ! -- ** Checked menu items ! , MenuCheck, menucheck, menucheckAt -- ** Radio items , MenuRadioItem, menuRadioItemAt, menuRadioItem , setMenuRadioGroup -- ** Menu separator ! , MenuLine, menuline, menulineAt ) where --- 13,28 ---- module Graphics.UI.GIO.Menu ( -- * Menus ! Menu, mainMenu, menuAt, menu, itemCount ! , popupMenu, trackPopupMenu -- * Menu items ! -- ** Command items ! , MenuItem, menuitemAt, menuitem ! -- ** Checked items ! , MenuCheck, menucheckAt, menucheck -- ** Radio items , MenuRadioItem, menuRadioItemAt, menuRadioItem , setMenuRadioGroup -- ** Menu separator ! , MenuLine, menulineAt, menuline ) where *************** *** 42,51 **** hmenu (Menu h) = h ! -- | The main application menu mainMenu :: Menu mainMenu = Menu Lib.mainMenu ! -- | Insert a menu at specified position. ! menuAt :: Maybe Int -> [Prop Menu] -> Menu -> IO Menu menuAt pos props parent = do m <- do hmenu <- Lib.insertMenu (hmenu parent) pos --- 43,59 ---- hmenu (Menu h) = h ! -- | The main application menu (the menu bar) mainMenu :: Menu mainMenu = Menu Lib.mainMenu ! -- | The 'menuAt' function creates and inserts an item with submenu in the parent menu. ! -- The created submenu is initially empty. You can populate it with items by using the ! -- 'menuitemAt', 'menucheckAt', 'menuRadioItemAt' or 'menulineAt' functions. ! -- Using the 'menuAt' you can create nested submenus. ! menuAt :: Maybe Int -- ^ The position where to place the submenu ! -- or Nothing if you want to append the item. ! -> [Prop Menu] -- ^ The setup of the menu attributes ! -> Menu -- ^ The parent menu ! -> IO Menu -- ^ The created sub menu menuAt pos props parent = do m <- do hmenu <- Lib.insertMenu (hmenu parent) pos *************** *** 54,61 **** return m ! -- | Append a menu menu :: [Prop Menu] -> Menu -> IO Menu menu = menuAt Nothing instance Able Menu where enabled = newAttr (Lib.getMenuItemEnabled . hmenu) (Lib.setMenuItemEnabled . hmenu) --- 62,88 ---- return m ! -- | The function is the same as the 'menuAt' function but always appends the item. The 'menu' function ! -- is semantically equal to @menuAt Nothing@ menu :: [Prop Menu] -> Menu -> IO Menu menu = menuAt Nothing + -- | The 'popupMenu' function creates a popup menu. The menu is initially empty. + -- You can populate it with items by using the 'menuitemAt', 'menucheckAt', + -- 'menuRadioItemAt' or 'menulineAt' functions. Using the 'menuAt' you can create nested submenus. + popupMenu :: [Prop Menu] -> IO Menu + popupMenu props + = do m <- do hmenu <- Lib.createPopupMenu + return (Menu hmenu) + set m props + return m + + -- | The 'trackPopupMenu' function displays a popup menu at the specified location in the + -- window and tracks the selection of items on the menu. + trackPopupMenu :: Menu -- ^ The popup menu + -> Window -- ^ The window in which to popup the menu + -> Point -- ^ The location inside the window at which to display the menu + -> IO () + trackPopupMenu menu window pos = Lib.trackPopupMenu (hmenu menu) (hwindow window) pos + instance Able Menu where enabled = newAttr (Lib.getMenuItemEnabled . hmenu) (Lib.setMenuItemEnabled . hmenu) *************** *** 63,67 **** instance Titled Menu where title = newAttr (Lib.getMenuLabel . hmenu) (Lib.setMenuLabel . hmenu) ! itemCount :: Attr Menu Int itemCount = readAttr "itemsCount" (Lib.getMenuItemCount . hmenu) --- 90,96 ---- instance Titled Menu where title = newAttr (Lib.getMenuLabel . hmenu) (Lib.setMenuLabel . hmenu) ! ! -- | The 'itemCount' attribute is readonly and returns the number of items in the ! -- popup or sub menu. itemCount :: Attr Menu Int itemCount = readAttr "itemsCount" (Lib.getMenuItemCount . hmenu) *************** *** 122,131 **** -------------------------------------------------------------------- ! -- | Radio menu items are labeled entries in a menu. newtype MenuRadioItem = MenuRadioItem MenuHandle hradioitem (MenuRadioItem h) = h ! -- | Create a menu item and insert it at specified position. ! menuRadioItemAt :: Maybe Int -> [Prop MenuRadioItem] -> Menu -> IO MenuRadioItem menuRadioItemAt pos props menu = do mradioitem <- do hradioitem <- Lib.insertMenuRadioItem (hmenu menu) pos --- 151,167 ---- -------------------------------------------------------------------- ! -- | Radio menu items are labeled entries in a menu with bookmark. ! -- Sometimes, a group of menu items corresponds to a set of mutually exclusive options. ! -- In this case, you can indicate the selected option by using a selected radio menu item. ! -- To check a menu item use the 'checked' attribute. newtype MenuRadioItem = MenuRadioItem MenuHandle hradioitem (MenuRadioItem h) = h ! -- | Create a radio menu item and insert it at specified position. ! menuRadioItemAt :: Maybe Int -- ^ The position where to place the item ! -- or Nothing if you want to append it. ! -> [Prop MenuRadioItem] -- ^ The setup of the radio item attributes ! -> Menu -- ^ The parent menu ! -> IO MenuRadioItem -- ^ The created radio item menuRadioItemAt pos props menu = do mradioitem <- do hradioitem <- Lib.insertMenuRadioItem (hmenu menu) pos *************** *** 134,138 **** return mradioitem ! -- | Create a menu item and appends it to parent menu. menuRadioItem :: [Prop MenuRadioItem] -> Menu -> IO MenuRadioItem menuRadioItem = menuRadioItemAt Nothing --- 170,175 ---- return mradioitem ! -- | The function is the same as the 'menuRadioItemAt' function but always appends the item. The 'menuRadioItem' ! -- function is semantically equal to @menuRadioItemAt Nothing@ menuRadioItem :: [Prop MenuRadioItem] -> Menu -> IO MenuRadioItem menuRadioItem = menuRadioItemAt Nothing *************** *** 162,166 **** instance Accelerated MenuRadioItem where accel = newAttr (Lib.getMenuItemAccel . hradioitem) (Lib.setMenuItemAccel . hradioitem) ! setMenuRadioGroup :: [MenuRadioItem] -> IO () setMenuRadioGroup items = Lib.setMenuRadioGroup (map hradioitem items) --- 199,204 ---- instance Accelerated MenuRadioItem where accel = newAttr (Lib.getMenuItemAccel . hradioitem) (Lib.setMenuItemAccel . hradioitem) ! ! -- | The 'setMenuRadioGroup' function specifies a set of mutually exclusive options. setMenuRadioGroup :: [MenuRadioItem] -> IO () setMenuRadioGroup items = Lib.setMenuRadioGroup (map hradioitem items) *************** *** 169,178 **** -- Checked menu items -------------------------------------------------------------------- ! -- | Menu items are labeled entries in a menu. newtype MenuCheck = MenuCheck MenuHandle hcheck (MenuCheck h) = h ! -- | Create a menu item and insert it at specified position. ! menucheckAt :: Maybe Int -> [Prop MenuCheck] -> Menu -> IO MenuCheck menucheckAt pos props menu = do mcheck <- do mcheck <- Lib.insertMenuCheckItem (hmenu menu) pos --- 207,222 ---- -- Checked menu items -------------------------------------------------------------------- ! -- | Checked menu items are labeled entries in a menu with check mark. ! -- Applications typically check or clear a menu item to indicate whether ! -- an option is in effect. newtype MenuCheck = MenuCheck MenuHandle hcheck (MenuCheck h) = h ! -- | Create a check menu item and insert it at specified position. ! menucheckAt :: Maybe Int -- ^ The position where to place the item ! -- or Nothing if you want to append it. ! -> [Prop MenuCheck] -- ^ The setup of the item attributes ! -> Menu -- ^ The parent menu ! -> IO MenuCheck -- ^ The created checked item menucheckAt pos props menu = do mcheck <- do mcheck <- Lib.insertMenuCheckItem (hmenu menu) pos *************** *** 181,185 **** return mcheck ! -- | Create a checked menu item and appends it to parent menu. menucheck :: [Prop MenuCheck] -> Menu -> IO MenuCheck menucheck = menucheckAt Nothing --- 225,230 ---- return mcheck ! -- | The function is the same as the 'menucheckAt' function but always appends the item. The 'menucheck' ! -- function is semantically equal to @menucheckAt Nothing@ menucheck :: [Prop MenuCheck] -> Menu -> IO MenuCheck menucheck = menucheckAt Nothing |
From: <kr_...@us...> - 2003-08-17 16:45:10
|
Update of /cvsroot/htoolkit/port/src/Port In directory sc8-pr-cvs1:/tmp/cvs-serv25012/port/src/Port Modified Files: Menu.hs Log Message: Implementation for popup menus Index: Menu.hs =================================================================== RCS file: /cvsroot/htoolkit/port/src/Port/Menu.hs,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** Menu.hs 15 Aug 2003 21:24:54 -0000 1.10 --- Menu.hs 17 Aug 2003 16:45:07 -0000 1.11 *************** *** 9,13 **** Portability : portable ! Menus -} ----------------------------------------------------------------------------------------- --- 9,17 ---- Portability : portable ! The module contains all functions for creation and management of menus. ! A menu is a list of items that specify options or groups of options (a submenu). ! Clicking a menu item opens a submenu or causes the application to carry out a command. ! A menu is arranged in a hierarchy. At the top level of the hierarchy is the menu bar; ! which contains a list of menus, which in turn can contain submenus. -} ----------------------------------------------------------------------------------------- *************** *** 19,22 **** --- 23,29 ---- , insertMenu , getMenuItemCount + -- * Popup menus + , createPopupMenu + , trackPopupMenu -- * Menu items , insertMenuItem *************** *** 48,52 **** ----------------------------------------------------------------------------------------- ! -- | The handle of the main application menu mainMenu :: MenuHandle mainMenu = nullHandle --- 55,59 ---- ----------------------------------------------------------------------------------------- ! -- | The main application menu (the menu bar) mainMenu :: MenuHandle mainMenu = nullHandle *************** *** 56,66 **** ----------------------------------------------------------------------------------------- ! -- | Add a sub menu. ! insertMenu :: MenuHandle -> Maybe Int -> IO MenuHandle insertMenu handle pos = osInsertMenu handle (fromMaybe (-1) pos) foreign import ccall osInsertMenu :: MenuHandle -> Int -> IO MenuHandle ! -- | The getMenuItemsCount function determines the number of items in the specified menu. foreign import ccall "osGetMenuItemCount" getMenuItemCount :: MenuHandle -> IO Int ----------------------------------------------------------------------------------------- --- 63,101 ---- ----------------------------------------------------------------------------------------- ! -- | The 'insertMenu' function creates and inserts an item with submenu in the parent menu. ! -- The created submenu is initially empty. You can insert or append menu items by using the ! -- 'insertMenuItem', 'insertMenuCheckItem', 'insertMenuRadioItem' or 'insertMenuSeparatorItem' ! -- functions. Using the 'insertMenu' you can create nested submenus. ! insertMenu :: MenuHandle -- ^ The handle of the parent menu. ! -- Use the 'mainMenu' handle if you want to ! -- place the menu in the application menu bar. ! -> Maybe Int -- ^ The position where to place the submenu. ! -- or Nothing if you want to append it. ! -> IO MenuHandle -- ^ The handle of the created submenu. insertMenu handle pos = osInsertMenu handle (fromMaybe (-1) pos) foreign import ccall osInsertMenu :: MenuHandle -> Int -> IO MenuHandle ! -- | The 'getMenuItemCount' function determines the number of items in the ! -- specified popup or sub menu. foreign import ccall "osGetMenuItemCount" getMenuItemCount :: MenuHandle -> IO Int + + ----------------------------------------------------------------------------------------- + -- Popup menus + ----------------------------------------------------------------------------------------- + + -- | The 'createPopupMenu' function creates a drop-down menu. The menu is initially empty. + -- You can insert or append menu items by using the 'insertMenuItem', + -- 'insertMenuCheckItem', 'insertMenuRadioItem' or 'insertMenuSeparatorItem' functions. + -- Using the 'insertMenu' you can create nested submenus. + foreign import ccall "osCreatePopupMenu" createPopupMenu :: IO MenuHandle -- ^ The handle of the created popup menu. + + -- | The 'trackPopupMenu' function displays a shortcut menu at the specified location in the + -- window and tracks the selection of items on the menu. + trackPopupMenu :: MenuHandle -- ^ The handle of the popup menu + -> WindowHandle -- ^ The handle of the window in which to popup the menu + -> Point -- ^ The location inside the window at which to display the menu + -> IO () + trackPopupMenu handle hwnd pos = withCPoint pos (osTrackPopupMenu handle hwnd) + foreign import ccall osTrackPopupMenu :: MenuHandle -> WindowHandle -> CInt -> CInt -> IO () ----------------------------------------------------------------------------------------- |
From: <kr_...@us...> - 2003-08-17 16:45:10
|
Update of /cvsroot/htoolkit/port/src/include In directory sc8-pr-cvs1:/tmp/cvs-serv25012/port/src/include Modified Files: Menu.h Log Message: Implementation for popup menus Index: Menu.h =================================================================== RCS file: /cvsroot/htoolkit/port/src/include/Menu.h,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** Menu.h 15 Aug 2003 21:24:54 -0000 1.7 --- Menu.h 17 Aug 2003 16:45:07 -0000 1.8 *************** *** 4,7 **** --- 4,10 ---- #include "Types.h" + MenuHandle osCreatePopupMenu(); + void osTrackPopupMenu(MenuHandle handle, WindowHandle hwnd, int x, int y); + MenuHandle osInsertMenu(MenuHandle parent, int pos); MenuHandle osInsertMenuItem(MenuHandle parent, int pos); |
From: <kr_...@us...> - 2003-08-17 16:45:10
|
Update of /cvsroot/htoolkit/port/src/cbits/Win32 In directory sc8-pr-cvs1:/tmp/cvs-serv25012/port/src/cbits/Win32 Modified Files: Menu.c MenuHandlesMap.c MenuHandlesMap.h Log Message: Implementation for popup menus Index: Menu.c =================================================================== RCS file: /cvsroot/htoolkit/port/src/cbits/Win32/Menu.c,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** Menu.c 15 Aug 2003 21:24:54 -0000 1.12 --- Menu.c 17 Aug 2003 16:45:07 -0000 1.13 *************** *** 6,10 **** #define CHECK_MENU_TYPE(handle,mask,ret) \ ! if (((handle ? handle->type : MENU_POPUP) & (mask)) == 0) \ { \ printf("Invalid menu handle type."); \ --- 6,10 ---- #define CHECK_MENU_TYPE(handle,mask,ret) \ ! if (((handle ? handle->type : MENU_SUBMENU) & (mask)) == 0) \ { \ printf("Invalid menu handle type."); \ *************** *** 13,17 **** #define CHECK_MENU_TYPE_V(handle,mask) \ ! if (((handle ? handle->type : MENU_POPUP) & (mask)) == 0) \ { \ printf("Invalid menu handle type."); \ --- 13,17 ---- #define CHECK_MENU_TYPE_V(handle,mask) \ ! if (((handle ? handle->type : MENU_SUBMENU) & (mask)) == 0) \ { \ printf("Invalid menu handle type."); \ *************** *** 103,106 **** --- 103,129 ---- } + MenuHandle osCreatePopupMenu() + { + MenuHandle handle; + FrameData *pFrameData; + + pFrameData = (FrameData *) GetWindowLong(ghWndFrame,GWL_USERDATA); + handle = newMenuHandle(pFrameData->pMenuHandlesMap, NULL, MENU_POPUP, -1); + + if (handle) + handle->hMenu = CreatePopupMenu(); + + return handle; + }; + + void osTrackPopupMenu(MenuHandle handle, WindowHandle hWnd, int x, int y) + { + POINT pos; + pos.x = x; + pos.y = y; + ClientToScreen(hWnd, &pos); + TrackPopupMenu(handle->hMenu, TPM_LEFTALIGN | TPM_TOPALIGN, pos.x, pos.y, 0, ghWndFrame, NULL); + } + MenuHandle osInsertMenu(MenuHandle parent, int pos) { *************** *** 108,115 **** FrameData *pFrameData; ! CHECK_MENU_TYPE(parent, MENU_POPUP, NULL); pFrameData = (FrameData *) GetWindowLong(ghWndFrame,GWL_USERDATA); ! handle = newMenuHandle(pFrameData->pMenuHandlesMap, parent, MENU_POPUP, pos); if (handle) --- 131,138 ---- FrameData *pFrameData; ! CHECK_MENU_TYPE(parent, MENU_SUBMENU | MENU_POPUP, NULL); pFrameData = (FrameData *) GetWindowLong(ghWndFrame,GWL_USERDATA); ! handle = newMenuHandle(pFrameData->pMenuHandlesMap, parent, MENU_SUBMENU, pos); if (handle) *************** *** 130,134 **** FrameData *pFrameData; ! CHECK_MENU_TYPE(parent, MENU_POPUP, NULL); pFrameData = (FrameData *) GetWindowLong(ghWndFrame,GWL_USERDATA); --- 153,157 ---- FrameData *pFrameData; ! CHECK_MENU_TYPE(parent, MENU_SUBMENU | MENU_POPUP, NULL); pFrameData = (FrameData *) GetWindowLong(ghWndFrame,GWL_USERDATA); *************** *** 149,153 **** FrameData *pFrameData; ! CHECK_MENU_TYPE(parent, MENU_POPUP, NULL); pFrameData = (FrameData *) GetWindowLong(ghWndFrame,GWL_USERDATA); --- 172,176 ---- FrameData *pFrameData; ! CHECK_MENU_TYPE(parent, MENU_SUBMENU | MENU_POPUP, NULL); pFrameData = (FrameData *) GetWindowLong(ghWndFrame,GWL_USERDATA); *************** *** 168,172 **** FrameData *pFrameData; ! CHECK_MENU_TYPE(parent, MENU_POPUP, NULL); pFrameData = (FrameData *) GetWindowLong(ghWndFrame,GWL_USERDATA); --- 191,195 ---- FrameData *pFrameData; ! CHECK_MENU_TYPE(parent, MENU_SUBMENU | MENU_POPUP, NULL); pFrameData = (FrameData *) GetWindowLong(ghWndFrame,GWL_USERDATA); *************** *** 188,192 **** MENUITEMINFO mii; ! CHECK_MENU_TYPE(parent, MENU_POPUP, NULL); pFrameData = (FrameData *) GetWindowLong(ghWndFrame,GWL_USERDATA); --- 211,215 ---- MENUITEMINFO mii; ! CHECK_MENU_TYPE(parent, MENU_SUBMENU | MENU_POPUP, NULL); pFrameData = (FrameData *) GetWindowLong(ghWndFrame,GWL_USERDATA); *************** *** 238,245 **** notifyHandleForDestroy(handle); ! DeleteMenu(getParentHMENU(handle), getMenuPos(pFrameData->pMenuHandlesMap, handle), MF_BYPOSITION); deleteMenuHandle(pFrameData->pMenuHandlesMap, handle); - - updateMenuBar(handle->parent); } --- 261,271 ---- notifyHandleForDestroy(handle); ! if (handle->type != MENU_POPUP) ! { ! DeleteMenu(getParentHMENU(handle), getMenuPos(pFrameData->pMenuHandlesMap, handle), MF_BYPOSITION); ! updateMenuBar(handle->parent); ! } ! deleteMenuHandle(pFrameData->pMenuHandlesMap, handle); } *************** *** 248,252 **** FrameData *pFrameData; ! CHECK_MENU_TYPE(handle, MENU_POPUP, 0); pFrameData = (FrameData *) GetWindowLong(ghWndFrame,GWL_USERDATA); --- 274,278 ---- FrameData *pFrameData; ! CHECK_MENU_TYPE(handle, MENU_SUBMENU | MENU_POPUP, 0); pFrameData = (FrameData *) GetWindowLong(ghWndFrame,GWL_USERDATA); *************** *** 257,283 **** void osSetMenuItemEnabled(MenuHandle handle, BOOL bState) { ! FrameData *pFrameData; ! ! CHECK_MENU_TYPE_V(handle, MENU_RADIO_ITEM | MENU_CHECK_ITEM | MENU_ITEM | MENU_POPUP); ! ! pFrameData = (FrameData *) GetWindowLong(ghWndFrame,GWL_USERDATA); ! ! EnableMenuItem(getParentHMENU(handle), getMenuPos(pFrameData->pMenuHandlesMap, handle), (bState ? MF_ENABLED : MF_GRAYED) | MF_BYPOSITION); ! updateMenuBar(handle->parent); }; BOOL osGetMenuItemEnabled(MenuHandle handle) { ! MENUITEMINFO mii; ! FrameData *pFrameData; ! ! CHECK_MENU_TYPE(handle, MENU_RADIO_ITEM | MENU_CHECK_ITEM | MENU_ITEM | MENU_POPUP, FALSE); ! ! pFrameData = (FrameData *) GetWindowLong(ghWndFrame,GWL_USERDATA); ! ! mii.cbSize = sizeof(mii); ! mii.fMask = MIIM_STATE; ! GetMenuItemInfo(getParentHMENU(handle), getMenuPos(pFrameData->pMenuHandlesMap, handle), TRUE, &mii); ! return (mii.fState & MFS_DISABLED) == 0; }; --- 283,317 ---- void osSetMenuItemEnabled(MenuHandle handle, BOOL bState) { ! if (handle->type != MENU_POPUP) ! { ! FrameData *pFrameData; ! ! CHECK_MENU_TYPE_V(handle, MENU_RADIO_ITEM | MENU_CHECK_ITEM | MENU_ITEM | MENU_SUBMENU); ! ! pFrameData = (FrameData *) GetWindowLong(ghWndFrame,GWL_USERDATA); ! ! EnableMenuItem(getParentHMENU(handle), getMenuPos(pFrameData->pMenuHandlesMap, handle), (bState ? MF_ENABLED : MF_GRAYED) | MF_BYPOSITION); ! updateMenuBar(handle->parent); ! } }; BOOL osGetMenuItemEnabled(MenuHandle handle) { ! if (handle->type != MENU_POPUP) ! { ! MENUITEMINFO mii; ! FrameData *pFrameData; ! ! CHECK_MENU_TYPE(handle, MENU_RADIO_ITEM | MENU_CHECK_ITEM | MENU_ITEM | MENU_SUBMENU, FALSE); ! ! pFrameData = (FrameData *) GetWindowLong(ghWndFrame,GWL_USERDATA); ! ! mii.cbSize = sizeof(mii); ! mii.fMask = MIIM_STATE; ! GetMenuItemInfo(getParentHMENU(handle), getMenuPos(pFrameData->pMenuHandlesMap, handle), TRUE, &mii); ! return (mii.fState & MFS_DISABLED) == 0; ! } ! else ! return TRUE; }; *************** *** 327,405 **** char *osGetMenuLabel(MenuHandle handle) { ! int pos; ! HMENU hParent; ! char *s; ! MENUITEMINFO mii; ! FrameData *pFrameData; ! CHECK_MENU_TYPE(handle, MENU_POPUP | MENU_RADIO_ITEM | MENU_CHECK_ITEM | MENU_ITEM, NULL); ! pFrameData = (FrameData *) GetWindowLong(ghWndFrame,GWL_USERDATA); ! pos = getMenuPos(pFrameData->pMenuHandlesMap, handle); ! hParent = getParentHMENU(handle); ! ! memset(&mii,0,sizeof(mii)); ! mii.cbSize = sizeof(mii); ! mii.fMask = MIIM_STRING; ! mii.fType = MFT_STRING; ! mii.dwTypeData = NULL; ! mii.cch = 0; ! GetMenuItemInfo(hParent, pos, TRUE, &mii); ! mii.cch++; ! mii.dwTypeData = malloc(mii.cch); ! ! if (mii.dwTypeData) ! { GetMenuItemInfo(hParent, pos, TRUE, &mii); ! ! s = mii.dwTypeData; ! while (*s && *s != '\t') s++; ! *s = 0; } ! ! return mii.dwTypeData; } void osSetMenuLabel(MenuHandle handle, char *title) { ! char *s, *temp; ! MENUITEMINFO mii; ! FrameData *pFrameData; ! ! CHECK_MENU_TYPE_V(handle, MENU_POPUP | MENU_RADIO_ITEM | MENU_CHECK_ITEM | MENU_ITEM); ! ! pFrameData = (FrameData *) GetWindowLong(ghWndFrame,GWL_USERDATA); ! ! if (handle->parent == NULL) ! temp = title; ! else { ! temp = malloc(strlen(title)+32); ! if (!temp) temp = title; else { ! s = temp; ! while (*title) { ! if (*title != '\t') *s++ = *title; ! title++; } - *s = 0; - AddAccelString(handle->key, handle->mods, temp); } - } ! memset(&mii,0,sizeof(mii)); ! mii.cbSize = sizeof(mii); ! mii.fMask = MIIM_STRING; ! mii.fType = MFT_STRING; ! mii.dwTypeData = temp; ! mii.cch = strlen(temp); ! SetMenuItemInfo(getParentHMENU(handle), getMenuPos(pFrameData->pMenuHandlesMap, handle), TRUE, &mii); ! updateMenuBar(handle->parent); ! if (temp != title) free(temp); } --- 361,447 ---- char *osGetMenuLabel(MenuHandle handle) { ! if (handle->type != MENU_POPUP) ! { ! int pos; ! HMENU hParent; ! char *s; ! MENUITEMINFO mii; ! FrameData *pFrameData; ! CHECK_MENU_TYPE(handle, MENU_SUBMENU | MENU_RADIO_ITEM | MENU_CHECK_ITEM | MENU_ITEM, NULL); ! pFrameData = (FrameData *) GetWindowLong(ghWndFrame,GWL_USERDATA); ! pos = getMenuPos(pFrameData->pMenuHandlesMap, handle); ! hParent = getParentHMENU(handle); ! ! memset(&mii,0,sizeof(mii)); ! mii.cbSize = sizeof(mii); ! mii.fMask = MIIM_STRING; ! mii.fType = MFT_STRING; ! mii.dwTypeData = NULL; ! mii.cch = 0; GetMenuItemInfo(hParent, pos, TRUE, &mii); ! mii.cch++; ! mii.dwTypeData = malloc(mii.cch); ! ! if (mii.dwTypeData) ! { ! GetMenuItemInfo(hParent, pos, TRUE, &mii); ! ! s = mii.dwTypeData; ! while (*s && *s != '\t') s++; ! *s = 0; ! } ! ! return mii.dwTypeData; } ! else ! return NULL; } void osSetMenuLabel(MenuHandle handle, char *title) { ! if (handle->type != MENU_POPUP) { ! char *s, *temp; ! MENUITEMINFO mii; ! FrameData *pFrameData; ! ! CHECK_MENU_TYPE_V(handle, MENU_SUBMENU | MENU_RADIO_ITEM | MENU_CHECK_ITEM | MENU_ITEM); ! ! pFrameData = (FrameData *) GetWindowLong(ghWndFrame,GWL_USERDATA); ! ! if (handle->parent == NULL) temp = title; else { ! temp = malloc(strlen(title)+32); ! if (!temp) ! temp = title; ! else { ! s = temp; ! while (*title) ! { ! if (*title != '\t') *s++ = *title; ! title++; ! } ! *s = 0; ! AddAccelString(handle->key, handle->mods, temp); } } ! memset(&mii,0,sizeof(mii)); ! mii.cbSize = sizeof(mii); ! mii.fMask = MIIM_STRING; ! mii.fType = MFT_STRING; ! mii.dwTypeData = temp; ! mii.cch = strlen(temp); ! SetMenuItemInfo(getParentHMENU(handle), getMenuPos(pFrameData->pMenuHandlesMap, handle), TRUE, &mii); ! updateMenuBar(handle->parent); ! if (temp != title) free(temp); ! } } Index: MenuHandlesMap.c =================================================================== RCS file: /cvsroot/htoolkit/port/src/cbits/Win32/MenuHandlesMap.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** MenuHandlesMap.c 15 Aug 2003 21:24:54 -0000 1.2 --- MenuHandlesMap.c 17 Aug 2003 16:45:07 -0000 1.3 *************** *** 14,17 **** --- 14,18 ---- pMap->children = NULL; + pMap->popups = NULL; pMap->pFreeList = NULL; pMap->pBlocks = NULL; *************** *** 84,97 **** handle->hMenu = NULL; handle->nextInGroup = handle; ! if (parent) { ! child = parent->children; ! prev = &parent->children; } else { ! child = pMap->children; ! prev = &pMap->children; } --- 85,107 ---- handle->hMenu = NULL; handle->nextInGroup = handle; + handle->sibling = NULL; ! if (type != MENU_POPUP) { ! if (parent) ! { ! child = parent->children; ! prev = &parent->children; ! } ! else ! { ! child = pMap->children; ! prev = &pMap->children; ! } } else { ! child = pMap->popups; ! prev = &pMap->popups; } *************** *** 99,103 **** while (child) { ! prev = &child->sibling; child = child->sibling; } --- 109,113 ---- while (child) { ! prev = &child->sibling; child = child->sibling; } *************** *** 111,115 **** handle->sibling = child; *prev = handle; - // put into hash table --- 121,124 ---- *************** *** 129,143 **** deleteMenuHandle(pMap, handle->children); ! if (handle->parent) { ! prev = &handle->parent->children; ! child = handle->parent->children; } else { ! prev = &pMap->children; ! child = pMap->children; } ! while (child) { --- 138,160 ---- deleteMenuHandle(pMap, handle->children); ! if (handle->type != MENU_POPUP) { ! if (handle->parent) ! { ! prev = &handle->parent->children; ! child = handle->parent->children; ! } ! else ! { ! prev = &pMap->children; ! child = pMap->children; ! } } else { ! prev = &pMap->popups; ! child = pMap->popups; } ! while (child) { *************** *** 298,303 **** MenuHandle h; pos = 0; - h = handle->parent ? handle->parent->children : pMap->children; while (h && h != handle) { --- 315,324 ---- MenuHandle h; + if (handle->type != MENU_POPUP) + h = handle->parent ? handle->parent->children : pMap->children; + else + h = pMap->popups; + pos = 0; while (h && h != handle) { *************** *** 311,318 **** HMENU getParentHMENU(MenuHandle handle) { ! if (handle->parent == NULL) ! return GetMenu(ghWndFrame); else ! return handle->parent->hMenu; } --- 332,342 ---- HMENU getParentHMENU(MenuHandle handle) { ! if (handle->type != MENU_POPUP) ! if (handle->parent == NULL) ! return GetMenu(ghWndFrame); ! else ! return handle->parent->hMenu; else ! return NULL; } *************** *** 369,372 **** child = child->sibling; } } - --- 393,402 ---- child = child->sibling; } + + child = pMap->popups; + while (child) + { + notifyHandleForDestroy(child); + child = child->sibling; + } } Index: MenuHandlesMap.h =================================================================== RCS file: /cvsroot/htoolkit/port/src/cbits/Win32/MenuHandlesMap.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** MenuHandlesMap.h 15 Aug 2003 21:24:54 -0000 1.3 --- MenuHandlesMap.h 17 Aug 2003 16:45:07 -0000 1.4 *************** *** 8,16 **** enum MENU_TYPE ! { MENU_SEPARATOR = 1 ! , MENU_ITEM = 2 ! , MENU_POPUP = 4 ! , MENU_CHECK_ITEM = 8 ! , MENU_RADIO_ITEM = 16 }; --- 8,17 ---- enum MENU_TYPE ! { MENU_POPUP = 1 ! , MENU_SUBMENU = 2 ! , MENU_SEPARATOR = 4 ! , MENU_ITEM = 8 ! , MENU_CHECK_ITEM = 16 ! , MENU_RADIO_ITEM = 32 }; *************** *** 40,43 **** --- 41,45 ---- { struct MenuHandle *children; + struct MenuHandle *popups; Block* pBlocks; |
From: <kr_...@us...> - 2003-08-17 16:44:00
|
Update of /cvsroot/htoolkit/port/src/cbits/Win32 In directory sc8-pr-cvs1:/tmp/cvs-serv24769/src/cbits/Win32 Modified Files: Window.c Log Message: Translate screen coordinates to local coordinates in the WM_CONTEXTMENU handler Index: Window.c =================================================================== RCS file: /cvsroot/htoolkit/port/src/cbits/Win32/Window.c,v retrieving revision 1.37 retrieving revision 1.38 diff -C2 -d -r1.37 -r1.38 *** Window.c 15 Aug 2003 21:24:54 -0000 1.37 --- Window.c 17 Aug 2003 16:43:57 -0000 1.38 *************** *** 485,492 **** if (pData->enabled) { ! POINT pos; ! pos.x = pData->Origin.x+GET_X_LPARAM(lParam); ! pos.y = pData->Origin.y+GET_Y_LPARAM(lParam); handleWindowContextMenu(hWnd,pos.x,pos.y,GetModifiers()); --- 485,498 ---- if (pData->enabled) { ! POINT pos; ! pos.x = GET_X_LPARAM(lParam); ! pos.y = GET_Y_LPARAM(lParam); ! ! if (pos.x != 1 || pos.y != 1) ! ScreenToClient(hWnd, &pos); ! ! pos.x += pData->Origin.x; ! pos.y += pData->Origin.y; handleWindowContextMenu(hWnd,pos.x,pos.y,GetModifiers()); |
From: <kr_...@us...> - 2003-08-16 20:48:57
|
Update of /cvsroot/htoolkit/port/src/cbits/Win32 In directory sc8-pr-cvs1:/tmp/cvs-serv24938/src/cbits/Win32 Modified Files: DockBar.c ToolBar.c Log Message: Generate Command event when the checked attribute is changed Index: DockBar.c =================================================================== RCS file: /cvsroot/htoolkit/port/src/cbits/Win32/DockBar.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** DockBar.c 16 Aug 2003 09:59:41 -0000 1.2 --- DockBar.c 16 Aug 2003 20:48:54 -0000 1.3 *************** *** 110,114 **** } ! extern void osAlterToolRadioGroup(ToolHandle toolButton); LRESULT CALLBACK HDockBarFunction(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) --- 110,114 ---- } ! extern void osActivateToolItem(ToolHandle toolButton); LRESULT CALLBACK HDockBarFunction(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) *************** *** 171,176 **** handle = (ToolHandle) tbbi.lParam; ! osAlterToolRadioGroup(handle); ! handleToolCommand(handle); } break; --- 171,175 ---- handle = (ToolHandle) tbbi.lParam; ! osActivateToolItem(handle); } break; Index: ToolBar.c =================================================================== RCS file: /cvsroot/htoolkit/port/src/cbits/Win32/ToolBar.c,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** ToolBar.c 16 Aug 2003 09:59:41 -0000 1.13 --- ToolBar.c 16 Aug 2003 20:48:54 -0000 1.14 *************** *** 920,927 **** } ! void osAlterToolRadioGroup(ToolHandle toolButton) { if (toolButton->bRadio) osSetToolButtonChecked(toolButton, TRUE); } --- 920,929 ---- } ! void osActivateToolItem(ToolHandle toolButton) { if (toolButton->bRadio) osSetToolButtonChecked(toolButton, TRUE); + else + handleToolCommand(toolButton); } *************** *** 1096,1099 **** --- 1098,1103 ---- SendMessage(toolButton->hToolBar,TB_SETSTATE,toolButton->nCommand,MAKELONG(nState, 0)); } + + handleToolCommand(toolButton); }; |
From: <kr_...@us...> - 2003-08-16 16:01:40
|
Update of /cvsroot/htoolkit/port/src/cbits/GTK In directory sc8-pr-cvs1:/tmp/cvs-serv17739/src/cbits/GTK Modified Files: ToolBar.c Log Message: ToolRadioButton for GNOME Index: ToolBar.c =================================================================== RCS file: /cvsroot/htoolkit/port/src/cbits/GTK/ToolBar.c,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** ToolBar.c 16 Aug 2003 07:59:42 -0000 1.4 --- ToolBar.c 16 Aug 2003 16:01:36 -0000 1.5 *************** *** 76,79 **** --- 76,117 ---- } + static void tool_radio_button_clicked(GtkWidget *widget, gpointer user_data) + { + ToolHandle toolItem = (ToolHandle) user_data; + + if (gtk_toggle_tool_button_get_active(GTK_TOGGLE_TOOL_BUTTON(toolItem))) + handleToolCommand(toolItem); + } + + ToolHandle osInsertToolRadioButton(WindowHandle toolbar, int pos) + { + GtkToolItem *item = gtk_radio_tool_button_new(NULL); + + gtk_signal_connect (GTK_OBJECT(GTK_TOOL_BUTTON(item)->button), "clicked", + GTK_SIGNAL_FUNC(tool_radio_button_clicked), + item); + gtk_signal_connect (GTK_OBJECT(item), "destroy", + GTK_SIGNAL_FUNC(handleToolDestroy), + NULL); + gtk_tool_button_set_label_widget(GTK_TOOL_BUTTON(item), gtk_label_new("")); + gtk_tool_button_set_icon_widget(GTK_TOOL_BUTTON(item), gtk_image_new()); + + gtk_toolbar_insert(GTK_TOOLBAR(toolbar), item, pos); + gtk_widget_show_all(GTK_WIDGET(item)); + return GTK_WIDGET(item); + } + + void osSetToolRadioGroup(ToolHandle *handles) + { + ToolHandle *phandle; + GSList *group = NULL; + + for (phandle = handles; *phandle; phandle++) + { + gtk_radio_tool_button_set_group(GTK_RADIO_TOOL_BUTTON(*phandle), group); + group = gtk_radio_tool_button_get_group(GTK_RADIO_TOOL_BUTTON(*phandle)); + } + } + ToolHandle osInsertToolLine(WindowHandle toolbar, int pos) { |
From: <kr_...@us...> - 2003-08-16 10:32:52
|
Update of /cvsroot/htoolkit/gio/src/Graphics/UI/GIO In directory sc8-pr-cvs1:/tmp/cvs-serv3981/gio/src/Graphics/UI/GIO Modified Files: ToolBar.hs Log Message: Added support for ToolRadioButton Index: ToolBar.hs =================================================================== RCS file: /cvsroot/htoolkit/gio/src/Graphics/UI/GIO/ToolBar.hs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ToolBar.hs 8 Jul 2003 20:36:26 -0000 1.1 --- ToolBar.hs 16 Aug 2003 09:59:41 -0000 1.2 *************** *** 17,20 **** --- 17,21 ---- , ToolButton, toolButtonAt, toolButton , ToolCheckButton, toolCheckButtonAt, toolCheckButton + , ToolRadioButton, toolRadioButtonAt, toolRadioButton, setToolRadioGroup , ToolLine, toolLineAt, toolLine , DockPlace(..) *************** *** 125,128 **** --- 126,174 ---- destroyWidget t = Lib.destroyToolItem (hcheck t) destroy = newEvent (Lib.getToolDestroyHandler . hcheck) (Lib.setToolDestroyHandler . hcheck) (Lib.setToolDestroyDefHandler . hcheck) + + -------------------------------------------------------------------- + -- ToolRadioButton + -------------------------------------------------------------------- + + data ToolRadioButton = ToolRadioButton {hradio :: ToolHandle} + + toolRadioButtonAt :: Maybe Int -> [Prop ToolRadioButton] -> ToolBar -> IO ToolRadioButton + toolRadioButtonAt pos props (ToolBar hwnd) = do + btn <- do hbtn <- Lib.insertToolRadioButton hwnd pos + return (ToolRadioButton hbtn) + set btn props + return btn + + toolRadioButton :: [Prop ToolRadioButton] -> ToolBar -> IO ToolRadioButton + toolRadioButton = toolRadioButtonAt Nothing + + instance Able ToolRadioButton where + enabled = newAttr (Lib.getToolButtonEnabled . hradio) (Lib.setToolButtonEnabled . hradio) + + instance Commanding ToolRadioButton where + command = + newEvent (Lib.getToolCommandHandler . hradio) (Lib.setToolCommandHandler . hradio) (Lib.setToolCommandDefHandler . hradio) + + instance HasIcon ToolRadioButton where + icon = newAttr (Lib.getToolButtonBitmap . hradio) (Lib.setToolButtonBitmap . hradio) + + instance Positioned ToolRadioButton where + pos = readAttr "pos" (Lib.getToolItemPos . hradio) + + instance ToolTip ToolRadioButton where + tooltip = newAttr (Lib.getToolButtonTip . hradio) (Lib.setToolButtonTip . hradio) + + instance Titled ToolRadioButton where + title = newAttr (Lib.getToolButtonText . hradio) (Lib.setToolButtonText . hradio) + + instance Checked ToolRadioButton where + checked = newAttr (Lib.getToolButtonChecked . hradio) (Lib.setToolButtonChecked . hradio) + + instance Deadly ToolRadioButton where + destroyWidget t = Lib.destroyToolItem (hradio t) + destroy = newEvent (Lib.getToolDestroyHandler . hradio) (Lib.setToolDestroyHandler . hradio) (Lib.setToolDestroyDefHandler . hradio) + + setToolRadioGroup :: [ToolRadioButton] -> IO () + setToolRadioGroup btns = Lib.setToolRadioGroup (map hradio btns) -------------------------------------------------------------------- |
From: <kr_...@us...> - 2003-08-16 10:32:47
|
Update of /cvsroot/htoolkit/port/src/Port In directory sc8-pr-cvs1:/tmp/cvs-serv3981/port/src/Port Modified Files: ToolBar.hs Log Message: Added support for ToolRadioButton Index: ToolBar.hs =================================================================== RCS file: /cvsroot/htoolkit/port/src/Port/ToolBar.hs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ToolBar.hs 8 Jul 2003 21:44:49 -0000 1.2 --- ToolBar.hs 16 Aug 2003 09:59:41 -0000 1.3 *************** *** 21,30 **** , insertToolButton , insertToolCheckButton , insertToolLine , setToolButtonBitmap, getToolButtonBitmap , setToolButtonEnabled, getToolButtonEnabled ! , setToolButtonTip, getToolButtonTip ! , setToolButtonText, getToolButtonText ! , setToolButtonChecked,getToolButtonChecked , getToolItemPos , destroyToolItem --- 21,32 ---- , insertToolButton , insertToolCheckButton + , insertToolRadioButton , insertToolLine + , setToolRadioGroup , setToolButtonBitmap, getToolButtonBitmap , setToolButtonEnabled, getToolButtonEnabled ! , setToolButtonTip, getToolButtonTip ! , setToolButtonText, getToolButtonText ! , setToolButtonChecked, getToolButtonChecked , getToolItemPos , destroyToolItem *************** *** 32,38 **** import Graphics.UI.Port.Types ! import Graphics.UI.Port.Handlers import Graphics.UI.Port.PtrMap as PtrMap ! import Foreign.Ptr import Foreign.C import Control.Concurrent.MVar --- 34,40 ---- import Graphics.UI.Port.Types ! import Graphics.UI.Port.Handlers import Graphics.UI.Port.PtrMap as PtrMap ! import Foreign import Foreign.C import Control.Concurrent.MVar *************** *** 62,65 **** --- 64,75 ---- insertToolCheckButton toolBar pos = osInsertToolCheckButton toolBar (fromMaybe (-1) pos) foreign import ccall osInsertToolCheckButton :: WindowHandle -> Int -> IO ToolHandle + + insertToolRadioButton :: WindowHandle -> Maybe Int -> IO ToolHandle + insertToolRadioButton toolBar pos = osInsertToolRadioButton toolBar (fromMaybe (-1) pos) + foreign import ccall osInsertToolRadioButton :: WindowHandle -> Int -> IO ToolHandle + + setToolRadioGroup :: [ToolHandle] -> IO () + setToolRadioGroup handles = withArray0 nullHandle handles osSetToolRadioGroup + foreign import ccall osSetToolRadioGroup :: Ptr ToolHandle -> IO () insertToolLine :: WindowHandle -> Maybe Int -> IO ToolHandle |
From: <kr_...@us...> - 2003-08-16 10:32:46
|
Update of /cvsroot/htoolkit/port/src/include In directory sc8-pr-cvs1:/tmp/cvs-serv3981/port/src/include Modified Files: ToolBar.h Log Message: Added support for ToolRadioButton Index: ToolBar.h =================================================================== RCS file: /cvsroot/htoolkit/port/src/include/ToolBar.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** ToolBar.h 10 Aug 2003 18:36:04 -0000 1.4 --- ToolBar.h 16 Aug 2003 09:59:41 -0000 1.5 *************** *** 11,15 **** --- 11,17 ---- ToolHandle osInsertToolButton(WindowHandle toolbar, int pos); ToolHandle osInsertToolCheckButton(WindowHandle toolbar, int pos); + ToolHandle osInsertToolRadioButton(WindowHandle toolBar, int pos); ToolHandle osInsertToolLine(WindowHandle toolbar, int pos); + void osSetToolRadioGroup(ToolHandle *handles); void osSetToolButtonBitmap(ToolHandle toolButton, BitmapHandle bitmap); void osSetToolButtonEnabled(ToolHandle toolButton, BOOL bEnabled); |
From: <kr_...@us...> - 2003-08-16 10:32:46
|
Update of /cvsroot/htoolkit/port/src/cbits/Win32 In directory sc8-pr-cvs1:/tmp/cvs-serv3981/port/src/cbits/Win32 Modified Files: DockBar.c ToolBar.c Log Message: Added support for ToolRadioButton Index: DockBar.c =================================================================== RCS file: /cvsroot/htoolkit/port/src/cbits/Win32/DockBar.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** DockBar.c 15 Aug 2003 16:40:01 -0000 1.1 --- DockBar.c 16 Aug 2003 09:59:41 -0000 1.2 *************** *** 109,113 **** SetWindowPos(pData->hClientWnd,NULL,nLeft,nTop,nWidth-(nRight+nLeft),nHeight-(nBottom+nTop),SWP_NOZORDER); } ! LRESULT CALLBACK HDockBarFunction(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { --- 109,115 ---- SetWindowPos(pData->hClientWnd,NULL,nLeft,nTop,nWidth-(nRight+nLeft),nHeight-(nBottom+nTop),SWP_NOZORDER); } ! ! extern void osAlterToolRadioGroup(ToolHandle toolButton); ! LRESULT CALLBACK HDockBarFunction(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { *************** *** 159,162 **** --- 161,165 ---- case WM_COMMAND: { + ToolHandle handle; TBBUTTONINFO tbbi; HWND hToolBar = (HWND) lParam; *************** *** 166,170 **** tbbi.lParam = 0; SendMessage(hToolBar, TB_GETBUTTONINFO, LOWORD(wParam), (LPARAM) &tbbi); ! handleToolCommand((WindowHandle) tbbi.lParam); } break; --- 169,176 ---- tbbi.lParam = 0; SendMessage(hToolBar, TB_GETBUTTONINFO, LOWORD(wParam), (LPARAM) &tbbi); ! ! handle = (ToolHandle) tbbi.lParam; ! osAlterToolRadioGroup(handle); ! handleToolCommand(handle); } break; Index: ToolBar.c =================================================================== RCS file: /cvsroot/htoolkit/port/src/cbits/Win32/ToolBar.c,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** ToolBar.c 15 Aug 2003 16:40:01 -0000 1.12 --- ToolBar.c 16 Aug 2003 09:59:41 -0000 1.13 *************** *** 25,28 **** --- 25,30 ---- HWND hToolBar; BitmapHandle bitmap; + BOOL bRadio; + ToolHandle nextInGroup; }; *************** *** 811,817 **** if (!btn) return NULL; ! btn->nCommand = ++nNextToolButtonID; ! btn->hToolBar = toolBar; ! btn->bitmap = NULL; tbb.iBitmap = I_IMAGENONE; --- 813,821 ---- if (!btn) return NULL; ! btn->nCommand = ++nNextToolButtonID; ! btn->hToolBar = toolBar; ! btn->bitmap = NULL; ! btn->bRadio = FALSE; ! btn->nextInGroup = btn; tbb.iBitmap = I_IMAGENONE; *************** *** 839,845 **** if (!btn) return NULL; ! btn->nCommand = ++nNextToolButtonID; ! btn->hToolBar = toolBar; ! btn->bitmap = NULL; tbb.iBitmap = I_IMAGENONE; --- 843,851 ---- if (!btn) return NULL; ! btn->nCommand = ++nNextToolButtonID; ! btn->hToolBar = toolBar; ! btn->bitmap = NULL; ! btn->bRadio = FALSE; ! btn->nextInGroup = btn; tbb.iBitmap = I_IMAGENONE; *************** *** 859,862 **** --- 865,929 ---- } + ToolHandle osInsertToolRadioButton(WindowHandle toolBar, int pos) + { + TBBUTTON tbb; + ToolHandle btn; + + btn = malloc(sizeof(struct ToolHandle)); + if (!btn) return NULL; + + btn->nCommand = ++nNextToolButtonID; + btn->hToolBar = toolBar; + btn->bitmap = NULL; + btn->bRadio = TRUE; + btn->nextInGroup = btn; + + tbb.iBitmap = I_IMAGENONE; + tbb.idCommand = btn->nCommand; + tbb.fsState = TBSTATE_ENABLED; + tbb.fsStyle = TBSTYLE_BUTTON; + tbb.dwData = (DWORD)btn; + tbb.iString = 0; + + if (pos > 0) + SendMessage(toolBar,TB_INSERTBUTTON,pos,(LPARAM)&tbb); + else + SendMessage(toolBar,TB_ADDBUTTONS, 1, (LPARAM)&tbb); + + RelayoutFrameBars(); + return btn; + } + + void osSetToolRadioGroup(ToolHandle *handles) + { + ToolHandle next, handle, *phandle; + + phandle=handles; + for (;;) + { + handle = *phandle; + + next = handle->nextInGroup; + while (next->nextInGroup != handle) + next = next->nextInGroup; + next->nextInGroup = handle->nextInGroup; + + phandle++; + if (*phandle) + handle->nextInGroup = *phandle; + else + { + handle->nextInGroup = *handles; + break; + } + } + } + + void osAlterToolRadioGroup(ToolHandle toolButton) + { + if (toolButton->bRadio) + osSetToolButtonChecked(toolButton, TRUE); + } + ToolHandle osInsertToolLine(WindowHandle toolBar, int pos) { *************** *** 868,874 **** if (!btn) return NULL; ! btn->nCommand = ++nNextToolButtonID; ! btn->hToolBar = toolBar; ! btn->bitmap = NULL; tbb.iBitmap = 1; --- 935,942 ---- if (!btn) return NULL; ! btn->nCommand = ++nNextToolButtonID; ! btn->hToolBar = toolBar; ! btn->bitmap = NULL; ! btn->nextInGroup = btn; tbb.iBitmap = 1; *************** *** 1007,1015 **** if (bState) ! nState = nState | TBSTATE_CHECKED; else nState = nState & ~TBSTATE_CHECKED; ! ! SendMessage(toolButton->hToolBar,TB_SETSTATE,toolButton->nCommand,MAKELONG(nState, 0)); }; --- 1075,1099 ---- if (bState) ! { ! ToolHandle next; ! ! nState = nState | TBSTATE_CHECKED; ! SendMessage(toolButton->hToolBar,TB_SETSTATE,toolButton->nCommand,MAKELONG(nState, 0)); ! ! next = toolButton->nextInGroup; ! while (next != toolButton) ! { ! nState = SendMessage(next->hToolBar, TB_GETSTATE, next->nCommand, 0); ! nState = nState & ~TBSTATE_CHECKED; ! SendMessage(next->hToolBar,TB_SETSTATE,next->nCommand,MAKELONG(nState, 0)); ! ! next = next->nextInGroup; ! } ! } else + { nState = nState & ~TBSTATE_CHECKED; ! SendMessage(toolButton->hToolBar,TB_SETSTATE,toolButton->nCommand,MAKELONG(nState, 0)); ! } }; *************** *** 1026,1032 **** --- 1110,1123 ---- void osDestroyToolItem(ToolHandle toolItem) { + ToolHandle next; + handleToolDestroy(toolItem); SendMessage(toolItem->hToolBar, TB_DELETEBUTTON, osGetToolItemPos(toolItem), 0); + + next = toolItem->nextInGroup; + while (next->nextInGroup != toolItem) + next = next->nextInGroup; + next->nextInGroup = toolItem->nextInGroup; free(toolItem); |
From: <kr_...@us...> - 2003-08-16 10:01:04
|
Update of /cvsroot/htoolkit/port In directory sc8-pr-cvs1:/tmp/cvs-serv3392/port Modified Files: makefile Log Message: Better support for "make clean" Index: makefile =================================================================== RCS file: /cvsroot/htoolkit/port/makefile,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** makefile 15 Aug 2003 18:44:11 -0000 1.29 --- makefile 16 Aug 2003 09:54:28 -0000 1.30 *************** *** 213,217 **** #-------------------------------------------------------------------------- ! # EXTRA RULES: clean doc #-------------------------------------------------------------------------- .PHONY: clean --- 213,217 ---- #-------------------------------------------------------------------------- ! # EXTRA RULES: clean & doc #-------------------------------------------------------------------------- .PHONY: clean *************** *** 224,230 **** $(RM) $(HOUTDIR)/Port/*.* $(RM) $(COUTDIR)/*.* - $(RMDIR) $(HOUTDIR)/Port - $(RMDIR) $(HOUTDIR) - $(RMDIR) $(COUTDIR) # documentation --- 224,227 ---- |