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-04-26 20:23:18
|
Update of /cvsroot/htoolkit/gio/src/examples/simple In directory sc8-pr-cvs1:/tmp/cvs-serv23833 Added Files: SimpleDialog.hs Log Message: Add dialogs sample --- NEW FILE: SimpleDialog.hs --- module Main where import Graphics.UI.GIO import Control.Monad(when) main = start SDI [title =: "Simple dialogs"] $ do fm <- menu [title =: "&Open"] mainMenu menuitem [title =: "Modal Dialog", on command =: showDialog True Nothing] fm menuitem [title =: "Modeless Dialog", on command =: showDialog False Nothing] fm where showDialog b parent = do d <- dialog [title =: "Dialog", frame =: Rect 100 100 500 500] parent b1 <- button [text =: "Open Modal Dialog", on command =: showDialog True (Just d)] d b2 <- button [text =: "Open Modeless Dialog", on command =: showDialog False (Just d)] d set d [layout =: pad 10 (center (b1 <<< b2))] when b (runDialog d) |
From: <kr_...@us...> - 2003-04-26 20:19:35
|
Update of /cvsroot/htoolkit/port/src/Port In directory sc8-pr-cvs1:/tmp/cvs-serv22472 Added Files: CommonDialogs.hs Removed Files: ColorDialog.hs FileDialog.hs FontDialog.hs Log Message: Replace ColorDialog.hs FileDialog.hs and FontDialog.hs with single CommonDialogs.hs module --- NEW FILE: CommonDialogs.hs --- {-# OPTIONS -fglasgow-exts -#include FileDialog.h -#include ColorDialog.h -#include FontDialog.h #-} ----------------------------------------------------------------------------------------- {-| Module : CommonDialogs Copyright : (c) Krasimir Angelov 2003 License : BSD-style Maintainer : ka2...@ya... Stability : provisional Portability : portable Standard file selection dialogs. -} ----------------------------------------------------------------------------------------- module Graphics.UI.Port.CommonDialogs ( runDirectoryDialog , runInputFileDialog , runInputFilesDialog , runOutputFileDialog , runColorDialog , runFontDialog ) where import Foreign import Foreign.C import Graphics.UI.Port.Types ----------------------------------------------------------------------------------------- -- File Dialogs ----------------------------------------------------------------------------------------- -- | Run a dialog to select an input file. Returns 'Nothing' when cancelled. runInputFileDialog :: String -> [(String,[String])] -> IO (Maybe FilePath) runInputFileDialog title filter = withCString title $ \ctitle -> withCFilter filter $ \cfilter -> do cin <- osSelectInputFile ctitle cfilter maybeCString cin foreign import ccall osSelectInputFile :: CString -> Ptr CChar -> IO CString -- | Run a dialog to select multiple input files. Returns empty list when canceled. runInputFilesDialog :: String -> [(String,[String])] -> IO [FilePath] runInputFilesDialog title filter = withCString title $ \ctitle -> withCFilter filter $ \cfilter -> do cin <- osSelectInputFiles ctitle cfilter peekCStrings cin foreign import ccall osSelectInputFiles :: CString -> Ptr CChar -> IO (Ptr CChar) -- | Run a dialog to select an output file. Takes both a dialog title and a -- suggested filename as arguments. Returns 'Nothing' when cancelled. runOutputFileDialog :: String -> [(String,[String])] -> FilePath -> IO (Maybe FilePath) runOutputFileDialog title filter fname = withCString title $ \ctitle -> withCString fname $ \cname -> withCFilter filter $ \cfilter -> do cout <- osSelectOutputFile ctitle cfilter cname maybeCString cout foreign import ccall osSelectOutputFile :: CString -> Ptr CChar -> CString -> IO CString -- | Runs a dialog to select a directory. Returns 'Nothing' when cancelled. runDirectoryDialog :: String -> IO (Maybe FilePath) runDirectoryDialog title = do cdir <- withCString title osSelectDirectory maybeCString cdir foreign import ccall osSelectDirectory :: CString -> IO CString maybeCString :: CString -> IO (Maybe String) maybeCString cstr | cstr == nullPtr = return Nothing | otherwise = do str <- peekCString cstr; free cstr; return (Just str) withCFilter :: [(String,[String])] -> (Ptr CChar -> IO a) -> IO a withCFilter filter io = let filterSize [] = 2 filterSize ((name,exts):rs) = (length name+1)+(foldr (\x n -> length x+1+n) 0 exts)+filterSize rs pokeFilter [] cfilter = do pokeElemOff cfilter 0 (castCharToCChar '\0') pokeElemOff cfilter 1 (castCharToCChar '\0') pokeFilter ((name,exts):rs) cfilter = do pokeArray0 (castCharToCChar '\0') cfilter (map castCharToCChar name) cfilter <- pokeExts name exts (cfilter `plusPtr` (length name+1)) pokeFilter rs cfilter pokeExts name [] cfilter = error ("Filter \"" ++ name ++ "\" has empty list of file extensions") pokeExts name [ext] cfilter = do pokeArray0 (castCharToCChar '\0') cfilter (map castCharToCChar ext) return (cfilter `plusPtr` (length ext+1)) pokeExts name (ext:exts) cfilter = do pokeArray0 (castCharToCChar ';') cfilter (map castCharToCChar ext) pokeExts name exts (cfilter `plusPtr` (length ext+1)) in allocaArray (filterSize filter) $ \cfilter -> do pokeFilter filter cfilter io cfilter ----------------------------------------------------------------------------------------- -- Color selection dialog ----------------------------------------------------------------------------------------- -- | Run a dialog to select a color. Returns 'Nothing' when cancelled. runColorDialog :: IO (Maybe Color) runColorDialog = alloca $ \cref -> do res <- osRunColorDialog cref if res then do c <- peek cref return (Just (fromCColor c)) else return Nothing foreign import ccall osRunColorDialog :: Ptr CColor -> IO Bool ----------------------------------------------------------------------------------------- -- Font selection dialog ----------------------------------------------------------------------------------------- -- | Run a dialog to select a font. Returns 'Nothing' when cancelled. runFontDialog :: IO (Maybe FontDef) runFontDialog = alloca $ \fnameref -> alloca $ \fsizeref -> alloca $ \fweightref -> alloca $ \fstyleref -> alloca $ \funderlineref -> alloca $ \fstrikeoutref -> do print 1 res <- osRunFontDialog fnameref fsizeref fweightref fstyleref funderlineref fstrikeoutref print 2 if res then do cname <- peek fnameref csize <- peek fsizeref cweight <- peek fweightref cstyle <- peek fstyleref cunderline <- peek funderlineref cstrikeout <- peek fstrikeoutref fontdef <- fromCFontDef cname csize cweight cstyle cunderline cstrikeout free cname return (Just fontdef) else return Nothing foreign import ccall osRunFontDialog :: Ptr CString -> Ptr CInt -> Ptr CInt -> Ptr CInt -> Ptr CBool -> Ptr CBool -> IO Bool --- ColorDialog.hs DELETED --- --- FileDialog.hs DELETED --- --- FontDialog.hs DELETED --- |
From: <kr_...@us...> - 2003-04-26 20:03:40
|
Update of /cvsroot/htoolkit/port/src/Port In directory sc8-pr-cvs1:/tmp/cvs-serv15534/port/src/Port Modified Files: Window.hs Log Message: Complete implementation for modal and modeless dialogs Index: Window.hs =================================================================== RCS file: /cvsroot/htoolkit/port/src/Port/Window.hs,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** Window.hs 31 Mar 2003 00:12:06 -0000 1.8 --- Window.hs 26 Apr 2003 20:03:06 -0000 1.9 *************** *** 17,21 **** createWindow, createDialog -- * Operations ! , showWindow, runWindow , dismissWindow, dismissAllWindows , destroyWindow, destroyAllWindows --- 17,21 ---- createWindow, createDialog -- * Operations ! , showWindow, runDialog , dismissWindow, dismissAllWindows , destroyWindow, destroyAllWindows *************** *** 76,80 **** foreign import ccall osInvalidateWindowRect :: WindowHandle -> CInt -> CInt -> CInt -> CInt -> IO () ! -- | Create a new (invisible) window. createWindow :: IO WindowHandle createWindow = do --- 76,81 ---- foreign import ccall osInvalidateWindowRect :: WindowHandle -> CInt -> CInt -> CInt -> CInt -> IO () ! -- | Create a new (invisible) window. If the function succeeds, the return value is a handle to the new window. ! -- If the function fails, the return value is nullHandle. createWindow :: IO WindowHandle createWindow = do *************** *** 92,96 **** -- | Create a new (invisible) dialog window. ! createDialog :: WindowHandle -> IO WindowHandle createDialog hparent = do hwnd <- osCreateDialog hparent --- 93,101 ---- -- | Create a new (invisible) dialog window. ! createDialog :: WindowHandle -- ^ Handle to the owner window of the dialog being created. ! -- If this parameter is nullHandle or is a handle of a window instead of dialog ! -- then the dialog owner is the process window. ! -> IO WindowHandle -- ^ If the function succeeds, the return value is a handle to the new dialog. ! -- If the function fails, the return value is nullHandle. createDialog hparent = do hwnd <- osCreateDialog hparent *************** *** 137,142 **** foreign import ccall "osShowWindow" showWindow :: WindowHandle -> IO () ! -- | Run a modal dialog (or window). ! foreign import ccall "osRunWindow" runWindow :: WindowHandle -> IO () -- | Dismiss a window. --- 142,147 ---- foreign import ccall "osShowWindow" showWindow :: WindowHandle -> IO () ! -- | Run a modal dialog. ! foreign import ccall "osRunDialog" runDialog :: WindowHandle -> IO () -- | Dismiss a window. |
From: <kr_...@us...> - 2003-04-26 20:03:39
|
Update of /cvsroot/htoolkit/gio/src/Graphics/UI/GIO In directory sc8-pr-cvs1:/tmp/cvs-serv15534/gio/src/Graphics/UI/GIO Modified Files: Window.hs Log Message: Complete implementation for modal and modeless dialogs Index: Window.hs =================================================================== RCS file: /cvsroot/htoolkit/gio/src/Graphics/UI/GIO/Window.hs,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** Window.hs 14 Apr 2003 17:57:33 -0000 1.12 --- Window.hs 26 Apr 2003 20:03:05 -0000 1.13 *************** *** 13,17 **** module Graphics.UI.GIO.Window ( Window, window, domain, resizeable, view, layout, autosize ! , dialog, modalDialog -- * Internal , windowHandle --- 13,17 ---- module Graphics.UI.GIO.Window ( Window, window, domain, resizeable, view, layout, autosize ! , dialog, runDialog -- * Internal , windowHandle *************** *** 30,36 **** --------------------------------------------------------------------} -- | A main window widget. ! data Window = Window{ hwindow :: WindowHandle ! , hparent :: WindowHandle ! , vdomain :: Var Size , vresizeable :: Var Bool , vautosize :: Var Bool --- 30,35 ---- --------------------------------------------------------------------} -- | A main window widget. ! data Window = Window{ hwindow :: WindowHandle ! , vdomain :: Var Size , vresizeable :: Var Bool , vautosize :: Var Bool *************** *** 38,43 **** , vbgcolor :: Var Color , vhatch :: Var HatchStyle ! , vpaint :: Var PaintFunction ! , vlayout :: Var Layout } --- 37,42 ---- , vbgcolor :: Var Color , vhatch :: Var HatchStyle ! , vpaint :: Var PaintFunction ! , vlayout :: Var Layout } *************** *** 45,50 **** window :: [Prop Window] -> IO Window window props ! = do hwnd <- Lib.createWindow ! w <- form hwnd nullHandle props set w [bgcolor =: white] set w props --- 44,48 ---- window :: [Prop Window] -> IO Window window props ! = do w <- Lib.createWindow >>= form set w [bgcolor =: white] set w props *************** *** 52,77 **** return w ! ! dialog :: [Prop Window] -> Window -> IO Window ! dialog props parent ! = do hwnd <- Lib.createDialog (hwindow parent) ! w <- form hwnd (hwindow parent) props set w props Lib.showWindow (hwindow w) return w ! modalDialog :: [Prop Window] -> Window -> (Window -> IO ()) -> IO () ! modalDialog props parent f ! = do hwnd <- Lib.createDialog (hwindow parent) ! w <- form hwnd (hwindow parent) props ! set w props ! f w ! Lib.runWindow (hwindow w) ! -- ugly technique to bring the parent in focus again ! f <- Lib.getWindowFrame (hwindow parent) ! Lib.setWindowFrame (hwindow parent) f ! form :: WindowHandle -> WindowHandle -> [Prop Window] -> IO Window ! form hwindow hparent props = do w <- do vpaint <- newVar (\_ _ _ -> return ()) vautosize <- newVar True --- 50,74 ---- return w ! -- | Create a modeless dialog box. If you want to make the dialog modal use 'runDialog' function. ! dialog :: [Prop Window] ! -> Maybe Window -- ^ The owner window of the dialog being created. ! -- If this parameter is Nothing or is a @Just handle@ of a window instead of dialog ! -- then the dialog owner is the process window. A dialog is always above its owner ! -- in the z-order and the system automatically destroys a dialog when its owner is ! -- destroyed. The dialog is automatically hidded when its owner is minimized. ! -> IO Window ! dialog props mb_parent ! = do let hparent = maybe Lib.nullHandle hwindow mb_parent ! w <- Lib.createDialog hparent >>= form set w props Lib.showWindow (hwindow w) return w ! -- | Blocks in a recursive main loop until the dialog is destroyed. ! runDialog :: Window -> IO () ! runDialog w = Lib.runDialog (hwindow w) ! form :: WindowHandle -> IO Window ! form hwindow = do w <- do vpaint <- newVar (\_ _ _ -> return ()) vautosize <- newVar True *************** *** 82,86 **** vbgcolor <- newVar dialoggray vhatch <- newVar HatchSolid ! return (Window hwindow hparent vdomain vresizeable vautosize vcolor vbgcolor vhatch vpaint vlayout --- 79,83 ---- vbgcolor <- newVar dialoggray vhatch <- newVar HatchSolid ! return (Window hwindow vdomain vresizeable vautosize vcolor vbgcolor vhatch vpaint vlayout |
From: <kr_...@us...> - 2003-04-26 20:03:12
|
Update of /cvsroot/htoolkit/port/src/include In directory sc8-pr-cvs1:/tmp/cvs-serv15534/port/src/include Modified Files: Window.h Log Message: Complete implementation for modal and modeless dialogs Index: Window.h =================================================================== RCS file: /cvsroot/htoolkit/port/src/include/Window.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Window.h 26 Mar 2003 19:20:22 -0000 1.5 --- Window.h 26 Apr 2003 20:03:08 -0000 1.6 *************** *** 74,78 **** void osSetWindowViewSize(WindowHandle window, int w, int h); void osShowWindow(WindowHandle window); ! void osRunWindow(WindowHandle window); void osSetWindowDomainSize(WindowHandle window, int cx, int cy); void osScrollWindowTo(WindowHandle window, int x, int y); --- 74,78 ---- void osSetWindowViewSize(WindowHandle window, int w, int h); void osShowWindow(WindowHandle window); ! void osRunDialog(WindowHandle window); void osSetWindowDomainSize(WindowHandle window, int cx, int cy); void osScrollWindowTo(WindowHandle window, int x, int y); |
From: <kr_...@us...> - 2003-04-26 20:03:11
|
Update of /cvsroot/htoolkit/port/src/cbits/Win32 In directory sc8-pr-cvs1:/tmp/cvs-serv15534/port/src/cbits/Win32 Modified Files: Window.c Log Message: Complete implementation for modal and modeless dialogs Index: Window.c =================================================================== RCS file: /cvsroot/htoolkit/port/src/cbits/Win32/Window.c,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** Window.c 23 Apr 2003 21:48:54 -0000 1.25 --- Window.c 26 Apr 2003 20:03:08 -0000 1.26 *************** *** 117,152 **** } ! static HWND checkMousePosition(HWND hWnd, POINT *pos) { ! RECT rect; ! POINT upLeft; ! POINT downRight; ! HWND hCtrl = GetTopWindow(hWnd); ! ! while (hCtrl) ! { ! if (IsWindowEnabled(hCtrl)) ! { ! GetWindowRect(hCtrl,&rect); ! upLeft.x = rect.left; ! upLeft.y = rect.top; ! ScreenToClient(hWnd,&upLeft); ! downRight.x = rect.right; ! downRight.y = rect.bottom; ! ScreenToClient(hWnd,&downRight); ! if (pos->x >= upLeft.x && ! pos->x <= downRight.x && ! pos->y >= upLeft.y && ! pos->y <= downRight.y) ! { ! return hCtrl; ! } ! } ! ! hCtrl = GetNextWindow(hCtrl,GW_HWNDNEXT); ! } ! return NULL; } --- 117,135 ---- } ! static HWND checkMousePosition(HWND hWnd, POINT pos) { ! HWND hCtrl; ! ! hCtrl = ChildWindowFromPointEx(hWnd, pos, CWP_SKIPINVISIBLE | CWP_SKIPDISABLED | CWP_SKIPTRANSPARENT); ! if (hCtrl == hWnd) hCtrl = NULL; ! if (hCtrl == NULL) ! { ! ClientToScreen(hWnd, &pos); ! hCtrl = WindowFromPoint(pos); ! if (hCtrl == hWnd) hCtrl = NULL; ! } ! return hCtrl; } *************** *** 537,541 **** pos.y = pData->Origin.y+GET_Y_LPARAM(lParam); ! hCtrl = checkMousePosition(hWnd, &pos); if (hCtrl) { --- 520,524 ---- pos.y = pData->Origin.y+GET_Y_LPARAM(lParam); ! hCtrl = checkMousePosition(hWnd, pos); if (hCtrl) { *************** *** 562,566 **** pos.y = pData->Origin.y+GET_Y_LPARAM(lParam); ! hCtrl = checkMousePosition(hWnd, &pos); if (hCtrl) { --- 545,549 ---- pos.y = pData->Origin.y+GET_Y_LPARAM(lParam); ! hCtrl = checkMousePosition(hWnd, pos); if (hCtrl) { *************** *** 605,609 **** ReleaseCapture(); ! hCtrl = checkMousePosition(hWnd, &pos); if (hCtrl) { --- 588,592 ---- ReleaseCapture(); ! hCtrl = checkMousePosition(hWnd, pos); if (hCtrl) { *************** *** 624,628 **** pos.y = pData->Origin.y+GET_Y_LPARAM(lParam); ! hCtrl = checkMousePosition(hWnd, &pos); if (hCtrl) { --- 607,611 ---- pos.y = pData->Origin.y+GET_Y_LPARAM(lParam); ! hCtrl = checkMousePosition(hWnd, pos); if (hCtrl) { *************** *** 647,651 **** pos.y = pData->Origin.y+GET_Y_LPARAM(lParam); ! hCtrl = checkMousePosition(hWnd, &pos); if (hCtrl) { --- 630,634 ---- pos.y = pData->Origin.y+GET_Y_LPARAM(lParam); ! hCtrl = checkMousePosition(hWnd, pos); if (hCtrl) { *************** *** 806,809 **** --- 789,799 ---- switch (uMsg) { + case WM_CLOSE: + { + HWND hOwner = GetWindow(hWnd, GW_OWNER); + EnableWindow(hOwner, TRUE); + SetActiveWindow(hOwner); + } + break; case WM_LBUTTONDOWN: SetActiveWindow(hWnd); *************** *** 811,815 **** } ! return HWindowSharedFunction(DefDlgProc, hWnd, uMsg, wParam, lParam ); } --- 801,805 ---- } ! return HWindowSharedFunction(DefDlgProc, hWnd, uMsg, wParam, lParam); } *************** *** 904,911 **** WORD dlgtemplate[60]; DWORD lStyle; - HWND hDlg; // start to fill in the dlgtemplate information. Addressing by WORDs ! lStyle = WS_CAPTION | DS_SETFONT | WS_SYSMENU | WS_OVERLAPPEDWINDOW; p = dlgtemplate; --- 894,900 ---- WORD dlgtemplate[60]; DWORD lStyle; // start to fill in the dlgtemplate information. Addressing by WORDs ! lStyle = WS_CAPTION | DS_SETFONT | WS_SYSMENU | WS_OVERLAPPEDWINDOW | WS_HSCROLL | WS_VSCROLL; p = dlgtemplate; *************** *** 926,932 **** s = "MS Sans Serif"; do { *p++ = (WORD) *s; } while (*s++); ! hDlg = CreateDialogIndirectParam (ghModule, (LPCDLGTEMPLATE) dlgtemplate, parent, (DLGPROC) NULL, (LPARAM) 0); ! ! return hDlg; }; --- 915,921 ---- s = "MS Sans Serif"; do { *p++ = (WORD) *s; } while (*s++); ! if (!parent) parent = ghWndFrame; ! ! return CreateDialogIndirectParam (ghModule, (LPCDLGTEMPLATE) dlgtemplate, parent, (DLGPROC) NULL, (LPARAM) 0); }; *************** *** 974,982 **** void osSetWindowViewSize(WindowHandle window, int w, int h) { HWND hTargetWnd; RECT crect, wrect; - FrameData *pFrameData = (FrameData *) GetWindowLong(ghWndFrame,GWL_USERDATA); ! hTargetWnd = (pFrameData->DocumentInterface == 1) ? ghWndFrame : window; GetClientRect(hTargetWnd,&crect); --- 963,972 ---- void osSetWindowViewSize(WindowHandle window, int w, int h) { + char buffer[20]; HWND hTargetWnd; RECT crect, wrect; ! GetClassName(window,buffer,sizeof(buffer)); ! hTargetWnd = (_stricmp(buffer, "HSDIWINDOW") == 0) ? ghWndFrame : window; GetClientRect(hTargetWnd,&crect); *************** *** 1072,1088 **** } ! void osRunWindow(WindowHandle window) { MSG msg; ! WindowHandle parent = GetWindow(window,GW_OWNER); ! ! EnableWindow(parent,FALSE); ! ShowWindow(window, SW_SHOW); while (IsWindow(window) && GetMessage(&msg, NULL, 0, 0) != 0) { ! TranslateMessage(&msg); ! DispatchMessage(&msg); }; - EnableWindow(parent,TRUE); } --- 1062,1077 ---- } ! void osRunDialog(WindowHandle window) { MSG msg; ! ! SetActiveWindow(window); ! EnableWindow(GetWindow(window, GW_OWNER), FALSE); ! while (IsWindow(window) && GetMessage(&msg, NULL, 0, 0) != 0) { ! TranslateMessage(&msg); ! DispatchMessage(&msg); }; } *************** *** 1383,1388 **** void osSetWindowRect(WindowHandle window, int x0, int y0, int x1, int y1) { ! FrameData *pFrameData = (FrameData *) GetWindowLong(ghWndFrame,GWL_USERDATA); ! SetWindowPos((pFrameData->DocumentInterface == 1) ? ghWndFrame : window,NULL,x0,y0,abs(x1-x0),abs(y1-y0),SWP_NOZORDER); } --- 1372,1382 ---- void osSetWindowRect(WindowHandle window, int x0, int y0, int x1, int y1) { ! char buffer[20]; ! HWND hTargetWnd; ! ! GetClassName(window,buffer,sizeof(buffer)); ! hTargetWnd = (_stricmp(buffer, "HSDIWINDOW") == 0) ? ghWndFrame : window; ! ! SetWindowPos(hTargetWnd,NULL,x0,y0,abs(x1-x0),abs(y1-y0),SWP_NOZORDER); } |
From: <kr_...@us...> - 2003-04-26 20:03:11
|
Update of /cvsroot/htoolkit/port/src/cbits/GTK In directory sc8-pr-cvs1:/tmp/cvs-serv15534/port/src/cbits/GTK Modified Files: Window.c Log Message: Complete implementation for modal and modeless dialogs Index: Window.c =================================================================== RCS file: /cvsroot/htoolkit/port/src/cbits/GTK/Window.c,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** Window.c 2 Apr 2003 20:00:24 -0000 1.14 --- Window.c 26 Apr 2003 20:03:06 -0000 1.15 *************** *** 237,247 **** }; ! WindowHandle osCreateWindow() { GtkWidget *fixed, *sw, *viewport; ! ! if (gDocumentInterface == 1 && gClientWidget != NULL) ! return NULL; ! /* Create a Scrolled Window */ sw = gtk_scrolled_window_new (NULL, NULL); --- 237,244 ---- }; ! static WindowHandle create_generic_window() { GtkWidget *fixed, *sw, *viewport; ! /* Create a Scrolled Window */ sw = gtk_scrolled_window_new (NULL, NULL); *************** *** 256,261 **** NULL); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), ! GTK_POLICY_AUTOMATIC, ! GTK_POLICY_AUTOMATIC); gtk_widget_show(sw); --- 253,258 ---- NULL); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), ! GTK_POLICY_AUTOMATIC, ! GTK_POLICY_AUTOMATIC); gtk_widget_show(sw); *************** *** 293,296 **** --- 290,306 ---- GTK_SIGNAL_FUNC(frame_adjustment_value_changed_handler), sw); + + return sw; + } + + WindowHandle osCreateWindow() + { + GtkWidget *sw, *viewport; + + if (gDocumentInterface == 1 && gClientWidget != NULL) + return NULL; + + sw = create_generic_window(); + viewport = GTK_BIN(sw)->child; if (gDocumentInterface == 2) *************** *** 301,309 **** gtk_box_pack_end(GTK_BOX(GTK_BIN(gFrameWidget)->child), sw, TRUE, TRUE, 0); } ! gtk_widget_realize(viewport); gdk_window_set_events(viewport->window, gdk_window_get_events(viewport->window) | GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK | GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK); return sw; } --- 311,320 ---- gtk_box_pack_end(GTK_BOX(GTK_BIN(gFrameWidget)->child), sw, TRUE, TRUE, 0); } ! gtk_widget_realize(viewport); gdk_window_set_events(viewport->window, gdk_window_get_events(viewport->window) | GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK | GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK); + return sw; } *************** *** 312,316 **** WindowHandle osCreateDialog(WindowHandle parent) { ! return NULL; } --- 323,346 ---- WindowHandle osCreateDialog(WindowHandle parent) { ! GtkWidget *sw, *viewport, *frame; ! ! if (parent == NULL) ! parent = gFrameWidget; ! else ! parent = gtk_widget_get_toplevel(parent); ! ! frame = gtk_window_new (GTK_WINDOW_TOPLEVEL); ! gtk_window_set_transient_for(frame, gtk_widget_get_toplevel(parent)); ! gtk_window_set_destroy_with_parent(frame, gtk_true()); ! ! sw = create_generic_window(); ! viewport = GTK_BIN(sw)->child; ! ! gtk_container_add(GTK_CONTAINER(frame), sw); ! ! gtk_widget_realize(viewport); ! gdk_window_set_events(viewport->window, ! gdk_window_get_events(viewport->window) | GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK | GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK); ! return sw; } *************** *** 360,389 **** char *osGetWindowTitle(WindowHandle window) { ! if (gDocumentInterface == 2) { ! GtkWidget *label; ! label = gtk_notebook_get_tab_label(GTK_NOTEBOOK(gClientWidget),window); ! gWindowName = gtk_label_get_text(GTK_LABEL(label)); } - - return strdup(gWindowName); }; void osSetWindowTitle(WindowHandle window, char *title) { ! if (gDocumentInterface == 2) { ! GtkWidget *label; ! label = gtk_notebook_get_tab_label(GTK_NOTEBOOK(gClientWidget),window); ! gtk_label_set_text(GTK_LABEL(label), title); ! gtk_notebook_set_menu_label_text(GTK_NOTEBOOK(gClientWidget),window,title); } else { ! gWindowName = strdup(title); ! updateFrameTitle(); } }; --- 390,438 ---- char *osGetWindowTitle(WindowHandle window) { ! GtkWidget *toplevel = gtk_widget_get_toplevel(window); ! ! if (toplevel == gFrameWidget) { ! if (gDocumentInterface == 2) ! { ! GtkWidget *label; ! label = gtk_notebook_get_tab_label(GTK_NOTEBOOK(gClientWidget),window); ! gWindowName = gtk_label_get_text(GTK_LABEL(label)); ! } ! ! ! return strdup(gWindowName); ! } ! else ! { ! return strdup(gtk_window_get_title(GTK_WINDOW(toplevel))); } }; void osSetWindowTitle(WindowHandle window, char *title) { ! GtkWidget *toplevel = gtk_widget_get_toplevel(window); ! ! if (toplevel == gFrameWidget) { ! if (gDocumentInterface == 2) ! { ! GtkWidget *label; ! label = gtk_notebook_get_tab_label(GTK_NOTEBOOK(gClientWidget),window); ! gtk_label_set_text(GTK_LABEL(label), title); ! gtk_notebook_set_menu_label_text(GTK_NOTEBOOK(gClientWidget),window,title); ! } ! else ! { ! gWindowName = strdup(title); ! updateFrameTitle(); ! } } else { ! gtk_window_set_title(GTK_WINDOW(toplevel), title); } }; *************** *** 391,398 **** void osGetWindowViewSize(WindowHandle window, int *res) { ! if (gDocumentInterface == 1) { ! res[0] = gFrameWidget->allocation.width-4; ! res[1] = gFrameWidget->allocation.height-4; } else --- 440,449 ---- void osGetWindowViewSize(WindowHandle window, int *res) { ! GtkWidget *toplevel = gtk_widget_get_toplevel(window); ! ! if (toplevel != gFrameWidget || gDocumentInterface == 1) { ! res[0] = toplevel->allocation.width-4; ! res[1] = toplevel->allocation.height-4; } else *************** *** 405,410 **** void osSetWindowViewSize(WindowHandle window, int w, int h) { ! if (gDocumentInterface == 1) ! gtk_window_resize(GTK_WINDOW(gFrameWidget), w+4, h+4); } --- 456,462 ---- void osSetWindowViewSize(WindowHandle window, int w, int h) { ! GtkWidget *toplevel = gtk_widget_get_toplevel(window); ! if (toplevel != gFrameWidget || gDocumentInterface == 1) ! gtk_window_resize(GTK_WINDOW(toplevel), w+4, h+4); } *************** *** 453,461 **** void osShowWindow(WindowHandle window) { gtk_widget_show(window); }; ! void osRunWindow(WindowHandle window) { } --- 505,522 ---- void osShowWindow(WindowHandle window) { + GtkWidget *toplevel = gtk_widget_get_toplevel(window); gtk_widget_show(window); + gtk_widget_show(toplevel); }; ! void osRunDialog(WindowHandle window) { + GtkWidget *toplevel = gtk_widget_get_toplevel(window); + gtk_window_set_modal(GTK_WINDOW(toplevel), TRUE); + gtk_signal_connect (GTK_OBJECT(toplevel), "delete-event", + GTK_SIGNAL_FUNC(gtk_main_quit), + NULL); + + gtk_main(); } *************** *** 464,471 **** --- 525,534 ---- GtkWidget *widget = window; + printf("1 %p\n", window); gtk_signal_connect (GTK_OBJECT(window), "destroy", GTK_SIGNAL_FUNC(gtk_widget_destroyed), &widget); handleWindowDismiss(widget); + printf("2\n"); return (widget == NULL); } *************** *** 476,487 **** } ! void osSetWindowEnabled(WindowHandle ctrl, BOOL enabled) { ! gtk_widget_set_sensitive(ctrl,enabled); } ! BOOL osGetWindowEnabled(WindowHandle ctrl) { ! return GTK_WIDGET_SENSITIVE(ctrl); } --- 539,550 ---- } ! void osSetWindowEnabled(WindowHandle window, BOOL enabled) { ! gtk_widget_set_sensitive(window,enabled); } ! BOOL osGetWindowEnabled(WindowHandle window) { ! return GTK_WIDGET_SENSITIVE(window); } *************** *** 589,596 **** void osSetWindowRect(WindowHandle window, int x0, int y0, int x1, int y1) { ! if (gDocumentInterface != 2) { ! gtk_window_move(GTK_WINDOW(gFrameWidget), x0, y0); ! gtk_window_resize(GTK_WINDOW(gFrameWidget), abs(x1 - x0), abs(y1 - y0)); } } --- 652,661 ---- void osSetWindowRect(WindowHandle window, int x0, int y0, int x1, int y1) { ! GtkWidget *toplevel = gtk_widget_get_toplevel(window); ! ! if (toplevel != gFrameWidget || gDocumentInterface == 1) { ! gtk_window_move(GTK_WINDOW(toplevel), x0, y0); ! gtk_window_resize(GTK_WINDOW(toplevel), abs(x1 - x0), abs(y1 - y0)); } } *************** *** 598,602 **** void osGetWindowRect(WindowHandle window, int *res) { ! if (gDocumentInterface == 2) { res[0] = 0; --- 663,669 ---- void osGetWindowRect(WindowHandle window, int *res) { ! GtkWidget *toplevel = gtk_widget_get_toplevel(window); ! ! if (toplevel == gFrameWidget && gDocumentInterface == 2) { res[0] = 0; *************** *** 612,617 **** int h = 0; ! gtk_window_get_position(GTK_WINDOW(gFrameWidget), &x, &y); ! gtk_window_get_size(GTK_WINDOW(gFrameWidget), &w, &h); res[0] = x; --- 679,684 ---- int h = 0; ! gtk_window_get_position(GTK_WINDOW(toplevel), &x, &y); ! gtk_window_get_size(GTK_WINDOW(toplevel), &w, &h); res[0] = x; *************** *** 622,630 **** } ! void osSetWindowResizeable(WindowHandle window, int resizeable ) { ! if (gDocumentInterface != 2 || GTK_IS_DIALOG(window)) { ! gtk_window_set_resizable(GTK_WINDOW(gtk_widget_get_toplevel(window)), resizeable != 0); } } --- 689,699 ---- } ! void osSetWindowResizeable(WindowHandle window, int resizeable) { ! GtkWidget *toplevel = gtk_widget_get_toplevel(window); ! ! if (toplevel != gFrameWidget || gDocumentInterface == 1) { ! gtk_window_set_resizable(GTK_WINDOW(toplevel), resizeable != 0); } } |
From: <kr_...@us...> - 2003-04-26 20:01:37
|
Update of /cvsroot/htoolkit/port/src/cbits/Win32 In directory sc8-pr-cvs1:/tmp/cvs-serv15274/port/src/cbits/Win32 Modified Files: Menu.c Log Message: bugfixes Index: Menu.c =================================================================== RCS file: /cvsroot/htoolkit/port/src/cbits/Win32/Menu.c,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Menu.c 23 Apr 2003 21:48:53 -0000 1.6 --- Menu.c 26 Apr 2003 20:01:33 -0000 1.7 *************** *** 403,431 **** pFrameData = (FrameData *) GetWindowLong(ghWndFrame,GWL_USERDATA); - temp = malloc(strlen(title)+32); ! if (temp) { ! 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); } ! ! free(temp); } --- 403,438 ---- 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); } *************** *** 446,460 **** updateAccelTable(pFrameData->pMenuHandlesMap, handle, key, mods); ! 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.dwTypeData = malloc(mii.cch+32); ! ! if (mii.dwTypeData) { mii.cch++; GetMenuItemInfo(hParent, pos, TRUE, &mii); --- 453,470 ---- updateAccelTable(pFrameData->pMenuHandlesMap, handle, key, mods); ! if (handle->parent != NULL) { + 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.dwTypeData = malloc(mii.cch+32); + + if (!mii.dwTypeData) + return; + mii.cch++; GetMenuItemInfo(hParent, pos, TRUE, &mii); *************** *** 463,476 **** while (*s && *s != '\t') s++; *s = 0; ! AddAccelString(key, mods, s); mii.cch = strlen(mii.dwTypeData); SetMenuItemInfo(hParent, pos, TRUE, &mii); ! updateMenuBar(handle->parent); } - - free(mii.dwTypeData); } --- 473,486 ---- while (*s && *s != '\t') s++; *s = 0; ! AddAccelString(key, mods, s); mii.cch = strlen(mii.dwTypeData); SetMenuItemInfo(hParent, pos, TRUE, &mii); ! updateMenuBar(handle->parent); + + free(mii.dwTypeData); } } |
From: <kr_...@us...> - 2003-04-26 10:01:23
|
Update of /cvsroot/htoolkit/port/src/cbits/Win32 In directory sc8-pr-cvs1:/tmp/cvs-serv4266/port/src/cbits/Win32 Modified Files: FileDialog.c Log Message: The InputFileDialog, OutputFileDialog and SelectDirectory dialogs has extended functionality Index: FileDialog.c =================================================================== RCS file: /cvsroot/htoolkit/port/src/cbits/Win32/FileDialog.c,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** FileDialog.c 29 Mar 2003 08:12:18 -0000 1.3 --- FileDialog.c 26 Apr 2003 10:00:48 -0000 1.4 *************** *** 18,28 **** } ! char *osSelectDirectory() { char buffer[MAX_PATH]; LPITEMIDLIST pidlReturn; BROWSEINFO bi; ! char *s = NULL; ! char title[17] = "Select Directory\0"; bi.hwndOwner = ghWndFrame; --- 18,27 ---- } ! char *osSelectDirectory(char *title) { char buffer[MAX_PATH]; LPITEMIDLIST pidlReturn; BROWSEINFO bi; ! char *s = NULL; bi.hwndOwner = ghWndFrame; *************** *** 48,52 **** } ! char *osSelectInputFile() { OPENFILENAME ofn; --- 47,51 ---- } ! char *osSelectInputFile(char *title, char *filter) { OPENFILENAME ofn; *************** *** 56,60 **** ofn.hwndOwner = ghWndFrame; ofn.hInstance = NULL; ! ofn.lpstrFilter = NULL; ofn.lpstrCustomFilter = NULL; ofn.nMaxCustFilter = 0; --- 55,59 ---- ofn.hwndOwner = ghWndFrame; ofn.hInstance = NULL; ! ofn.lpstrFilter = filter; ofn.lpstrCustomFilter = NULL; ofn.nMaxCustFilter = 0; *************** *** 66,78 **** ofn.nMaxFileTitle = 0; ofn.lpstrInitialDir = NULL; ! ofn.lpstrTitle = NULL; ofn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_PATHMUSTEXIST ! | OFN_ENABLEHOOK; // PA: OFN_ENABLEHOOK added from Ronny ofn.lpstrDefExt = NULL; ofn.lCustData = 0; ! ofn.lpfnHook = &FileSelectorHook; // PA: &FileSelectorHook instead of NULL from Ronny ofn.lpTemplateName = NULL; --- 65,77 ---- ofn.nMaxFileTitle = 0; ofn.lpstrInitialDir = NULL; ! ofn.lpstrTitle = title; ofn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_PATHMUSTEXIST ! | OFN_ENABLEHOOK; ofn.lpstrDefExt = NULL; ofn.lCustData = 0; ! ofn.lpfnHook = &FileSelectorHook; ofn.lpTemplateName = NULL; *************** *** 84,97 **** } ! char *osSelectOutputFile(char *promptptr, char *nameptr) { OPENFILENAME ofn; ! if (strlen(promptptr) == 0) ! promptptr = NULL; ofn.lStructSize = sizeof (OPENFILENAME); ofn.hwndOwner = ghWndFrame; ! ofn.lpstrFilter = NULL; ofn.lpstrCustomFilter = NULL; ofn.nMaxCustFilter = 0; --- 83,172 ---- } ! char *osSelectInputFiles(char *title, char *filter) { + char *buffer; OPENFILENAME ofn; ! buffer = malloc(MAX_PATH*2); ! if (!buffer) ! return NULL; ofn.lStructSize = sizeof (OPENFILENAME); ofn.hwndOwner = ghWndFrame; ! ofn.hInstance = NULL; ! ofn.lpstrFilter = filter; ! ofn.lpstrCustomFilter = NULL; ! ofn.nMaxCustFilter = 0; ! ofn.nFilterIndex = 0; ! ofn.lpstrFile = buffer; ! ofn.lpstrFile[0] = '\0'; ! ofn.nMaxFile = MAX_PATH*2; ! ofn.lpstrFileTitle = NULL; ! ofn.nMaxFileTitle = 0; ! ofn.lpstrInitialDir = NULL; ! ofn.lpstrTitle = title; ! ofn.Flags = OFN_EXPLORER ! | OFN_FILEMUSTEXIST ! | OFN_HIDEREADONLY ! | OFN_PATHMUSTEXIST ! | OFN_ENABLEHOOK ! | OFN_ALLOWMULTISELECT; ! ofn.lpstrDefExt = NULL; ! ofn.lCustData = 0; ! ofn.lpfnHook = &FileSelectorHook; ! ofn.lpTemplateName = NULL; ! ! if (GetOpenFileName(&ofn)) ! { ! int nLen, nSize; ! char *s, *s2, *buffer; ! ! nSize = 1; ! s = ofn.lpstrFile+ofn.nFileOffset; ! while (*s) ! { ! nLen = strlen(s); ! s += nLen+1; ! nSize += ofn.nFileOffset+nLen+1; ! } ! ! buffer = malloc(nSize); ! if (!buffer) ! { ! free(ofn.lpstrFile); ! return NULL; ! } ! ! s2 = buffer; ! s = ofn.lpstrFile+ofn.nFileOffset; ! while (*s) ! { ! memcpy(s2,ofn.lpstrFile,ofn.nFileOffset-1); ! s2[ofn.nFileOffset-1] = '\\'; ! strcpy(s2+ofn.nFileOffset,s); ! nLen = strlen(s); ! s += nLen+1; ! s2 += ofn.nFileOffset+nLen+1; ! } ! *s2 = 0; ! ! free(ofn.lpstrFile); ! return buffer; ! } ! ! free(ofn.lpstrFile); ! return NULL; ! } ! ! char *osSelectOutputFile(char *title, char *filter, char *nameptr) ! { ! OPENFILENAME ofn; ! ! if (strlen(title) == 0) ! title = NULL; ! ! ofn.lStructSize = sizeof (OPENFILENAME); ! ofn.hwndOwner = ghWndFrame; ! ofn.lpstrFilter = filter; ofn.lpstrCustomFilter = NULL; ofn.nMaxCustFilter = 0; *************** *** 106,117 **** ofn.nMaxFileTitle = 0; ofn.lpstrInitialDir = NULL; ! ofn.lpstrTitle = promptptr; ofn.Flags = OFN_EXPLORER | OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY ! | OFN_ENABLEHOOK; // PA: OFN_ENABLEHOOK added from Ronny ofn.lpstrDefExt = NULL; ofn.lCustData = 0; ! ofn.lpfnHook = &FileSelectorHook; // PA: &FileSelectorHook instead of NULL from Ronny ofn.lpTemplateName = NULL; --- 181,192 ---- ofn.nMaxFileTitle = 0; ofn.lpstrInitialDir = NULL; ! ofn.lpstrTitle = title; ofn.Flags = OFN_EXPLORER | OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY ! | OFN_ENABLEHOOK; ofn.lpstrDefExt = NULL; ofn.lCustData = 0; ! ofn.lpfnHook = &FileSelectorHook; ofn.lpTemplateName = NULL; |
From: <kr_...@us...> - 2003-04-26 10:01:23
|
Update of /cvsroot/htoolkit/port/src/include In directory sc8-pr-cvs1:/tmp/cvs-serv4266/port/src/include Modified Files: FileDialog.h Log Message: The InputFileDialog, OutputFileDialog and SelectDirectory dialogs has extended functionality Index: FileDialog.h =================================================================== RCS file: /cvsroot/htoolkit/port/src/include/FileDialog.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** FileDialog.h 21 Jan 2003 22:01:17 -0000 1.1 --- FileDialog.h 26 Apr 2003 10:00:49 -0000 1.2 *************** *** 4,10 **** #include "Types.h" ! char *osSelectDirectory(); ! char *osSelectInputFile(); ! char *osSelectOutputFile(char *promptptr, char *nameptr); #endif --- 4,11 ---- #include "Types.h" ! char *osSelectDirectory(char *title); ! char *osSelectInputFile(char *title, char *filter); ! char *osSelectInputFiles(char *title, char *filter); ! char *osSelectOutputFile(char *title, char *filter, char *nameptr); #endif |
From: <kr_...@us...> - 2003-04-26 10:01:23
|
Update of /cvsroot/htoolkit/port/src/cbits/GTK In directory sc8-pr-cvs1:/tmp/cvs-serv4266/port/src/cbits/GTK Modified Files: FileDialog.c Log Message: The InputFileDialog, OutputFileDialog and SelectDirectory dialogs has extended functionality Index: FileDialog.c =================================================================== RCS file: /cvsroot/htoolkit/port/src/cbits/GTK/FileDialog.c,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** FileDialog.c 2 Apr 2003 19:32:07 -0000 1.4 --- FileDialog.c 26 Apr 2003 10:00:47 -0000 1.5 *************** *** 2,8 **** #include "Internals.h" ! char *osSelectDirectory() { ! GtkWidget *file_selector = gtk_file_selection_new("Select directory"); gtk_window_set_transient_for(GTK_WINDOW(file_selector), GTK_WINDOW(gFrameWidget)); --- 2,8 ---- #include "Internals.h" ! char *osSelectDirectory(char *title) { ! GtkWidget *file_selector = gtk_file_selection_new(title); gtk_window_set_transient_for(GTK_WINDOW(file_selector), GTK_WINDOW(gFrameWidget)); *************** *** 39,45 **** } ! char *osSelectInputFile() { ! GtkWidget *file_selector = gtk_file_selection_new("Open"); gtk_window_set_transient_for(GTK_WINDOW(file_selector), GTK_WINDOW(gFrameWidget)); --- 39,45 ---- } ! char *osSelectInputFile(char *title, char *filter) { ! GtkWidget *file_selector = gtk_file_selection_new(title); gtk_window_set_transient_for(GTK_WINDOW(file_selector), GTK_WINDOW(gFrameWidget)); *************** *** 90,96 **** } ! char *osSelectOutputFile(char *promptptr, char *nameptr) { ! GtkWidget *file_selector = gtk_file_selection_new(promptptr); gtk_window_set_transient_for(GTK_WINDOW(file_selector), GTK_WINDOW(gFrameWidget)); --- 90,173 ---- } ! char *osSelectInputFiles(char *title, char *filter) { ! GtkWidget *file_selector = gtk_file_selection_new(title); ! gtk_window_set_transient_for(GTK_WINDOW(file_selector), GTK_WINDOW(gFrameWidget)); ! gtk_file_selection_set_select_multiple(GTK_FILE_SELECTION(file_selector), gtk_true()); ! ! for (;;) ! { ! if (gtk_dialog_run(GTK_DIALOG(file_selector)) == GTK_RESPONSE_OK) ! { ! int pos_size; ! gchar *buffer; ! gchar **fname, **files = gtk_file_selection_get_selections(GTK_FILE_SELECTION(file_selector)); ! ! pos_size = 1; ! for (fname = files; *fname; fname++) ! { ! if (!g_file_test(*fname, G_FILE_TEST_EXISTS)) ! { ! GtkWidget *dialog = ! gtk_message_dialog_new (GTK_WINDOW(file_selector), ! GTK_DIALOG_DESTROY_WITH_PARENT, ! GTK_MESSAGE_ERROR, ! GTK_BUTTONS_OK, ! "%s file not found", ! *fname); ! gtk_dialog_run (GTK_DIALOG (dialog)); ! gtk_widget_destroy (dialog); ! break; ! } ! ! if (g_file_test(*fname, G_FILE_TEST_IS_DIR)) ! { ! GtkWidget *dialog = ! gtk_message_dialog_new (GTK_WINDOW(file_selector), ! GTK_DIALOG_DESTROY_WITH_PARENT, ! GTK_MESSAGE_ERROR, ! GTK_BUTTONS_OK, ! "Path %s is a directory", ! *fname); ! gtk_dialog_run (GTK_DIALOG (dialog)); ! gtk_widget_destroy (dialog); ! break; ! } ! ! pos_size += strlen(*fname)+1; ! } ! ! if (*fname) ! { ! g_strfreev(files); ! continue; ! } ! ! buffer = malloc(pos_size); ! if (!buffer) ! return NULL; ! ! pos_size = 0; ! for (fname = files; *fname; fname++) ! { ! strcpy(buffer+pos_size,*fname); ! pos_size += strlen(*fname)+1; ! } ! ! gtk_widget_destroy(file_selector); ! g_strfreev(files); ! return buffer; ! } ! else ! { ! gtk_widget_destroy(file_selector); ! return NULL; ! } ! } ! } ! ! char *osSelectOutputFile(char *title, char *filter, char *nameptr) ! { ! GtkWidget *file_selector = gtk_file_selection_new(title); gtk_window_set_transient_for(GTK_WINDOW(file_selector), GTK_WINDOW(gFrameWidget)); |
From: <kr_...@us...> - 2003-04-26 10:01:22
|
Update of /cvsroot/htoolkit/port/src/Port In directory sc8-pr-cvs1:/tmp/cvs-serv4266/port/src/Port Modified Files: FileDialog.hs Log Message: The InputFileDialog, OutputFileDialog and SelectDirectory dialogs has extended functionality Index: FileDialog.hs =================================================================== RCS file: /cvsroot/htoolkit/port/src/Port/FileDialog.hs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** FileDialog.hs 21 Jan 2003 22:01:09 -0000 1.2 --- FileDialog.hs 26 Apr 2003 10:00:46 -0000 1.3 *************** *** 16,25 **** runDirectoryDialog , runInputFileDialog , runOutputFileDialog ) where import Foreign.C - import Foreign.Ptr - import Foreign.Marshal.Alloc import Graphics.UI.Port.Types --- 16,25 ---- runDirectoryDialog , runInputFileDialog + , runInputFilesDialog , runOutputFileDialog ) where + import Foreign import Foreign.C import Graphics.UI.Port.Types *************** *** 28,53 **** -----------------------------------------------------------------------------------------} -- | Run a dialog to select an input file. Returns 'Nothing' when cancelled. ! runInputFileDialog :: IO (Maybe String) ! runInputFileDialog ! = do cin <- osSelectInputFile maybeCString cin ! foreign import ccall osSelectInputFile :: IO CString ! -- | Run a dialog to select an output file. Takes both a prompt message and a -- suggested filename as arguments. Returns 'Nothing' when cancelled. ! runOutputFileDialog :: String -> String -> IO (Maybe String) ! runOutputFileDialog msg fname ! = withCString msg $ \cmsg -> withCString fname $ \cname -> ! do cout <- osSelectOutputFile cmsg cname maybeCString cout ! foreign import ccall osSelectOutputFile :: CString -> CString -> IO CString -- | Runs a dialog to select a directory. Returns 'Nothing' when cancelled. ! runDirectoryDialog :: IO (Maybe String) ! runDirectoryDialog ! = do cdir <- osSelectDirectory maybeCString cdir ! foreign import ccall osSelectDirectory :: IO CString --- 28,65 ---- -----------------------------------------------------------------------------------------} -- | Run a dialog to select an input file. Returns 'Nothing' when cancelled. ! runInputFileDialog :: String -> [(String,[String])] -> IO (Maybe FilePath) ! runInputFileDialog title filter ! = withCString title $ \ctitle -> ! withCFilter filter $ \cfilter -> ! do cin <- osSelectInputFile ctitle cfilter maybeCString cin ! foreign import ccall osSelectInputFile :: CString -> Ptr CChar -> IO CString ! -- | Run a dialog to select multiple input files. Returns empty list when canceled. ! runInputFilesDialog :: String -> [(String,[String])] -> IO [FilePath] ! runInputFilesDialog title filter ! = withCString title $ \ctitle -> ! withCFilter filter $ \cfilter -> ! do cin <- osSelectInputFiles ctitle cfilter ! peekCStrings cin ! foreign import ccall osSelectInputFiles :: CString -> Ptr CChar -> IO (Ptr CChar) ! ! -- | Run a dialog to select an output file. Takes both a dialog title and a -- suggested filename as arguments. Returns 'Nothing' when cancelled. ! runOutputFileDialog :: String -> [(String,[String])] -> FilePath -> IO (Maybe FilePath) ! runOutputFileDialog title filter fname ! = withCString title $ \ctitle -> withCString fname $ \cname -> ! withCFilter filter $ \cfilter -> ! do cout <- osSelectOutputFile ctitle cfilter cname maybeCString cout ! foreign import ccall osSelectOutputFile :: CString -> Ptr CChar -> CString -> IO CString -- | Runs a dialog to select a directory. Returns 'Nothing' when cancelled. ! runDirectoryDialog :: String -> IO (Maybe FilePath) ! runDirectoryDialog title ! = do cdir <- withCString title osSelectDirectory maybeCString cdir ! foreign import ccall osSelectDirectory :: CString -> IO CString *************** *** 55,57 **** maybeCString cstr | cstr == nullPtr = return Nothing ! | otherwise = do str <- peekCString cstr; free cstr; return (Just str) \ No newline at end of file --- 67,94 ---- maybeCString cstr | cstr == nullPtr = return Nothing ! | otherwise = do str <- peekCString cstr; free cstr; return (Just str) ! ! withCFilter :: [(String,[String])] -> (Ptr CChar -> IO a) -> IO a ! withCFilter filter io = ! let filterSize [] = 2 ! filterSize ((name,exts):rs) = (length name+1)+(foldr (\x n -> length x+1+n) 0 exts)+filterSize rs ! ! pokeFilter [] cfilter = do ! pokeElemOff cfilter 0 (castCharToCChar '\0') ! pokeElemOff cfilter 1 (castCharToCChar '\0') ! pokeFilter ((name,exts):rs) cfilter = do ! pokeArray0 (castCharToCChar '\0') cfilter (map castCharToCChar name) ! cfilter <- pokeExts name exts (cfilter `plusPtr` (length name+1)) ! pokeFilter rs cfilter ! ! pokeExts name [] cfilter = error ("Filter \"" ++ name ++ "\" has empty list of file extensions") ! pokeExts name [ext] cfilter = do ! pokeArray0 (castCharToCChar '\0') cfilter (map castCharToCChar ext) ! return (cfilter `plusPtr` (length ext+1)) ! pokeExts name (ext:exts) cfilter = do ! pokeArray0 (castCharToCChar ';') cfilter (map castCharToCChar ext) ! pokeExts name exts (cfilter `plusPtr` (length ext+1)) ! in ! allocaArray (filterSize filter) $ \cfilter -> do ! pokeFilter filter cfilter ! io cfilter |
From: <kr_...@us...> - 2003-04-26 10:00:54
|
Update of /cvsroot/htoolkit/gio/src/examples/simple In directory sc8-pr-cvs1:/tmp/cvs-serv4266/gio/src/examples/simple Modified Files: BitmapViewer.hs Log Message: The InputFileDialog, OutputFileDialog and SelectDirectory dialogs has extended functionality Index: BitmapViewer.hs =================================================================== RCS file: /cvsroot/htoolkit/gio/src/examples/simple/BitmapViewer.hs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** BitmapViewer.hs 25 Apr 2003 06:56:28 -0000 1.4 --- BitmapViewer.hs 26 Apr 2003 10:00:50 -0000 1.5 *************** *** 3,6 **** --- 3,12 ---- import Graphics.UI.GIO + codecsToFilesFilter :: [Codec] -> [(String,[String])] + codecsToFilesFilter = map codeToFileFilter + where + codeToFileFilter :: Codec -> (String,[String]) + codeToFileFilter codec = (codecDescr codec,map (\e->"*."++e) (codecExtensions codec)) + main = start MDI [title =: "Bitmap Viewer"] $ *************** *** 15,33 **** where cmdopen mclose ! = do mbfname <- runInputFileDialog ! case mbfname of ! Nothing -> return () ! Just fname -> do bitmap <- readBitmap fname [] ! bmpSize <- get bitmap size ! w <- window [ title =: fname ! , domain =: bmpSize ! , view =: sz 300 300 ! , on paint =: paintImage bitmap ! ] ! set mclose [enabled =: True, on command =: cmdclose w mclose] ! set w [ on activate =: set mclose [enabled =: True, on command =: cmdclose w mclose] ! , on deactivate =: set mclose [enabled =: False, off command] ! ] ! return () cmdclose w mclose --- 21,27 ---- where cmdopen mclose ! = do codes <- getAvailableCodecs ! fnames <- runInputFilesDialog "Open" (codecsToFilesFilter codes) ! mapM_ (openBitmapWindow mclose) fnames cmdclose w mclose *************** *** 37,39 **** paintImage image can updFrame updAreas ! = do bitmap (pt 0 0) image can \ No newline at end of file --- 31,46 ---- paintImage image can updFrame updAreas ! = do bitmap (pt 0 0) image can ! ! openBitmapWindow mclose fname = do ! bitmap <- readBitmap fname [] ! bmpSize <- get bitmap size ! w <- window [ title =: fname ! , domain =: bmpSize ! , view =: sz 300 300 ! , on paint =: paintImage bitmap ! ] ! set mclose [enabled =: True, on command =: cmdclose w mclose] ! set w [ on activate =: set mclose [enabled =: True, on command =: cmdclose w mclose] ! , on deactivate =: set mclose [enabled =: False, off command] ! ] |
From: <kr_...@us...> - 2003-04-26 10:00:53
|
Update of /cvsroot/htoolkit/gio/src/Graphics/UI/GIO In directory sc8-pr-cvs1:/tmp/cvs-serv4266/gio/src/Graphics/UI/GIO Modified Files: CommonDialogs.hs Log Message: The InputFileDialog, OutputFileDialog and SelectDirectory dialogs has extended functionality Index: CommonDialogs.hs =================================================================== RCS file: /cvsroot/htoolkit/gio/src/Graphics/UI/GIO/CommonDialogs.hs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** CommonDialogs.hs 26 Mar 2003 10:38:33 -0000 1.1 --- CommonDialogs.hs 26 Apr 2003 10:00:49 -0000 1.2 *************** *** 14,17 **** --- 14,18 ---- ( runDirectoryDialog , runInputFileDialog + , runInputFilesDialog , runOutputFileDialog , runFontDialog *************** *** 27,40 **** --------------------------------------------------------------------} -- | Run a dialog to select an input file. Returns 'Nothing' when cancelled. ! runInputFileDialog :: IO (Maybe String) runInputFileDialog = Lib.runInputFileDialog ! -- | Run a dialog to select an output file. Takes both a prompt message and a ! -- suggested filename as arguments. Returns 'Nothing' when cancelled. ! runOutputFileDialog :: String -> String -> IO (Maybe String) runOutputFileDialog = Lib.runOutputFileDialog -- | Runs a dialog to select a directory. Returns 'Nothing' when cancelled. ! runDirectoryDialog :: IO (Maybe String) runDirectoryDialog = Lib.runDirectoryDialog --- 28,61 ---- --------------------------------------------------------------------} -- | Run a dialog to select an input file. Returns 'Nothing' when cancelled. ! runInputFileDialog :: String -- ^ The dialog title ! -> [(String,[String])] -- ^ Filter for acceptable file types. The filter is a ! -- list of pairs where the first element of pair is a ! -- filter name and the second element is a list of ! -- wildcards (example [(\"Haskell script\", [\"*.hs\", \"*.lhs\"])]) ! -> IO (Maybe FilePath) -- ^ The full qualified path to the selected file runInputFileDialog = Lib.runInputFileDialog ! -- | Run a dialog to select an input file. Returns 'Nothing' when cancelled. ! runInputFilesDialog :: String -- ^ The dialog title ! -> [(String,[String])] -- ^ Filter for acceptable file types. The filter is a ! -- list of pairs where the first element of pair is a ! -- filter name and the second element is a list of ! -- wildcards (example [(\"Haskell script\", [\"*.hs\", \"*.lhs\"])]) ! -> IO [FilePath] -- ^ The list of full qualified paths for the selected files ! runInputFilesDialog = Lib.runInputFilesDialog ! ! -- | Run a dialog to select an output file. Returns 'Nothing' when cancelled. ! runOutputFileDialog :: String -- ^ The dialog title ! -> [(String,[String])] -- ^ Filter for acceptable file types. The filter is a ! -- list of pairs where the first element of pair is a ! -- filter name and the second element is a list of ! -- wildcards (example [(\"Haskell script\", [\"*.hs\", \"*.lhs\"])]) ! -> FilePath -- ^ The default file name ! -> IO (Maybe FilePath) -- ^ The full qualified path to the selected file runOutputFileDialog = Lib.runOutputFileDialog -- | Runs a dialog to select a directory. Returns 'Nothing' when cancelled. ! runDirectoryDialog :: String -- ^ The dialog title ! -> IO (Maybe FilePath) -- ^ The full qualified path to the selected directory runDirectoryDialog = Lib.runDirectoryDialog |
From: <kr_...@us...> - 2003-04-25 21:15:38
|
Update of /cvsroot/htoolkit/port/src/cbits/Win32 In directory sc8-pr-cvs1:/tmp/cvs-serv17516/src/cbits/Win32 Modified Files: Frame.c Log Message: bugfix Index: Frame.c =================================================================== RCS file: /cvsroot/htoolkit/port/src/cbits/Win32/Frame.c,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** Frame.c 23 Apr 2003 21:48:53 -0000 1.7 --- Frame.c 25 Apr 2003 21:15:31 -0000 1.8 *************** *** 171,174 **** --- 171,175 ---- GetMenuItemInfo(hParent, pos, TRUE, &mii); + ZeroMemory(&rc,sizeof(rc)); DrawText(hDC,mii.dwTypeData,mii.cch,&rc,DT_SINGLELINE|DT_VCENTER|DT_LEFT|DT_CALCRECT|DT_EXPANDTABS); *************** *** 181,185 **** lpMIS->itemWidth = (rc.right-rc.left) + wCheckWidth + (Spacing*2); // Text width ! lpMIS->itemHeight = max((rc.bottom-rc.top),wCheckHeight) + (Spacing*2); // Text Height } --- 182,186 ---- lpMIS->itemWidth = (rc.right-rc.left) + wCheckWidth + (Spacing*2); // Text width ! lpMIS->itemHeight = max((rc.bottom-rc.top),wCheckHeight) + (Spacing*2); // Text Height } |
From: <kr_...@us...> - 2003-04-25 06:56:31
|
Update of /cvsroot/htoolkit/gio/src/examples/simple In directory sc8-pr-cvs1:/tmp/cvs-serv10597 Modified Files: BitmapViewer.hs SimpleMenu.hs Log Message: update examples Index: BitmapViewer.hs =================================================================== RCS file: /cvsroot/htoolkit/gio/src/examples/simple/BitmapViewer.hs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** BitmapViewer.hs 2 Apr 2003 00:08:45 -0000 1.3 --- BitmapViewer.hs 25 Apr 2003 06:56:28 -0000 1.4 *************** *** 5,13 **** main = start MDI [title =: "Bitmap Viewer"] $ ! do mfile <- menu "&File" [] mainMenu ! mopen <- menuitem "&Open" [] mfile ! mclose <- menuitem "&Close" [enabled =: False] mfile menuline mfile ! mexit <- menuitem "&Exit" [on command =: quit >> return ()] mfile set mopen [on command =: cmdopen mclose] --- 5,13 ---- main = start MDI [title =: "Bitmap Viewer"] $ ! do mfile <- menu [title =: "&File"] mainMenu ! mopen <- menuitem [title =: "&Open"] mfile ! mclose <- menuitem [title =: "&Close", enabled =: False] mfile menuline mfile ! mexit <- menuitem [title =: "&Exit", on command =: quit >> return ()] mfile set mopen [on command =: cmdopen mclose] Index: SimpleMenu.hs =================================================================== RCS file: /cvsroot/htoolkit/gio/src/examples/simple/SimpleMenu.hs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** SimpleMenu.hs 23 Apr 2003 21:48:48 -0000 1.4 --- SimpleMenu.hs 25 Apr 2003 06:56:28 -0000 1.5 *************** *** 7,13 **** do w <- window [title =: "Hello world", view =: sz 200 200] ! bmpNew <- readBitmap "new.bmp" [] ! bmpOpen <- readBitmap "open.bmp" [] ! bmpSave <- readBitmap "save.bmp" [] fm <- menu [title =: "&File"] mainMenu --- 7,13 ---- do w <- window [title =: "Hello world", view =: sz 200 200] ! bmpNew <- readBitmap "res/new.bmp" [] ! bmpOpen <- readBitmap "res/open.bmp" [] ! bmpSave <- readBitmap "res/save.bmp" [] fm <- menu [title =: "&File"] mainMenu |
From: <kr_...@us...> - 2003-04-23 21:58:22
|
Update of /cvsroot/htoolkit/port/src/include In directory sc8-pr-cvs1:/tmp/cvs-serv32229/include Removed Files: Internals.h Log Message: Split Internals.h into two idependent hidden platforms. One for each platform. --- Internals.h DELETED --- |
From: <kr_...@us...> - 2003-04-23 21:58:21
|
Update of /cvsroot/htoolkit/port/src/cbits/Win32 In directory sc8-pr-cvs1:/tmp/cvs-serv32229/cbits/Win32 Added Files: Internals.h Log Message: Split Internals.h into two idependent hidden platforms. One for each platform. --- NEW FILE: Internals.h --- #ifndef ITERNALS_H #define ITERNALS_H #include <config.h> extern BOOL gInKey; extern int gCurChar; #include "MenuHandlesMap.h" #ifndef GET_WHEEL_DELTA_WPARAM #define GET_WHEEL_DELTA_WPARAM(wparam) ((short)HIWORD (wparam)) #endif extern HMODULE ghModule; extern HWND ghWndFrame; extern unsigned int GetModifiers(); extern WindowHandle checkWindow(HWND hWnd, char *className); extern void SetupLogBrush(LOGBRUSH *plb, BOOL bSetSolid, int hatchStyle, BitmapHandle patBmp); typedef struct { HWND hClientWnd; int DocumentInterface; HFONT hControlFont; LPSTR lpszAppName; MenuHandlesMap *pMenuHandlesMap; } FrameData; extern void rfree(void *ptr); extern void *rmalloc(unsigned long bytes); #endif |
From: <kr_...@us...> - 2003-04-23 21:58:15
|
Update of /cvsroot/htoolkit/port/src/cbits/GTK In directory sc8-pr-cvs1:/tmp/cvs-serv32229/cbits/GTK Added Files: Internals.h Log Message: Split Internals.h into two idependent hidden platforms. One for each platform. --- NEW FILE: Internals.h --- #ifndef ITERNALS_H #define ITERNALS_H #include <config.h> extern BOOL gInKey; extern int gCurChar; extern int gDocumentInterface; extern char *gAppName, *gWindowName; extern GtkWidget *gFrameWidget; extern GtkWidget *gClientWidget; extern GtkWidget *gMenuBar; extern gchar *fromMnemonicString(const gchar *source); extern gchar *toMnemonicString(const gchar *source); void createMDIFrame(); void createSDIFrame(); void updateFrameTitle(); extern void rfree(void *ptr); extern void *rmalloc(unsigned long bytes); #endif |
From: <kr_...@us...> - 2003-04-23 21:49:38
|
Update of /cvsroot/htoolkit/port/src/include In directory sc8-pr-cvs1:/tmp/cvs-serv26873/port/src/include Modified Files: Internals.h Menu.h Types.h Log Message: Complete implementation for Menu with both GTK and Win32. Supported: - command menu items with bitmaps - checked menu items - radio menu items - sepparators - sub menus Index: Internals.h =================================================================== RCS file: /cvsroot/htoolkit/port/src/include/Internals.h,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** Internals.h 2 Apr 2003 19:12:11 -0000 1.9 --- Internals.h 23 Apr 2003 21:48:56 -0000 1.10 *************** *** 9,12 **** --- 9,14 ---- #ifdef WIN32_TARGET + #include "MenuHandlesMap.h" + #ifndef GET_WHEEL_DELTA_WPARAM #define GET_WHEEL_DELTA_WPARAM(wparam) ((short)HIWORD (wparam)) *************** *** 28,31 **** --- 30,34 ---- HFONT hControlFont; LPSTR lpszAppName; + MenuHandlesMap *pMenuHandlesMap; } FrameData; Index: Menu.h =================================================================== RCS file: /cvsroot/htoolkit/port/src/include/Menu.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Menu.h 1 Apr 2003 23:54:20 -0000 1.5 --- Menu.h 23 Apr 2003 21:48:57 -0000 1.6 *************** *** 4,21 **** #include "Types.h" ! MenuHandle osAddMenu(MenuHandle parent, char *title); ! MenuHandle osAddMenuItem(MenuHandle parent, int keyCode, unsigned int mods, char *title); ! MenuHandle osAddMenuCheckItem(MenuHandle parent, int keyCode, unsigned int mods, char *title); ! void osAddMenuSeparatorItem(MenuHandle parent); ! void osSetMenuItemEnabled(MenuHandle parent, MenuHandle item, BOOL bState); ! BOOL osGetMenuItemEnabled(MenuHandle parent, MenuHandle item); ! void osSetMenuItemChecked(MenuHandle parent, MenuHandle item, BOOL bState); ! BOOL osGetMenuItemChecked(MenuHandle parent, MenuHandle item); ! void osSetMenuItemLabel(MenuHandle menu, MenuHandle item, int nKeyCode, unsigned int mods, char* title); ! void osDrawMenuBar(WindowHandle window); #endif --- 4,34 ---- #include "Types.h" ! MenuHandle osInsertMenu(MenuHandle parent, int pos); ! MenuHandle osInsertMenuItem(MenuHandle parent, int pos); ! MenuHandle osInsertMenuCheckItem(MenuHandle parent, int pos); ! MenuHandle osInsertMenuSeparatorItem(MenuHandle parent, int pos); ! MenuHandle osInsertMenuRadioGroup(MenuHandle parent, int pos); ! MenuHandle osInsertMenuRadioItem(MenuHandle parent, int pos); ! void osDestroyMenu(MenuHandle handle); ! int osGetMenuItemCount(MenuHandle handle); ! void osSetMenuItemEnabled(MenuHandle item, BOOL bState); ! BOOL osGetMenuItemEnabled(MenuHandle item); ! void osSetMenuItemChecked(MenuHandle item, BOOL bState); ! BOOL osGetMenuItemChecked(MenuHandle item); ! void osSetMenuRadioGroupSelection(MenuHandle handle, int selection); ! int osGetMenuRadioGroupSelection(MenuHandle handle); ! ! void osSetMenuLabel(MenuHandle item, char* title); ! char *osGetMenuLabel(MenuHandle item); ! ! void osSetMenuItemAccel(MenuHandle item, int key, unsigned int mods); ! void osGetMenuItemAccel(MenuHandle item, int *key, unsigned int *mods); ! ! void osSetMenuItemBitmap(MenuHandle handle, BitmapHandle bitmap); + int osGetMenuItemPos(MenuHandle handle); #endif Index: Types.h =================================================================== RCS file: /cvsroot/htoolkit/port/src/include/Types.h,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** Types.h 30 Mar 2003 18:49:08 -0000 1.8 --- Types.h 23 Apr 2003 21:48:57 -0000 1.9 *************** *** 33,37 **** typedef HFONT FontHandle; ! typedef HMENU MenuHandle; typedef struct --- 33,37 ---- typedef HFONT FontHandle; ! typedef struct MenuHandle *MenuHandle; typedef struct *************** *** 41,45 **** } *PolygonHandle; ! typedef struct { HDC hDC; --- 41,45 ---- } *PolygonHandle; ! typedef struct CanvasHandle { HDC hDC; *************** *** 92,95 **** --- 92,96 ---- typedef GtkWidget *MenuHandle; + typedef GtkWidget *MenuItemHandle; typedef struct |
From: <kr_...@us...> - 2003-04-23 21:49:30
|
Update of /cvsroot/htoolkit/port/src/cbits/GTK In directory sc8-pr-cvs1:/tmp/cvs-serv26873/port/src/cbits/GTK Modified Files: Frame.c Menu.c Log Message: Complete implementation for Menu with both GTK and Win32. Supported: - command menu items with bitmaps - checked menu items - radio menu items - sepparators - sub menus Index: Frame.c =================================================================== RCS file: /cvsroot/htoolkit/port/src/cbits/GTK/Frame.c,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Frame.c 2 Apr 2003 19:12:10 -0000 1.5 --- Frame.c 23 Apr 2003 21:48:52 -0000 1.6 *************** *** 94,97 **** --- 94,98 ---- case GDK_F11: return kbF11; case GDK_F12: return kbF12; + case GDK_Clear: return kbClear; } *************** *** 191,195 **** GtkWidget *box; GtkWidget *notebook_menu, *menu_item, *pages_menu; - GtkAccelGroup *accel_group; GSList *group; --- 192,195 ---- *************** *** 231,235 **** /* Create "Pages" menu */ pages_menu = gtk_menu_new(); - // gtk_menu_set_accel_group(GTK_MENU(pages_menu), accel_group); menu_item = gtk_menu_item_new_with_label("Pages"); --- 231,234 ---- *************** *** 240,244 **** notebook_menu = gtk_menu_new(); - //gtk_menu_set_accel_group(GTK_MENU(notebook_menu), accel_group); menu_item = gtk_radio_menu_item_new_with_label(NULL, "Top"); --- 239,242 ---- *************** *** 279,282 **** --- 277,282 ---- gtk_menu_append(GTK_MENU(pages_menu), menu_item); + gtk_window_add_accel_group (GTK_WINDOW (gFrameWidget), gtk_accel_group_new()); + gtk_widget_show_all(pages_menu); } *************** *** 310,313 **** --- 310,315 ---- box = gtk_vbox_new(FALSE, 0); gtk_container_add(GTK_CONTAINER(gFrameWidget), box); + + gtk_window_add_accel_group (GTK_WINDOW (gFrameWidget), gtk_accel_group_new()); gtk_widget_show_all(gFrameWidget); Index: Menu.c =================================================================== RCS file: /cvsroot/htoolkit/port/src/cbits/GTK/Menu.c,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Menu.c 2 Apr 2003 19:12:11 -0000 1.6 --- Menu.c 23 Apr 2003 21:48:52 -0000 1.7 *************** *** 3,7 **** #include "Internals.h" #include "Handlers_stub.h" ! static MenuHandle getMenu(MenuHandle parent) --- 3,7 ---- #include "Internals.h" #include "Handlers_stub.h" ! #include <gdk/gdkkeysyms.h> static MenuHandle getMenu(MenuHandle parent) *************** *** 15,123 **** gtk_widget_show(gMenuBar); } ! parent = gMenuBar; } ! return parent; }; ! MenuHandle osAddMenu(MenuHandle parent, char *title) { ! GtkMenuShell *menu_shell; ! gchar *szText = toMnemonicString(title); ! GtkWidget *menuItem = gtk_menu_item_new_with_mnemonic(szText); GtkWidget *popUpMenu = gtk_menu_new(); gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuItem), popUpMenu); - rfree(szText); ! menu_shell = GTK_MENU_SHELL(getMenu(parent)); ! if (gDocumentInterface == 1) ! gtk_menu_shell_append(menu_shell, menuItem); ! else ! gtk_menu_shell_insert(menu_shell, menuItem, g_list_length(menu_shell->children)-1); ! gtk_widget_show(menuItem); ! return popUpMenu; }; ! MenuHandle osAddMenuItem(MenuHandle parent, int nKeyCode, unsigned int mods, char *title) { ! gchar *szText = toMnemonicString(title); ! GtkWidget *menuItem = gtk_menu_item_new_with_mnemonic(szText); ! rfree(szText); gtk_signal_connect (GTK_OBJECT(menuItem), "activate", GTK_SIGNAL_FUNC(handleMenuCommand), NULL); ! gtk_menu_shell_append(GTK_MENU_SHELL(getMenu(parent)), menuItem); ! gtk_widget_show(menuItem); return menuItem; }; ! static int in_handler_flag = 0; ! ! static void handleCheckMenuCommand(GtkMenuItem *menuitem) { ! if (!in_handler_flag) ! { ! in_handler_flag++; ! gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), !(GTK_CHECK_MENU_ITEM(menuitem)->active)); ! handleMenuCommand(menuitem) ; ! in_handler_flag--; ! } ! } ! MenuHandle osAddMenuCheckItem(MenuHandle parent, int nKeyCode, unsigned int mods, char *title) ! { ! gchar *szText = toMnemonicString(title); ! GtkWidget *menuItem = gtk_check_menu_item_new_with_mnemonic(szText); ! rfree(szText); gtk_signal_connect (GTK_OBJECT(menuItem), "activate", ! GTK_SIGNAL_FUNC(handleCheckMenuCommand), NULL); ! gtk_menu_shell_append(GTK_MENU_SHELL(getMenu(parent)), menuItem); ! gtk_widget_show(menuItem); return menuItem; }; ! void osAddMenuSeparatorItem(MenuHandle parent) { GtkWidget *item = gtk_separator_menu_item_new(); ! gtk_menu_shell_append(GTK_MENU_SHELL(getMenu(parent)), item); gtk_widget_show(item); } ! void osSetMenuItemEnabled(MenuHandle parent, MenuHandle item, BOOL bState) { gtk_widget_set_sensitive(item,bState); }; ! BOOL osGetMenuItemEnabled(MenuHandle parent, MenuHandle item) { return GTK_WIDGET_SENSITIVE(item); }; ! void osSetMenuItemChecked(MenuHandle parent, MenuHandle item, BOOL bState) { - in_handler_flag++; gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM(item), bState); - in_handler_flag--; }; ! BOOL osGetMenuItemChecked(MenuHandle parent, MenuHandle item) { return gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(item)); }; ! void osDrawMenuBar(WindowHandle window) { ! /* TODO: nothing yet */ } ! void osSetMenuItemLabel(MenuHandle menu, MenuHandle item, int nKeyCode, unsigned int mods, char* title ) { ! /* TODO: nothing yet */ } --- 15,643 ---- gtk_widget_show(gMenuBar); } ! parent = gMenuBar; } ! else ! parent = gtk_menu_item_get_submenu(GTK_MENU_ITEM(parent)); ! return parent; }; ! static int recalcPos(GtkWidget *menu, int pos) { ! BOOL b; ! int new_pos; ! GList *children; ! ! children = GTK_MENU_SHELL(menu)->children; ! ! if (pos >= 0) ! { ! b = TRUE; ! new_pos = 0; ! while (children && pos > 0) ! { ! if (GTK_WIDGET_VISIBLE((GtkWidget*) children->data)) ! { ! if (b) pos--; ! } ! else ! { ! b = !b; ! } ! ! new_pos++; ! children = children->next; ! } ! ! if (!children) ! new_pos = (gDocumentInterface == 1 || menu != gMenuBar) ? -1 : new_pos-1; ! } ! else ! { ! new_pos = (gDocumentInterface == 1 || menu != gMenuBar) ? -1 : g_list_length(children)-1; ! } ! ! return new_pos; ! } ! ! static void menu_show(GtkWidget *widget, gpointer user_data) ! { ! GtkWidget *menuItem; ! GList *child = GTK_MENU_SHELL(widget)->children; ! ! while (child) ! { ! menuItem = (GtkWidget *) child->data; ! ! if (GTK_IS_IMAGE_MENU_ITEM(menuItem) || ! GTK_IS_CHECK_MENU_ITEM(menuItem) || ! GTK_IS_RADIO_MENU_ITEM(menuItem)) ! { ! handleMenuUpdate(menuItem); ! } ! ! child = child->next; ! } ! } ! ! MenuHandle osInsertMenu(MenuHandle parent, int pos) ! { ! GtkWidget *menu; ! GtkWidget *menuItem = gtk_menu_item_new_with_mnemonic(""); GtkWidget *popUpMenu = gtk_menu_new(); gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuItem), popUpMenu); ! gtk_signal_connect (GTK_OBJECT(menuItem), "destroy", ! GTK_SIGNAL_FUNC(handleMenuDestroy), ! NULL); ! gtk_signal_connect (GTK_OBJECT(popUpMenu), "show", ! GTK_SIGNAL_FUNC(menu_show), ! NULL); ! menu = getMenu(parent); ! pos = recalcPos(menu, pos); ! ! gtk_menu_shell_insert(GTK_MENU_SHELL(menu), menuItem, pos); ! gtk_widget_show_all(menuItem); ! return menuItem; }; ! MenuHandle osInsertMenuItem(MenuHandle parent, int pos) { ! GtkWidget *menu; ! GtkWidget *label, *menuItem; ! ! menuItem = gtk_image_menu_item_new(); ! label = gtk_accel_label_new(""); ! gtk_container_add(GTK_CONTAINER(menuItem), label); ! gtk_accel_label_set_accel_widget(GTK_ACCEL_LABEL(label), menuItem); gtk_signal_connect (GTK_OBJECT(menuItem), "activate", GTK_SIGNAL_FUNC(handleMenuCommand), NULL); + gtk_signal_connect (GTK_OBJECT(menuItem), "destroy", + GTK_SIGNAL_FUNC(handleMenuDestroy), + NULL); ! menu = getMenu(parent); ! pos = recalcPos(menu, pos); ! ! gtk_menu_shell_insert(GTK_MENU_SHELL(menu), menuItem, pos); ! gtk_widget_show_all(menuItem); return menuItem; }; ! MenuHandle osInsertMenuCheckItem(MenuHandle parent, int pos) { ! GtkWidget *menu; ! GtkWidget *label, *menuItem; ! menuItem = gtk_check_menu_item_new(); ! label = gtk_accel_label_new(""); ! gtk_container_add(GTK_CONTAINER(menuItem), label); ! gtk_accel_label_set_accel_widget(GTK_ACCEL_LABEL(label), menuItem); gtk_signal_connect (GTK_OBJECT(menuItem), "activate", ! GTK_SIGNAL_FUNC(handleMenuCommand), ! NULL); ! gtk_signal_connect (GTK_OBJECT(menuItem), "destroy", ! GTK_SIGNAL_FUNC(handleMenuDestroy), NULL); ! menu = getMenu(parent); ! pos = recalcPos(menu, pos); ! ! gtk_menu_shell_insert(GTK_MENU_SHELL(menu), menuItem, pos); ! gtk_widget_show_all(menuItem); return menuItem; }; ! MenuHandle osInsertMenuSeparatorItem(MenuHandle parent, int pos) { + GtkWidget *menu; GtkWidget *item = gtk_separator_menu_item_new(); ! gtk_signal_connect (GTK_OBJECT(item), "destroy", ! GTK_SIGNAL_FUNC(handleMenuDestroy), ! NULL); ! ! menu = getMenu(parent); ! pos = recalcPos(menu, pos); ! ! gtk_menu_shell_insert(GTK_MENU_SHELL(getMenu(parent)), item, pos); gtk_widget_show(item); + return item; } ! static void handleRadioMenuCommand(GtkMenuItem *menuitem) ! { ! if (gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(menuitem))) ! handleMenuCommand(menuitem) ; ! } ! ! MenuHandle osInsertMenuRadioGroup(MenuHandle parent, int pos) ! { ! GtkWidget *menu; ! GtkWidget *item1, *item2; ! ! menu = getMenu(parent); ! pos = recalcPos(menu, pos); ! ! item1 = gtk_separator_menu_item_new(); ! gtk_menu_shell_insert(GTK_MENU_SHELL(menu), item1, pos); ! ! item2 = gtk_separator_menu_item_new(); ! gtk_menu_shell_insert(GTK_MENU_SHELL(menu), item2, pos); ! ! gtk_signal_connect (GTK_OBJECT(item1), "destroy", ! GTK_SIGNAL_FUNC(handleMenuDestroy), ! parent); ! ! return item1; ! }; ! ! MenuHandle osInsertMenuRadioItem(MenuHandle parent, int pos) ! { ! int new_pos; ! GList *children; ! GtkWidget *menu, *menuItem, *label; ! GSList *group; ! ! new_pos = 0; ! menu = gtk_widget_get_parent(parent); ! children = GTK_MENU_SHELL(menu)->children; ! ! ! while (children && children->data != parent) ! { ! new_pos++; ! children = children->next; ! } ! ! if (!children || !children->next) ! return NULL; ! ! new_pos++; ! children = children->next; ! group = NULL; ! ! if (pos < 0) ! { ! while (children && GTK_WIDGET_VISIBLE((GtkWidget *) children->data)) ! { ! new_pos++; ! group = gtk_radio_menu_item_get_group(GTK_RADIO_MENU_ITEM((GtkWidget *) children->data)); ! children = children->next; ! } ! } ! else ! { ! while (children && GTK_WIDGET_VISIBLE((GtkWidget *) children->data) && pos > 0) ! { ! pos--; ! new_pos++; ! group = gtk_radio_menu_item_get_group(GTK_RADIO_MENU_ITEM((GtkWidget *) children->data)); ! children = children->next; ! } ! } ! ! menuItem = gtk_radio_menu_item_new (group); ! label = gtk_accel_label_new(""); ! gtk_container_add(GTK_CONTAINER(menuItem), label); ! gtk_accel_label_set_accel_widget(GTK_ACCEL_LABEL(label), menuItem); ! ! gtk_signal_connect (GTK_OBJECT(menuItem), "activate", ! GTK_SIGNAL_FUNC(handleRadioMenuCommand), ! NULL); ! gtk_signal_connect (GTK_OBJECT(menuItem), "destroy", ! GTK_SIGNAL_FUNC(handleMenuDestroy), ! NULL); ! ! gtk_menu_shell_insert(GTK_MENU_SHELL(menu), menuItem, new_pos); ! gtk_widget_show_all(menuItem); ! ! return menuItem; ! } ! ! 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--; ! } ! ! return count; ! } ! ! void osSetMenuItemEnabled(MenuHandle item, BOOL bState) { gtk_widget_set_sensitive(item,bState); }; ! BOOL osGetMenuItemEnabled(MenuHandle item) { return GTK_WIDGET_SENSITIVE(item); }; ! void osSetMenuItemChecked(MenuHandle item, BOOL bState) { gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM(item), bState); }; ! BOOL osGetMenuItemChecked(MenuHandle item) { return gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(item)); }; ! 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) ! { ! 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))); ! }; ! ! static gboolean find_accel_by_widget(GtkAccelKey *key, GClosure *closure, gpointer data) ! { ! return (closure->data == data); ! } ! ! void osSetMenuItemAccel(MenuHandle item, int key, unsigned int mods) ! { ! GdkModifierType modifier; ! GtkAccelKey *accel_key; ! GtkAccelGroup *accel_group = (GtkAccelGroup *) gtk_accel_groups_from_object (G_OBJECT(gFrameWidget))->data; ! ! accel_key = gtk_accel_group_find(accel_group, find_accel_by_widget, item); ! if (accel_key) gtk_widget_remove_accelerator(item, accel_group, accel_key->accel_key, accel_key->accel_mods); ! ! if (!key) return; ! ! modifier = 0; ! if (mods & shiftBIT) modifier |= GDK_SHIFT_MASK; ! if (mods & ctrlBIT) modifier |= GDK_CONTROL_MASK; ! if (mods & altBIT) modifier |= GDK_MOD1_MASK; ! ! switch (key) ! { ! case kbBackSpace: key = GDK_BackSpace; break; ! case kbTab: key = GDK_Tab; break; ! case kbEnter: key = GDK_Return; break; ! case kbEscape: key = GDK_Escape; break; ! case kbBegin: key = GDK_Begin; break; ! case kbClear: key = GDK_Clear; break; ! case kbDelete: key = GDK_Delete; break; ! case kbDown: key = GDK_Down; break; ! case kbEnd: key = GDK_End; break; ! case kbF1: key = GDK_F1; break; ! case kbF2: key = GDK_F2; break; ! case kbF3: key = GDK_F3; break; ! case kbF4: key = GDK_F4; break; ! case kbF5: key = GDK_F5; break; ! case kbF6: key = GDK_F6; break; ! case kbF7: key = GDK_F7; break; ! case kbF8: key = GDK_F8; break; ! case kbF9: key = GDK_F9; break; ! case kbF10: key = GDK_F10; break; ! case kbF11: key = GDK_F11; break; ! case kbF12: key = GDK_F12; break; ! case kbF13: key = GDK_F13; break; ! case kbF14: key = GDK_F14; break; ! case kbF15: key = GDK_F15; break; ! case kbHelp: key = GDK_Help; break; ! case kbLeft: key = GDK_Left; break; ! case kbPgDown: key = GDK_Page_Down; break; ! case kbPgUp: key = GDK_Page_Up; break; ! case kbRight: key = GDK_Right; break; ! case kbUp: key = GDK_Up; break; ! default: ! if (key >= 256) ! { ! key -= 256; ! modifier = GDK_MOD1_MASK; ! } ! ! if (iscntrl(key)) ! { ! key += '@'; ! modifier |= GDK_CONTROL_MASK; ! } ! else ! if (isupper(key)) ! modifier |= GDK_SHIFT_MASK; ! else ! key = toupper(key); ! break; ! } ! ! gtk_widget_add_accelerator(item, "activate", ! accel_group, ! key, ! modifier, ! GTK_ACCEL_VISIBLE); ! }; ! ! void osGetMenuItemAccel(MenuHandle item, int *key, unsigned int *mods) ! { ! GtkAccelKey *accel_key; ! GtkAccelGroup *accel_group = (GtkAccelGroup *) gtk_accel_groups_from_object (G_OBJECT(gFrameWidget))->data; ! ! accel_key = gtk_accel_group_find(accel_group, find_accel_by_widget, item); ! ! if (accel_key) ! { ! *mods = 0; ! if (accel_key->accel_mods & GDK_SHIFT_MASK) *mods |= shiftBIT; ! if (accel_key->accel_mods & GDK_CONTROL_MASK) *mods |= ctrlBIT; ! if (accel_key->accel_mods & GDK_MOD1_MASK) *mods |= altBIT; ! ! switch (accel_key->accel_key) ! { ! case GDK_Up: *key = kbUp; break; ! case GDK_Down: *key = kbDown; break; ! case GDK_Left: *key = kbLeft; break; ! case GDK_Right: *key = kbRight; break; ! case GDK_Page_Up: *key = kbPgUp; break; ! case GDK_Page_Down:*key = kbPgDown; break; ! case GDK_End: *key = kbEnd; break; ! case GDK_Begin: *key = kbBegin; break; ! case GDK_BackSpace:*key = kbBackSpace; break; ! case GDK_Delete: *key = kbDelete; break; ! case GDK_Tab: *key = kbTab; break; ! case GDK_Return: *key = kbEnter; break; ! case GDK_Escape: *key = kbEscape; break; ! case GDK_Help: *key = kbHelp; break; ! case GDK_F1: *key = kbF1; break; ! case GDK_F2: *key = kbF2; break; ! case GDK_F3: *key = kbF3; break; ! case GDK_F4: *key = kbF4; break; ! case GDK_F5: *key = kbF5; break; ! case GDK_F6: *key = kbF6; break; ! case GDK_F7: *key = kbF7; break; ! case GDK_F8: *key = kbF8; break; ! case GDK_F9: *key = kbF9; break; ! case GDK_F10: *key = kbF10; break; ! case GDK_F11: *key = kbF11; break; ! case GDK_F12: *key = kbF12; break; ! case GDK_Clear: *key = kbClear; break; ! default: ! *mods = 0; ! ! *key = accel_key->accel_key; ! if (accel_key->accel_mods & GDK_CONTROL_MASK) ! *key = toupper(accel_key->accel_key) - '@'; ! else ! if (accel_key->accel_mods & GDK_SHIFT_MASK) ! *key = toupper(accel_key->accel_key); ! ! if (accel_key->accel_mods & GDK_MOD1_MASK) ! *key += 256; ! break; ! } ! } ! else ! { ! *key = 0; ! *mods = 0; ! } ! }; ! ! void osSetMenuItemBitmap(MenuHandle item, BitmapHandle bitmap) ! { ! GtkWidget *image = gtk_image_menu_item_get_image(GTK_IMAGE_MENU_ITEM(item)); ! ! if (bitmap) ! { ! if (!image) ! { ! image = gtk_image_new_from_pixbuf(bitmap->pixbuf); ! gtk_widget_show(image); ! gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item), image); ! } ! else ! gtk_image_set_from_pixbuf(GTK_IMAGE(image),bitmap->pixbuf); ! } ! else ! { ! if (image) ! { ! gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item), NULL); ! } ! } ! }; ! ! 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; } + |
From: <kr_...@us...> - 2003-04-23 21:49:30
|
Update of /cvsroot/htoolkit/gio/src/Graphics/UI/GIO In directory sc8-pr-cvs1:/tmp/cvs-serv26873/gio/src/Graphics/UI/GIO Modified Files: Attributes.hs Events.hs Menu.hs Log Message: Complete implementation for Menu with both GTK and Win32. Supported: - command menu items with bitmaps - checked menu items - radio menu items - sepparators - sub menus Index: Attributes.hs =================================================================== RCS file: /cvsroot/htoolkit/gio/src/Graphics/UI/GIO/Attributes.hs,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** Attributes.hs 30 Mar 2003 18:49:07 -0000 1.8 --- Attributes.hs 23 Apr 2003 21:48:46 -0000 1.9 *************** *** 69,72 **** --- 69,78 ---- -- ** ToolTip , ToolTip, tooltip + + -- ** Accelerated + , Accelerated, accel + + -- ** Positioned + , Positioned, pos -- ** Selection *************** *** 263,266 **** --- 269,282 ---- -- | The tip text tooltip :: Attr w String + + -- | Widgets that has accelerator key. + class Accelerated w where + -- | The accelerator. Set the property to (@KeyNull@) to remove the accelerator key. + accel :: Attr w Key + + -- | Widgets that has specified integer position. + class Positioned w where + -- | The widget position + pos :: Attr w Int -- | Widgets that can be checked. Index: Events.hs =================================================================== RCS file: /cvsroot/htoolkit/gio/src/Graphics/UI/GIO/Events.hs,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** Events.hs 14 Apr 2003 20:40:37 -0000 1.11 --- Events.hs 23 Apr 2003 21:48:47 -0000 1.12 *************** *** 66,69 **** --- 66,72 ---- , Commanding, command + -- ** Dynamic update + , DynamicUpdate, update + -- ** Reactive , Reactive *************** *** 117,122 **** -- *** Paint , newPaintEvent - -- *** Misc - , newMenuEvent -- ** Generic event creators --- 120,123 ---- *************** *** 159,162 **** --- 160,168 ---- class Commanding w where command :: Event w (IO ()) + + -- | The widgets which are members of 'DynamicUpdate' class has 'update' + -- event. The 'update' event is raised when the widget can update its state. + class DynamicUpdate w where + update :: Event w (IO ()) -- | A form is a visible window on the screen. *************** *** 386,394 **** (\w h -> Lib.setWindowPaintHandler (getWindowHandle w) (convert w h) >> setVar (getv w) h) (\w -> Lib.setWindowPaintDefHandler (getWindowHandle w) >> setVar (getv w) (\_ _ _ -> return ())) - - -- | Create a new generic event for menu command. - newMenuEvent :: (w -> MenuHandle) -> Event w (IO ()) - newMenuEvent getMenuHandle - = newEvent (Lib.getMenuCommandHandler . getMenuHandle) (Lib.setMenuCommandHandler . getMenuHandle) (Lib.setMenuCommandDefHandler . getMenuHandle) {-------------------------------------------------------------------- --- 392,395 ---- Index: Menu.hs =================================================================== RCS file: /cvsroot/htoolkit/gio/src/Graphics/UI/GIO/Menu.hs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Menu.hs 1 Apr 2003 23:54:20 -0000 1.5 --- Menu.hs 23 Apr 2003 21:48:47 -0000 1.6 *************** *** 1,8 **** ----------------------------------------------------------------------------------------- {-| Module : Menu ! Copyright : (c) Daan Leijen 2003 License : BSD-style ! Maintainer : da...@cs... Stability : provisional Portability : portable --- 1,8 ---- ----------------------------------------------------------------------------------------- {-| Module : Menu ! Copyright : (c) Krasimir Angelov & Daan Leijen 2003 License : BSD-style ! Maintainer : ka2...@ya... da...@cs... Stability : provisional Portability : portable *************** *** 13,25 **** module Graphics.UI.GIO.Menu ( -- * Menus ! Menu, mainMenu, menu -- * Menu items -- ** Menu item ! , MenuItem, menuitem, menukey -- ** Menu separator ! , menuline ) where ! import Char (isLower, isUpper) import qualified Graphics.UI.Port as Lib import Graphics.UI.GIO.Types --- 13,31 ---- module Graphics.UI.GIO.Menu ( -- * Menus ! Menu, mainMenu, menu, menuAt, itemCount -- * Menu items -- ** Menu item ! , MenuItem, menuitem, menuitemAt ! , menuicon ! -- ** Checked menu items ! , MenuCheck, menucheck, menucheckAt ! -- ** Radio group and radio items ! , MenuRadioGroup, menuRadioGroupAt, menuRadioGroup ! , MenuRadioItem, menuRadioItemAt, menuRadioItem -- ** Menu separator ! , MenuLine, menuline, menulineAt ) where ! import System.IO.Unsafe( unsafePerformIO ) import qualified Graphics.UI.Port as Lib import Graphics.UI.GIO.Types *************** *** 34,104 **** -- | A menu is a widget that contains menu items or other (sub) menus. -- The top level menu is always a 'mainMenu'. ! data Menu = Menu{ hmenu :: !MenuHandle ! } -- | The main application menu mainMenu :: Menu mainMenu = Menu Lib.mainMenu ! -- | Add a menu. ! menu :: String -> [Prop Menu] -> Menu -> IO Menu ! menu title props parent ! = do m <- do hmenu <- Lib.addMenu (hmenu parent) title return (Menu hmenu) set m props return m ! {-------------------------------------------------------------------- ! Menu items ! --------------------------------------------------------------------} -- | Menu items are labeled entries in a menu. ! data MenuItem = MenuItem{ hitem :: MenuHandle ! , parent :: Menu ! , mtext :: String ! , vkey :: Var Key ! } ! -- | Create a menu item with a certain label. ! menuitem :: String -> [Prop MenuItem] -> Menu -> IO MenuItem ! menuitem title props menu ! = do mitem <- do hitem <- Lib.addMenuItem (hmenu menu) Lib.KeyNull title ! vkey <- newVar Lib.KeyNull ! return (MenuItem hitem menu title vkey) set mitem props return mitem ! instance Able MenuItem where ! enabled = newAttr (\w -> Lib.getMenuItemEnabled (hmenu (parent w)) (hitem w)) ! (\w -> Lib.setMenuItemEnabled (hmenu (parent w)) (hitem w)) instance Commanding MenuItem where ! command = newMenuEvent hitem ! -- | The menu short-cut key. Use (@KeyChar '\0'@) for no short-cut key (default) ! menukey :: Attr MenuItem Key ! menukey ! = newAttr (\w -> getVar (vkey w)) ! (\w x -> do setVar (vkey w) x; menuItemUpdateLabel w) ! menuItemUpdateLabel m ! = do key <- getVar (vkey m) ! Lib.setMenuItemLabel (hmenu (parent m)) (hitem m) key (mtext m) ! {-------------------------------------------------------------------- ! Menu separator ! --------------------------------------------------------------------} ! -- | Adds a menu seperator line ! menuline :: Menu -> IO () ! menuline menu ! = Lib.addMenuSeparatorItem (hmenu menu) ! {-------------------------------------------------------------------- ! do m <- menubar [] w ! fm <- submenu "&File" [] m ! menuitem "&Open" [] fm ! menuitem "&Close" [] fm ! menuitem "E&xit" [] fm ! ! --------------------------------------------------------------------} --- 40,253 ---- -- | A menu is a widget that contains menu items or other (sub) menus. -- The top level menu is always a 'mainMenu'. ! newtype Menu = Menu MenuHandle ! 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 return (Menu hmenu) set m props return m ! -- | Append a menu ! menu :: [Prop Menu] -> Menu -> IO Menu ! menu = menuAt Nothing ! ! instance Titled Menu where ! title = newAttr (Lib.getMenuLabel . hmenu) (Lib.setMenuLabel . hmenu) ! ! itemCount :: Attr Menu Int ! itemCount = readAttr "itemsCount" (Lib.getMenuItemCount . hmenu) ! ! instance Positioned Menu where ! pos = readAttr "pos" (Lib.getMenuItemPos . hmenu) ! ! instance Deadly Menu where ! destroyWidget m = Lib.destroyMenu (hmenu m) ! destroy = newEvent (Lib.getMenuDestroyHandler . hmenu) (Lib.setMenuDestroyHandler . hmenu) (Lib.setMenuDestroyDefHandler . hmenu) ! ! -------------------------------------------------------------------- ! -- Menu items ! -------------------------------------------------------------------- -- | Menu items are labeled entries in a menu. ! newtype MenuItem = MenuItem MenuHandle ! hitem (MenuItem h) = h ! -- | Create a menu item and insert it at specified position. ! menuitemAt :: Maybe Int -> [Prop MenuItem] -> Menu -> IO MenuItem ! menuitemAt pos props menu ! = do mitem <- do hitem <- Lib.insertMenuItem (hmenu menu) pos ! return (MenuItem hitem) set mitem props return mitem ! -- | Create a menu item and appends it to parent menu. ! menuitem :: [Prop MenuItem] -> Menu -> IO MenuItem ! menuitem = menuitemAt Nothing instance Able MenuItem where ! enabled = newAttr (Lib.getMenuItemEnabled . hitem) (Lib.setMenuItemEnabled . hitem) instance Commanding MenuItem where ! command = newEvent (Lib.getMenuCommandHandler . hitem) (Lib.setMenuCommandHandler . hitem) (Lib.setMenuCommandDefHandler . hitem) ! ! instance DynamicUpdate MenuItem where ! update = newEvent (Lib.getMenuUpdateHandler . hitem) (Lib.setMenuUpdateHandler . hitem) (Lib.setMenuUpdateDefHandler . hitem) + instance Titled MenuItem where + title = newAttr (Lib.getMenuLabel . hitem) (Lib.setMenuLabel . hitem) ! instance Accelerated MenuItem where ! accel = newAttr (Lib.getMenuItemAccel . hitem) (Lib.setMenuItemAccel . hitem) ! menuicon :: Attr MenuItem (Maybe Bitmap) ! menuicon = newAttr (Lib.getMenuItemBitmap . hitem) ! (Lib.setMenuItemBitmap . hitem) ! instance Positioned MenuItem where ! pos = readAttr "pos" (Lib.getMenuItemPos . hitem) ! instance Deadly MenuItem where ! destroyWidget m = Lib.destroyMenu (hitem m) ! destroy = newEvent (Lib.getMenuDestroyHandler . hitem) (Lib.setMenuDestroyHandler . hitem) (Lib.setMenuDestroyDefHandler . hitem) ! ! -------------------------------------------------------------------- ! -- Menu radio groups and radio items ! -------------------------------------------------------------------- ! -- | Menu items are labeled entries in a menu. ! newtype MenuRadioGroup = MenuRadioGroup MenuHandle ! hradiogroup (MenuRadioGroup h) = h ! ! -- | Create a menu item and insert it at specified position. ! menuRadioGroupAt :: Maybe Int -> [Prop MenuRadioGroup] -> Menu -> IO MenuRadioGroup ! menuRadioGroupAt pos props menu ! = do mradiogroup <- do hradiogroup <- Lib.insertMenuRadioGroup (hmenu menu) pos ! return (MenuRadioGroup hradiogroup) ! set mradiogroup props ! return mradiogroup ! ! -- | Create a menu item and appends it to parent menu. ! menuRadioGroup :: [Prop MenuRadioGroup] -> Menu -> IO MenuRadioGroup ! menuRadioGroup = menuRadioGroupAt Nothing ! ! instance Positioned MenuRadioGroup where ! pos = readAttr "pos" (Lib.getMenuItemPos . hradiogroup) ! ! instance Deadly MenuRadioGroup where ! destroyWidget m = Lib.destroyMenu (hradiogroup m) ! destroy = newEvent (Lib.getMenuDestroyHandler . hradiogroup) (Lib.setMenuDestroyHandler . hradiogroup) (Lib.setMenuDestroyDefHandler . hradiogroup) ! ! instance SingleSelect MenuRadioGroup where ! selected = newAttr (Lib.getMenuRadioGroupSelection . hradiogroup) (Lib.setMenuRadioGroupSelection . hradiogroup) ! ! -- | 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] -> MenuRadioGroup -> IO MenuRadioItem ! menuRadioItemAt pos props group ! = do mradioitem <- do hradioitem <- Lib.insertMenuRadioItem (hradiogroup group) pos ! return (MenuRadioItem hradioitem) ! set mradioitem props ! return mradioitem ! ! -- | Create a menu item and appends it to parent menu. ! menuRadioItem :: [Prop MenuRadioItem] -> MenuRadioGroup -> IO MenuRadioItem ! menuRadioItem = menuRadioItemAt Nothing ! ! instance Able MenuRadioItem where ! enabled = newAttr (Lib.getMenuItemEnabled . hradioitem) (Lib.setMenuItemEnabled . hradioitem) ! ! instance Commanding MenuRadioItem where ! command = newEvent (Lib.getMenuCommandHandler . hradioitem) (Lib.setMenuCommandHandler . hradioitem) (Lib.setMenuCommandDefHandler . hradioitem) ! ! instance DynamicUpdate MenuRadioItem where ! update = newEvent (Lib.getMenuUpdateHandler . hradioitem) (Lib.setMenuUpdateHandler . hradioitem) (Lib.setMenuUpdateDefHandler . hradioitem) ! ! instance Positioned MenuRadioItem where ! pos = readAttr "pos" (Lib.getMenuItemPos . hradioitem) ! ! instance Deadly MenuRadioItem where ! destroyWidget m = Lib.destroyMenu (hradioitem m) ! destroy = newEvent (Lib.getMenuDestroyHandler . hradioitem) (Lib.setMenuDestroyHandler . hradioitem) (Lib.setMenuDestroyDefHandler . hradioitem) ! ! instance Titled MenuRadioItem where ! title = newAttr (Lib.getMenuLabel . hradioitem) (Lib.setMenuLabel . hradioitem) ! ! instance Accelerated MenuRadioItem where ! accel = newAttr (Lib.getMenuItemAccel . hradioitem) (Lib.setMenuItemAccel . hradioitem) ! ! -------------------------------------------------------------------- ! -- 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 ! return (MenuCheck mcheck) ! set mcheck props ! return mcheck ! ! -- | Create a checked menu item and appends it to parent menu. ! menucheck :: [Prop MenuCheck] -> Menu -> IO MenuCheck ! menucheck = menucheckAt Nothing ! ! instance Able MenuCheck where ! enabled = newAttr (Lib.getMenuItemEnabled . hcheck) (Lib.setMenuItemEnabled . hcheck) ! ! instance Commanding MenuCheck where ! command = newEvent (Lib.getMenuCommandHandler . hcheck) (Lib.setMenuCommandHandler . hcheck) (Lib.setMenuCommandDefHandler . hcheck) ! ! instance DynamicUpdate MenuCheck where ! update = newEvent (Lib.getMenuUpdateHandler . hcheck) (Lib.setMenuUpdateHandler . hcheck) (Lib.setMenuUpdateDefHandler . hcheck) ! ! instance Titled MenuCheck where ! title = newAttr (Lib.getMenuLabel . hcheck) (Lib.setMenuLabel . hcheck) ! ! instance Accelerated MenuCheck where ! accel = newAttr (Lib.getMenuItemAccel . hcheck) (Lib.setMenuItemAccel . hcheck) ! ! instance Positioned MenuCheck where ! pos = readAttr "pos" (Lib.getMenuItemPos . hcheck) ! ! instance Checked MenuCheck where ! checked = newAttr (Lib.getMenuItemChecked . hcheck) (Lib.setMenuItemChecked . hcheck) ! ! instance Deadly MenuCheck where ! destroyWidget m = Lib.destroyMenu (hcheck m) ! destroy = newEvent (Lib.getMenuDestroyHandler . hcheck) (Lib.setMenuDestroyHandler . hcheck) (Lib.setMenuDestroyDefHandler . hcheck) ! ! -------------------------------------------------------------------- ! -- Menu separator ! -------------------------------------------------------------------- ! ! -- | Menu separator item ! newtype MenuLine = MenuLine MenuHandle ! hline (MenuLine h) = h ! ! -- | Insert a menu seperator line at specified position. ! menulineAt :: Maybe Int -> Menu -> IO MenuLine ! menulineAt pos menu ! = do hitem <- Lib.insertMenuSeparatorItem (hmenu menu) pos ! return (MenuLine hitem) ! ! -- | Append a menu seperator line ! menuline :: Menu -> IO MenuLine ! menuline = menulineAt Nothing ! ! instance Positioned MenuLine where ! pos = readAttr "pos" (Lib.getMenuItemPos . hline) ! ! instance Deadly MenuLine where ! destroyWidget m = Lib.destroyMenu (hline m) ! destroy = newEvent (Lib.getMenuDestroyHandler . hline) (Lib.setMenuDestroyHandler . hline) (Lib.setMenuDestroyDefHandler . hline) |
From: <kr_...@us...> - 2003-04-23 21:49:30
|
Update of /cvsroot/htoolkit/port/src/Port In directory sc8-pr-cvs1:/tmp/cvs-serv26873/port/src/Port Modified Files: Handlers.hs Menu.hs Log Message: Complete implementation for Menu with both GTK and Win32. Supported: - command menu items with bitmaps - checked menu items - radio menu items - sepparators - sub menus Index: Handlers.hs =================================================================== RCS file: /cvsroot/htoolkit/port/src/Port/Handlers.hs,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** Handlers.hs 14 Apr 2003 18:22:32 -0000 1.20 --- Handlers.hs 23 Apr 2003 21:48:49 -0000 1.21 *************** *** 68,71 **** --- 68,72 ---- ,setMenuCommandHandler, setMenuCommandDefHandler, getMenuCommandHandler ,setMenuUpdateHandler, setMenuUpdateDefHandler, getMenuUpdateHandler + ,setMenuDestroyHandler, setMenuDestroyDefHandler, getMenuDestroyHandler ) where *************** *** 498,505 **** = getHandler hmenu (return ()) handlersMenuUpdate ! handleMenusUpdate :: IO () ! handleMenusUpdate ! = do map <- readMVar handlersMenuUpdate ! sequence_ (elems map) ----------------------------------------------------------------------------------------- --- 499,505 ---- = getHandler hmenu (return ()) handlersMenuUpdate ! handleMenuUpdate :: MenuHandle -> IO () ! handleMenuUpdate hmenu ! = invokeHandler hmenu handlersMenuUpdate id ----------------------------------------------------------------------------------------- *************** *** 528,531 **** --- 528,562 ---- = invokeHandler hmenu handlersMenuCommand id + ----------------------------------------------------------------------------------------- + -- MenuDestroy + ----------------------------------------------------------------------------------------- + + {-# NOINLINE handlersMenuDestroy #-} + handlersMenuDestroy :: MVar (PtrMap MenuHandle (IO ())) + handlersMenuDestroy + = unsafePerformIO (newMVar empty) + + setMenuDestroyHandler :: MenuHandle -> IO () -> IO () + setMenuDestroyHandler hmenu handler + = setHandler hmenu handler handlersMenuDestroy + + setMenuDestroyDefHandler :: MenuHandle -> IO () + setMenuDestroyDefHandler hmenu + = setDefHandler hmenu handlersMenuDestroy + + getMenuDestroyHandler :: MenuHandle -> IO (IO ()) + getMenuDestroyHandler hmenu + = getHandler hmenu (return ()) handlersMenuDestroy + + handleMenuDestroy :: MenuHandle -> IO () + handleMenuDestroy hmenu + = do map <- takeMVar handlersMenuDestroy + setMenuCommandDefHandler hmenu + setMenuUpdateDefHandler hmenu + putMVar handlersMenuDestroy (delete hmenu map) + case lookup hmenu map of + Nothing -> return () + Just io -> safeio io + {----------------------------------------------------------------------------------------- ProcessDismiss *************** *** 673,677 **** foreign export ccall handleControlCommand :: WindowHandle -> IO () foreign export ccall handleMenuCommand :: MenuHandle -> IO () ! foreign export ccall handleMenusUpdate :: IO () foreign export ccall handleTimer :: TimerHandle -> IO () foreign export ccall handleTimerDestroy :: TimerHandle -> IO () --- 704,709 ---- foreign export ccall handleControlCommand :: WindowHandle -> IO () foreign export ccall handleMenuCommand :: MenuHandle -> IO () ! foreign export ccall handleMenuUpdate :: MenuHandle -> IO () ! foreign export ccall handleMenuDestroy :: MenuHandle -> IO () foreign export ccall handleTimer :: TimerHandle -> IO () foreign export ccall handleTimerDestroy :: TimerHandle -> IO () Index: Menu.hs =================================================================== RCS file: /cvsroot/htoolkit/port/src/Port/Menu.hs,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Menu.hs 1 Apr 2003 23:54:20 -0000 1.6 --- Menu.hs 23 Apr 2003 21:48:49 -0000 1.7 *************** *** 13,41 **** ----------------------------------------------------------------------------------------- module Graphics.UI.Port.Menu ! ( -- * Menu bar mainMenu - , drawMenuBar -- * Sub menus ! , addMenu -- * Menu items ! , addMenuItem ! , addMenuSeparatorItem ! , addMenuCheckItem , setMenuItemEnabled, getMenuItemEnabled - , setMenuItemLabel , setMenuItemChecked, getMenuItemChecked ) where import Foreign.C import Graphics.UI.Port.Types import Graphics.UI.Port.Handlers -- just for haddock ! ! {----------------------------------------------------------------------------------------- ! Wrappers ! -----------------------------------------------------------------------------------------} ! -- | Redraw the menubar. Must be called before menu changes become visible. ! foreign import ccall "osDrawMenuBar" drawMenuBar :: WindowHandle -> IO () -- | The handle of the main application menu --- 13,52 ---- ----------------------------------------------------------------------------------------- module Graphics.UI.Port.Menu ! ( -- * Menu bar mainMenu -- * Sub menus ! , insertMenu ! , getMenuItemCount -- * Menu items ! , insertMenuItem ! , insertMenuSeparatorItem ! , insertMenuCheckItem ! , setMenuItemAccel, getMenuItemAccel , setMenuItemEnabled, getMenuItemEnabled , setMenuItemChecked, getMenuItemChecked + , setMenuItemBitmap, getMenuItemBitmap + -- * Radio groups and radio items + , insertMenuRadioGroup + , insertMenuRadioItem + , setMenuRadioGroupSelection, getMenuRadioGroupSelection + -- * Common functions + , destroyMenu + , getMenuItemPos + , setMenuLabel, getMenuLabel ) where + import Foreign import Foreign.C + import Data.Maybe( fromMaybe ) + import Control.Concurrent.MVar import Graphics.UI.Port.Types import Graphics.UI.Port.Handlers -- just for haddock + import Graphics.UI.Port.PtrMap as PtrMap + import System.IO.Unsafe( unsafePerformIO ) ! ----------------------------------------------------------------------------------------- ! -- Menu bar ! ----------------------------------------------------------------------------------------- -- | The handle of the main application menu *************** *** 43,93 **** mainMenu = nullHandle -- | Add a sub menu. ! addMenu :: MenuHandle -> String -> IO MenuHandle ! addMenu hmenu title = withCString title (osAddMenu hmenu) ! foreign import ccall osAddMenu :: MenuHandle -> CString -> IO MenuHandle -- | Add a menu item. Use a null character ('keyNull') if no -- short-cut key should be registered. An event handler for a menu item can be -- installed with 'registerMenuCommand'. ! addMenuItem :: MenuHandle -> Key -> String -> IO MenuHandle ! addMenuItem hmenu key title ! = withCString title $ \ctitle -> ! let (ckey,cmods) = toCKey key ! in osAddMenuItem hmenu ckey cmods ctitle ! foreign import ccall osAddMenuItem :: MenuHandle -> CInt -> CWord -> CString -> IO MenuHandle -- | Add a checkable menu item. An event handler for a menu item can be -- installed with 'registerMenuCommand'. ! addMenuCheckItem :: MenuHandle -> Key -> String -> IO MenuHandle ! addMenuCheckItem hmenu key title ! = withCString title $ \ctitle -> ! let (ckey,cmods) = toCKey key ! in osAddMenuCheckItem hmenu ckey cmods ctitle ! foreign import ccall osAddMenuCheckItem :: MenuHandle -> CInt -> CWord -> CString -> IO MenuHandle -- | Add a menu item separator line. ! addMenuSeparatorItem :: MenuHandle -> IO () ! addMenuSeparatorItem hmenu ! = osAddMenuSeparatorItem hmenu ! foreign import ccall osAddMenuSeparatorItem :: MenuHandle -> IO () ! -- | Change the label (and short-cut key) of a menu item (or checkable menu item). ! setMenuItemLabel :: MenuHandle -> MenuHandle -> Key -> String -> IO () ! setMenuItemLabel hparent hmenu key title ! = withCString title $ \ctitle -> ! let (ckey,cmods) = toCKey key ! in osSetMenuItemLabel hparent hmenu ckey cmods ctitle ! foreign import ccall osSetMenuItemLabel :: MenuHandle -> MenuHandle -> CInt -> CWord -> CString -> IO () -- | Enable or disable a menu item. ! foreign import ccall unsafe "osSetMenuItemEnabled" setMenuItemEnabled :: MenuHandle -> MenuHandle -> Bool -> IO () -- | returns True if the menu item is enabled. ! foreign import ccall unsafe "osGetMenuItemEnabled" getMenuItemEnabled :: MenuHandle -> MenuHandle -> IO Bool -- | Check or uncheck a checkable menu item. ! foreign import ccall "osSetMenuItemChecked" setMenuItemChecked :: MenuHandle -> MenuHandle -> Bool -> IO () -- | returns True if the menu item is checked. ! foreign import ccall "osGetMenuItemChecked" getMenuItemChecked :: MenuHandle -> MenuHandle -> IO Bool --- 54,184 ---- mainMenu = nullHandle + ----------------------------------------------------------------------------------------- + -- Sub menus + ----------------------------------------------------------------------------------------- + -- | 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 ! ! ----------------------------------------------------------------------------------------- ! -- Menu items ! ----------------------------------------------------------------------------------------- -- | Add a menu item. Use a null character ('keyNull') if no -- short-cut key should be registered. An event handler for a menu item can be -- installed with 'registerMenuCommand'. ! insertMenuItem :: MenuHandle -> Maybe Int -> IO MenuHandle ! insertMenuItem handle pos = osInsertMenuItem handle (fromMaybe (-1) pos) ! foreign import ccall osInsertMenuItem :: MenuHandle -> Int -> IO MenuHandle -- | Add a checkable menu item. An event handler for a menu item can be -- installed with 'registerMenuCommand'. ! insertMenuCheckItem :: MenuHandle -> Maybe Int -> IO MenuHandle ! insertMenuCheckItem handle pos = osInsertMenuCheckItem handle (fromMaybe (-1) pos) ! foreign import ccall osInsertMenuCheckItem :: MenuHandle -> Int -> IO MenuHandle -- | Add a menu item separator line. ! insertMenuSeparatorItem :: MenuHandle -> Maybe Int -> IO MenuHandle ! insertMenuSeparatorItem handle pos = osInsertMenuSeparatorItem handle (fromMaybe (-1) pos) ! foreign import ccall osInsertMenuSeparatorItem :: MenuHandle -> Int -> IO MenuHandle ! getMenuItemAccel :: MenuHandle -> IO Key ! getMenuItemAccel hmenu ! = alloca $ \pckey -> ! alloca $ \pcmods -> ! do osGetMenuItemAccel hmenu pckey pcmods ! ckey <- peek pckey ! cmods <- peek pcmods ! return (fromCKey ckey cmods) ! foreign import ccall osGetMenuItemAccel :: MenuHandle -> Ptr CInt -> Ptr CWord -> IO () ! ! setMenuItemAccel :: MenuHandle -> Key -> IO () ! setMenuItemAccel hmenu key ! = let (ckey,cmods) = toCKey key ! in osSetMenuItemAccel hmenu ckey cmods ! foreign import ccall osSetMenuItemAccel :: MenuHandle -> CInt -> CWord -> IO () -- | Enable or disable a menu item. ! foreign import ccall "osSetMenuItemEnabled" setMenuItemEnabled :: MenuHandle -> Bool -> IO () -- | returns True if the menu item is enabled. ! foreign import ccall "osGetMenuItemEnabled" getMenuItemEnabled :: MenuHandle -> IO Bool -- | Check or uncheck a checkable menu item. ! foreign import ccall "osSetMenuItemChecked" setMenuItemChecked :: MenuHandle -> Bool -> IO () -- | returns True if the menu item is checked. ! foreign import ccall "osGetMenuItemChecked" getMenuItemChecked :: MenuHandle -> IO Bool ! ! {-# NOINLINE menuBitmaps #-} ! menuBitmaps :: MVar (PtrMap MenuHandle Bitmap) ! menuBitmaps = unsafePerformIO (newMVar empty) ! ! setMenuItemBitmap :: MenuHandle -> Maybe Bitmap -> IO () ! setMenuItemBitmap hmenu (Just bmp) = do ! map <- takeMVar menuBitmaps ! withCBitmap bmp (osSetMenuItemBitmap hmenu) ! putMVar menuBitmaps (insert hmenu bmp map) ! setMenuItemBitmap hmenu Nothing = do ! map <- takeMVar menuBitmaps ! osSetMenuItemBitmap hmenu nullPtr ! putMVar menuBitmaps (delete hmenu map) ! foreign import ccall osSetMenuItemBitmap :: MenuHandle -> BitmapHandle -> IO () ! ! getMenuItemBitmap :: MenuHandle -> IO (Maybe Bitmap) ! getMenuItemBitmap hmenu = do ! map <- readMVar menuBitmaps ! return (PtrMap.lookup hmenu map) ! ! ----------------------------------------------------------------------------------------- ! -- Radio groups and radio items ! ----------------------------------------------------------------------------------------- ! ! -- | Add a radio group to the menu. ! insertMenuRadioGroup :: MenuHandle -> Maybe Int -> IO MenuHandle ! insertMenuRadioGroup handle pos = osInsertMenuRadioGroup handle (fromMaybe (-1) pos) ! foreign import ccall osInsertMenuRadioGroup :: MenuHandle -> Int -> IO MenuHandle ! ! -- | Add a menu radio item to the radio group. ! insertMenuRadioItem :: MenuHandle -> Maybe Int -> IO MenuHandle ! insertMenuRadioItem handle pos = osInsertMenuRadioItem handle (fromMaybe (-1) pos) ! foreign import ccall osInsertMenuRadioItem :: MenuHandle -> Int -> IO MenuHandle ! ! -- | Select an active item in the radio group. ! foreign import ccall "osSetMenuRadioGroupSelection" setMenuRadioGroupSelection :: MenuHandle -> Int -> IO () ! ! -- | returns an index of the currently selected radio item. ! foreign import ccall "osGetMenuRadioGroupSelection" getMenuRadioGroupSelection :: MenuHandle -> IO Int ! ! ----------------------------------------------------------------------------------------- ! -- Common functions ! ----------------------------------------------------------------------------------------- ! ! -- | The destroyMenu function deletes an item from the specified menu. If the menu item opens a menu or submenu, ! -- this function destroys the handle to the menu or submenu and frees the memory used by the menu or submenu. ! destroyMenu :: MenuHandle -> IO () ! destroyMenu hmenu = do ! map <- takeMVar menuBitmaps ! osDestroyMenu hmenu ! putMVar menuBitmaps (delete hmenu map) ! foreign import ccall osDestroyMenu :: MenuHandle -> IO () ! ! -- | Returns the position of the item in the parent menu ! foreign import ccall "osGetMenuItemPos" getMenuItemPos :: MenuHandle -> IO Int ! ! -- | Change the label of a menu item (or checkable menu item). ! setMenuLabel :: MenuHandle -> String -> IO () ! setMenuLabel hmenu title ! = withCString title (osSetMenuLabel hmenu) ! foreign import ccall osSetMenuLabel :: MenuHandle -> CString -> IO () ! ! -- | Returns the label of a menu item (or checkable menu item). ! getMenuLabel :: MenuHandle -> IO String ! getMenuLabel hmenu ! = resultCString (osGetMenuLabel hmenu) ! foreign import ccall osGetMenuLabel :: MenuHandle -> IO CString |
From: <kr_...@us...> - 2003-04-23 21:49:30
|
Update of /cvsroot/htoolkit/port In directory sc8-pr-cvs1:/tmp/cvs-serv26873/port Modified Files: makefile Log Message: Complete implementation for Menu with both GTK and Win32. Supported: - command menu items with bitmaps - checked menu items - radio menu items - sepparators - sub menus Index: makefile =================================================================== RCS file: /cvsroot/htoolkit/port/makefile,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** makefile 2 Apr 2003 18:41:10 -0000 1.17 --- makefile 23 Apr 2003 21:48:48 -0000 1.18 *************** *** 51,54 **** --- 51,58 ---- Label.c Font.c RadioBox.c Timer.c Frame.c Message.c Slider.c ProgressBar.c + ifeq "$(GUILIB)" "WIN32" + CSRCS += MenuHandlesMap.c + endif + # package description PKG = config/$(MAIN).pkg *************** *** 75,79 **** CSRCDIRS = src/cbits/$(GUILIB) HEADERDIR = src/include ! CINCDIRS = $(HEADERDIR) $(HOUTDIR)/Port $(FFIDIR) --- 79,83 ---- CSRCDIRS = src/cbits/$(GUILIB) HEADERDIR = src/include ! CINCDIRS = $(HEADERDIR) $(HOUTDIR)/Port $(FFIDIR) src/cbits/$(GUILIB) *************** *** 111,115 **** MAINOBJ = $(MAIN).o ! HOBJS = $(patsubst %.hs,$(HOUTDIR)/%.o, $(HSRCS)) HDEPS = $(patsubst %.hs,$(HOUTDIR)/%.d, $(HSRCS)) HHIS = $(patsubst %.hs,$(HOUTDIR)/Graphics/UI/%.hi, $(HSRCS)) --- 115,119 ---- MAINOBJ = $(MAIN).o ! HOBJS = $(patsubst %.hs,$(HOUTDIR)/%.o, $(HSRCS)) HDEPS = $(patsubst %.hs,$(HOUTDIR)/%.d, $(HSRCS)) HHIS = $(patsubst %.hs,$(HOUTDIR)/Graphics/UI/%.hi, $(HSRCS)) |
From: <kr_...@us...> - 2003-04-23 21:49:30
|
Update of /cvsroot/htoolkit/gio/src/examples/simple In directory sc8-pr-cvs1:/tmp/cvs-serv26873/gio/src/examples/simple Modified Files: SimpleMenu.hs Log Message: Complete implementation for Menu with both GTK and Win32. Supported: - command menu items with bitmaps - checked menu items - radio menu items - sepparators - sub menus Index: SimpleMenu.hs =================================================================== RCS file: /cvsroot/htoolkit/gio/src/examples/simple/SimpleMenu.hs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** SimpleMenu.hs 2 Apr 2003 21:33:55 -0000 1.3 --- SimpleMenu.hs 23 Apr 2003 21:48:48 -0000 1.4 *************** *** 7,15 **** do w <- window [title =: "Hello world", view =: sz 200 200] ! fm <- menu "&File" [] mainMenu ! menuitem "&Open" [menukey =: KeyChar 'o'] fm ! menuitem "&Close" [enabled =: False] fm ! menuline mainMenu ! menuitem "&Exit" [on command =: halt] fm - --- 7,34 ---- do w <- window [title =: "Hello world", view =: sz 200 200] ! bmpNew <- readBitmap "new.bmp" [] ! bmpOpen <- readBitmap "open.bmp" [] ! bmpSave <- readBitmap "save.bmp" [] ! ! fm <- menu [title =: "&File"] mainMenu ! menuitem [title =: "&New", accel =: KeyChar '\^N', on command =: messageAlert "NEW", menuicon =: Just bmpNew] fm ! menuitem [title =: "&Open", accel =: KeyChar '\^O', on command =: messageAlert "OPEN", menuicon =: Just bmpOpen] fm ! menuitem [title =: "&Close"] fm ! menuline fm ! menuitem [title =: "&Save", accel =: KeyChar '\^S', on command =: messageAlert "SAVE", menuicon =: Just bmpSave] fm ! menuline fm ! menuitem [title =: "&Exit", on command =: halt] fm ! ! cm <- menu [title =: "&Color"] mainMenu ! tgl <- menucheck [title =: "&Transparent", accel =: KeyChar '\^T'] cm ! set tgl [on command =: onToggleTransparent tgl] ! menuline cm ! rg <- menuRadioGroup [] cm ! menuRadioItem [title =: "&Red", on command =: messageAlert "RED COLOR" ] rg ! menuRadioItem [title =: "&Green", on command =: messageAlert "GREEN COLOR"] rg ! menuRadioItem [title =: "&Blue", on command =: messageAlert "BLUE COLOR" ] rg ! where ! onToggleTransparent tgl = do ! chk <- get tgl checked ! messageAlert (if chk then "TRANSPARENT ON" else "TRANSPARENT OFF") |