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...> - 2004-05-15 06:47:58
|
Update of /cvsroot/htoolkit/gio/src/examples/simple In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9734/src/examples/simple Modified Files: SimpleHello.hs Log Message: Initial support for Splitter Index: SimpleHello.hs =================================================================== RCS file: /cvsroot/htoolkit/gio/src/examples/simple/SimpleHello.hs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** SimpleHello.hs 7 Oct 2003 21:39:31 -0000 1.5 --- SimpleHello.hs 15 May 2004 06:47:45 -0000 1.6 *************** *** 3,5 **** import Graphics.UI.GIO ! main = start "hello world" "1.0" SDI [] (window [view =: sz 200 200] >>= showWindow) --- 3,12 ---- import Graphics.UI.GIO ! main = start "hello world" "1.0" SDI [] $ do ! w <- window [view =: sz 200 200] ! spl <- hSplitter [] w ! btnOk <- button [title =: "Ok"] spl ! btnCancel <- button [title =: "Cancel"] spl ! set spl [layout =: btnOk ^^^ btnCancel] ! set w [layout =: hfill (vfill spl)] ! showWindow w |
From: <kr_...@us...> - 2004-05-15 06:45:56
|
Update of /cvsroot/htoolkit/port/src/include In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9347/src/include Modified Files: HsPort.h Log Message: Initial support for Splitter. (Only Windows) Index: HsPort.h =================================================================== RCS file: /cvsroot/htoolkit/port/src/include/HsPort.h,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** HsPort.h 12 May 2004 20:42:34 -0000 1.12 --- HsPort.h 15 May 2004 06:45:45 -0000 1.13 *************** *** 26,29 **** #include "port/Notebook.h" #include "port/GroupBox.h" #include "port/Action.h" - --- 26,29 ---- #include "port/Notebook.h" #include "port/GroupBox.h" + #include "port/Splitter.h" #include "port/Action.h" |
From: <kr_...@us...> - 2004-05-15 06:45:55
|
Update of /cvsroot/htoolkit/port In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9347 Modified Files: makefile Log Message: Initial support for Splitter. (Only Windows) Index: makefile =================================================================== RCS file: /cvsroot/htoolkit/port/makefile,v retrieving revision 1.47 retrieving revision 1.48 diff -C2 -d -r1.47 -r1.48 *** makefile 14 May 2004 23:01:36 -0000 1.47 --- makefile 15 May 2004 06:45:44 -0000 1.48 *************** *** 50,54 **** FileDialog.c ColorDialog.c FontDialog.c AboutDialog.c PopUp.c Canvas.c Menu.c ListBox.c \ Label.c Font.c RadioBox.c Timer.c Frame.c Message.c Slider.c TrackBar.c ProgressBar.c \ ! ConfigKey.c ToolBar.c StatusBar.c Notebook.c GroupBox.c Action.c ifeq "$(GUILIB)" "WIN32" --- 50,54 ---- FileDialog.c ColorDialog.c FontDialog.c AboutDialog.c PopUp.c Canvas.c Menu.c ListBox.c \ Label.c Font.c RadioBox.c Timer.c Frame.c Message.c Slider.c TrackBar.c ProgressBar.c \ ! ConfigKey.c ToolBar.c StatusBar.c Notebook.c GroupBox.c Action.c Splitter.c ifeq "$(GUILIB)" "WIN32" |
From: <kr_...@us...> - 2004-05-15 06:45:55
|
Update of /cvsroot/htoolkit/port/src/cbits/Win32 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9347/src/cbits/Win32 Modified Files: Util.c Log Message: Initial support for Splitter. (Only Windows) Index: Util.c =================================================================== RCS file: /cvsroot/htoolkit/port/src/cbits/Win32/Util.c,v retrieving revision 1.32 retrieving revision 1.33 diff -C2 -d -r1.32 -r1.33 *** Util.c 14 May 2004 23:01:41 -0000 1.32 --- Util.c 15 May 2004 06:45:45 -0000 1.33 *************** *** 39,42 **** --- 39,43 ---- extern LRESULT CALLBACK HGroupBoxFunction(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); extern LRESULT CALLBACK HCheckListBoxFunction(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); + extern LRESULT CALLBACK HSplitterFunction(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); extern WNDPROC DefToolBarProc; *************** *** 227,230 **** --- 228,244 ---- RegisterClass(&wc); + // Splitter class + wc.style = CS_DBLCLKS; + wc.lpfnWndProc = HSplitterFunction; + wc.cbClsExtra = 0; + wc.cbWndExtra = 0; + wc.hInstance = ghModule; + wc.hIcon = NULL; + wc.hCursor = LoadCursor (NULL, IDC_ARROW); + wc.hbrBackground = GetSysColorBrush(COLOR_WINDOW); + wc.lpszMenuName = NULL; + wc.lpszClassName = "HSPLITTER"; + RegisterClass(&wc); + icc.dwSize = sizeof(icc); icc.dwICC = ICC_WIN95_CLASSES | ICC_DATE_CLASSES; |
From: <kr_...@us...> - 2004-05-15 06:45:54
|
Update of /cvsroot/htoolkit/port/src/Port In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9347/src/Port Modified Files: Controls.hs Log Message: Initial support for Splitter. (Only Windows) Index: Controls.hs =================================================================== RCS file: /cvsroot/htoolkit/port/src/Port/Controls.hs,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** Controls.hs 25 Nov 2003 14:12:22 -0000 1.29 --- Controls.hs 15 May 2004 06:45:45 -0000 1.30 *************** *** 40,43 **** --- 40,45 ---- * NotebookPage + + * Splitter -} ----------------------------------------------------------------------------------------- *************** *** 117,120 **** --- 119,126 ---- , destroyNotebookPage , getNotebookPageSize + -- * Splitter + , createHorzSplitter, createVertSplitter + , getSplitterRequestSize + , setSplitterChildren ) where *************** *** 608,609 **** --- 614,631 ---- map <- readMVar windowBitmaps return (PtrMap.lookup hwnd map) + + ----------------------------------------------------------------------------------------- + -- Splitter + ----------------------------------------------------------------------------------------- + + -- | Create a new horizontal splitter control. + foreign import ccall "osCreateHorzSplitter" createHorzSplitter :: WindowHandle -> IO WindowHandle + + -- | Create a new vertical splitter control. + foreign import ccall "osCreateVertSplitter" createVertSplitter :: WindowHandle -> IO WindowHandle + + getSplitterRequestSize :: WindowHandle -> IO Size + getSplitterRequestSize hwnd = withCSizeResult (osGetSplitterReqSize hwnd) + foreign import ccall osGetSplitterReqSize :: WindowHandle -> Ptr CInt -> IO () + + foreign import ccall "osSetSplitterChildren" setSplitterChildren :: WindowHandle -> WindowHandle -> WindowHandle -> IO () |
From: <kr_...@us...> - 2004-05-14 23:02:19
|
Update of /cvsroot/htoolkit/port In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27239 Modified Files: makefile Log Message: Still incomplete support for actions under Windows Index: makefile =================================================================== RCS file: /cvsroot/htoolkit/port/makefile,v retrieving revision 1.46 retrieving revision 1.47 diff -C2 -d -r1.46 -r1.47 *** makefile 12 May 2004 20:42:32 -0000 1.46 --- makefile 14 May 2004 23:01:36 -0000 1.47 *************** *** 53,57 **** ifeq "$(GUILIB)" "WIN32" ! CSRCS += MenuHandlesMap.c DockBar.c else CSRCS += gtkdropdownbutton.c gtkdropdowntoolbutton.c LayoutContainer.c --- 53,57 ---- ifeq "$(GUILIB)" "WIN32" ! CSRCS += ActionsMap.c DockBar.c else CSRCS += gtkdropdownbutton.c gtkdropdowntoolbutton.c LayoutContainer.c |
From: <kr_...@us...> - 2004-05-14 23:01:58
|
Update of /cvsroot/htoolkit/port/src/cbits/Win32 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27239/src/cbits/Win32 Modified Files: DockBar.c Frame.c Internals.h Menu.c ToolBar.c Util.c Window.c Added Files: Action.c ActionsMap.c ActionsMap.h Removed Files: MenuHandlesMap.c MenuHandlesMap.h Log Message: Still incomplete support for actions under Windows --- NEW FILE: Action.c --- #include "Action.h" #include "Window.h" #include "DockBar.h" #include "Internals.h" #include "Handlers_stub.h" ActionHandle osCreateAction() { FrameData *pFrameData = (FrameData *) GetWindowLong(ghWndFrame,GWL_USERDATA); return newActionHandle(pFrameData->pActionsMap, ACTION_NORMAL); } ActionHandle osCreateCheckAction() { FrameData *pFrameData = (FrameData *) GetWindowLong(ghWndFrame,GWL_USERDATA); return newActionHandle(pFrameData->pActionsMap, ACTION_CHECK); } ActionHandle osCreateRadioAction() { FrameData *pFrameData = (FrameData *) GetWindowLong(ghWndFrame,GWL_USERDATA); return newActionHandle(pFrameData->pActionsMap, ACTION_RADIO); } ActionHandle osCreateDropDownAction(MenuHandle menu) { ActionHandle action; FrameData *pFrameData = (FrameData *) GetWindowLong(ghWndFrame,GWL_USERDATA); action = newActionHandle(pFrameData->pActionsMap, ACTION_DROPDOWN); action->menu = menu; return action; } void osSetActionRadioGroup(ActionHandle *handles) { ActionHandle *phandle, handle, child; if (!handles || *handles == NULL) return; phandle=handles; for (;;) { handle = *phandle; child = handle->nextInGroup; while (child->nextInGroup != handle) child = child->nextInGroup; child->nextInGroup = handle->nextInGroup; phandle++; if (*phandle) handle->nextInGroup = *phandle; else { handle->nextInGroup = *handles; break; } } } void osSetActionBitmap(ActionHandle action, BitmapHandle bitmap) { ToolHandle tool; FrameData *pFrameData; pFrameData = (FrameData *) GetWindowLong(ghWndFrame,GWL_USERDATA); action->bitmap = bitmap; tool = action->toolProxies; while (tool) { TBADDBITMAP tbab; TBBUTTONINFO tbbi; if (bitmap) { tbab.hInst = NULL; tbab.nID = (UINT) bitmap->hBitmap; tbbi.iImage = SendMessage(tool->hToolBar, TB_ADDBITMAP, 1, (LPARAM) &tbab); } else tbbi.iImage = I_IMAGENONE; tbbi.cbSize = sizeof(tbbi); tbbi.dwMask = TBIF_IMAGE; SendMessage(tool->hToolBar, TB_SETBUTTONINFO, action->id, (LPARAM) &tbbi); tool = tool->nextInAction; } RelayoutFrameBars(); } void osSetActionEnabled(ActionHandle action, BOOL enabled) { ToolHandle tool; action->enabled = enabled; tool = action->toolProxies; while (tool) { SendMessage(tool->hToolBar, TB_ENABLEBUTTON, action->id, (LPARAM) enabled); tool = tool->nextInAction; } } BOOL osGetActionEnabled(ActionHandle action) { return action->enabled; } void osSetActionTip(ActionHandle action, char *text) { action->tooltip = strdup(text); } char *osGetActionTip(ActionHandle action) { return strdup(action->tooltip); } void osSetActionText(ActionHandle action, char *text) { ToolHandle tool; action->title = strdup(text); tool = action->toolProxies; while (tool) { TBBUTTONINFO tbbi; tbbi.cbSize = sizeof(tbbi); tbbi.dwMask = TBIF_STYLE; tbbi.fsStyle = TBSTYLE_BUTTON; SendMessage(tool->hToolBar, TB_GETBUTTONINFO, action->id, (LPARAM) &tbbi); tbbi.dwMask = TBIF_TEXT | TBIF_STYLE; tbbi.fsStyle = (text && *text) ? (tbbi.fsStyle | BTNS_SHOWTEXT) : (tbbi.fsStyle & ~BTNS_SHOWTEXT); tbbi.pszText = text; tbbi.cchText = strlen(text); SendMessage(tool->hToolBar, TB_SETBUTTONINFO, action->id, (LPARAM) &tbbi); tool = tool->nextInAction; } RelayoutFrameBars(); } char *osGetActionText(ActionHandle action) { return strdup(action->title); } void osSetActionShortText(ActionHandle action, char *text) { action->short_title = (text && *text) ? strdup(text) : NULL; } char *osGetActionShortText(ActionHandle action) { return strdup(action->short_title); } void osSetActionChecked(ActionHandle action, BOOL checked) { ToolHandle tool; ActionHandle actionInGroup; actionInGroup = action; do { actionInGroup->checked = checked; tool = actionInGroup->toolProxies; while (tool) { int nState = SendMessage(tool->hToolBar, TB_GETSTATE, actionInGroup->id, 0); if (checked) nState = nState | TBSTATE_CHECKED; else nState = nState & ~TBSTATE_CHECKED; SendMessage(tool->hToolBar,TB_SETSTATE,actionInGroup->id,MAKELONG(nState, 0)); tool = tool->nextInAction; } actionInGroup = actionInGroup->nextInGroup; checked = FALSE; } while (actionInGroup != action); handleActionCommand(action); }; BOOL osGetActionChecked(ActionHandle action) { return action->checked; }; void osSetActionAccel(ActionHandle action, int key, unsigned int mods) { FrameData *pFrameData = (FrameData *) GetWindowLong(ghWndFrame,GWL_USERDATA); updateAccelTable(pFrameData->pActionsMap, action, key, mods); }; void osGetActionAccel(ActionHandle action, int *key, unsigned int *mods) { *key = action->key; *mods = action->keyMods; }; void osActivateAction(int id) { FrameData *pFrameData = (FrameData *) GetWindowLong(ghWndFrame,GWL_USERDATA); ActionHandle action = getActionHandle(pFrameData->pActionsMap, id); if (action) { switch (action->type) { case ACTION_NORMAL: handleActionCommand(action); break; case ACTION_CHECK: osSetActionChecked(action, !action->checked); break; case ACTION_RADIO: osSetActionChecked(action, TRUE); break; case ACTION_DROPDOWN: break; } } } void osDestroyAction(ActionHandle action) { FrameData *pFrameData = (FrameData *) GetWindowLong(ghWndFrame,GWL_USERDATA); deleteActionHandle(pFrameData->pActionsMap, action); } --- NEW FILE: ActionsMap.c --- #include "ActionsMap.h" #include "Window.h" #include "Internals.h" #include "Handlers_stub.h" ActionsMap *newActionsMap() { ActionsMap *pMap; pMap = (ActionsMap *) malloc(sizeof(ActionsMap)); if (!pMap) return NULL; pMap->nNextActionID=0; pMap->menus = NULL; pMap->popupMenus = NULL; pMap->pFreeList = NULL; pMap->pBlocks = NULL; pMap->nAccelCount = 0; pMap->hAccelTable = NULL; memset(pMap->HashTable, 0, sizeof(ActionHandle)*HASH_TABLE_SIZE); return pMap; } void deleteActionsMap(ActionsMap *pMap) { Block *p, *pNext; pMap->pFreeList = NULL; p = pMap->pBlocks; while (p != NULL) { pNext = p->pNext; free(p); p = pNext; } if (pMap->hAccelTable) DestroyAcceleratorTable(pMap->hAccelTable); free(pMap); } ActionHandle newActionHandle(ActionsMap *pMap, enum ACTION_TYPE type) { int i, nHash; ActionHandle action; // it doesn't exist, add a new Association if (pMap->pFreeList == NULL) { // add another block Block *p = (Block *) malloc(sizeof(Block) + HASH_BLOCK_SIZE * sizeof(struct ActionHandle)); if (!p) return NULL; p->pNext = pMap->pBlocks; pMap->pBlocks = p; // change head (adds in reverse order for simplicity) // chain them into free list action = (ActionHandle) (p+1); // free in reverse order to make it easier to debug action += HASH_BLOCK_SIZE - 1; for (i = HASH_BLOCK_SIZE-1; i >= 0; i--, action--) { action->next = pMap->pFreeList; pMap->pFreeList = action; } } action = pMap->pFreeList; pMap->pFreeList = action->next; action->id = ++pMap->nNextActionID; action->type = type; action->title = NULL; action->short_title = NULL; action->tooltip = NULL; action->bitmap = NULL; action->enabled = TRUE; action->checked = FALSE; action->key = 0; action->keyMods = 0; action->menu = NULL; action->menuProxies = NULL; action->toolProxies = NULL; // by default the action is in its own group action->nextInGroup = action; // put into hash table nHash = (action->id >> 4) % HASH_TABLE_SIZE; action->next = pMap->HashTable[nHash]; pMap->HashTable[nHash] = action; return action; } void deleteActionHandle(ActionsMap *pMap, ActionHandle action) { int nHash; ActionHandle child, *prev; handleActionDestroy(action); nHash = (action->id >> 4) % HASH_TABLE_SIZE; prev = &(pMap->HashTable[nHash]); child = pMap->HashTable[nHash]; while (child) { if (child == action) { *prev = action->next; break; } prev = &child->next; child = child->next; } action->next = pMap->pFreeList; pMap->pFreeList = action; free(action->title); free(action->short_title); free(action->tooltip); } MenuHandle newMenuHandle(ActionsMap *pMap, MenuHandle parent, int pos, MENU_TYPE type, ActionHandle action) { MenuHandle handle, child, *prev; handle = malloc(sizeof(struct MenuHandle)); handle->parent = parent; handle->children = NULL; handle->sibling = NULL; handle->type = type; handle->hMenu = NULL; handle->action = action; if (action) { // link the button to the chain handle->nextInAction = action->menuProxies; action->menuProxies = handle; } if (type != MENU_POPUP) { if (parent) { child = parent->children; prev = &parent->children; } else { child = pMap->menus; prev = &pMap->menus; } } else { child = pMap->popupMenus; prev = &pMap->popupMenus; } if (pos < 0) while (child) { prev = &child->sibling; child = child->sibling; } else while (child && pos > 0) { prev = &child->sibling; child = child->sibling; pos--; } handle->sibling = child; *prev = handle; return handle; } void deleteMenuHandle(ActionsMap *pMap, MenuHandle handle) { MenuHandle child, *prev; while (handle->children) deleteMenuHandle(pMap, handle->children); if (handle->type != MENU_POPUP) { if (handle->parent) { prev = &handle->parent->children; child = handle->parent->children; } else { prev = &pMap->menus; child = pMap->menus; } } else { prev = &pMap->popupMenus; child = pMap->popupMenus; } while (child != handle) { prev = &child->sibling; child = child->sibling; } *prev = handle->sibling; if (handle->action) { prev = &handle->action->menuProxies; child = handle->action->menuProxies; while (child != handle) { prev = &child->nextInAction; child = child->nextInAction; } *prev = handle->nextInAction; } } ActionHandle getActionHandle(ActionsMap *pMap, UINT id) { ActionHandle action; unsigned int nHash; nHash = (id >> 4) % HASH_TABLE_SIZE; for (action = pMap->HashTable[nHash]; action != NULL; action = action->next) { if (action->id == id) return action; } return NULL; } void updateAccelTable(ActionsMap *pMap, ActionHandle action, int key, int mods) { if ( action->key && !key) pMap->nAccelCount--; if (!action->key && key) pMap->nAccelCount++; action->key = key; action->keyMods = mods; if (pMap->hAccelTable) { DestroyAcceleratorTable(pMap->hAccelTable); pMap->hAccelTable = NULL; } }; HACCEL getAccelTableFromMap(ActionsMap *pMap) { int i,k; ActionHandle action; ACCEL *pAccel; if (pMap->hAccelTable) return pMap->hAccelTable; if (pMap->nAccelCount == 0) return NULL; pAccel = malloc(sizeof(ACCEL)*pMap->nAccelCount); if (!pAccel) return NULL; for (k = 0, i = 0; k < pMap->nAccelCount; i++) { action = pMap->HashTable[i]; while (action) { pAccel[k].cmd = action->id; if (action->key > 0 && action->key < 256) { pAccel[k].key = action->key; pAccel[k].fVirt = 0; k++; } else if (action->key > 256 && action->key < 512) { pAccel[k].key = action->key-256; pAccel[k].fVirt = FALT; k++; } else { pAccel[k].fVirt = (((action->keyMods & shiftBIT) ? FSHIFT : 0) | ((action->keyMods & ctrlBIT ) ? FCONTROL : 0) | ((action->keyMods & altBIT ) ? FALT : 0) | FVIRTKEY); switch (action->key) { case kbUp: pAccel[k++].key = VK_UP; break; case kbDown: pAccel[k++].key = VK_DOWN; break; case kbLeft: pAccel[k++].key = VK_LEFT; break; case kbRight: pAccel[k++].key = VK_RIGHT; break; case kbPgUp: pAccel[k++].key = VK_PRIOR; break; case kbPgDown: pAccel[k++].key = VK_NEXT; break; case kbEnd: pAccel[k++].key = VK_END; break; case kbBegin: pAccel[k++].key = VK_HOME; break; case kbBackSpace:pAccel[k++].key = VK_BACK; break; case kbDelete: pAccel[k++].key = VK_DELETE; break; case kbEnter: pAccel[k++].key = VK_RETURN; break; case kbEscape: pAccel[k++].key = VK_ESCAPE; break; case kbTab: pAccel[k++].key = VK_TAB; break; case kbHelp: pAccel[k++].key = VK_HELP; break; case kbF1: pAccel[k++].key = VK_F1; break; case kbF2: pAccel[k++].key = VK_F2; break; case kbF3: pAccel[k++].key = VK_F3; break; case kbF4: pAccel[k++].key = VK_F4; break; case kbF5: pAccel[k++].key = VK_F5; break; case kbF6: pAccel[k++].key = VK_F6; break; case kbF7: pAccel[k++].key = VK_F7; break; case kbF8: pAccel[k++].key = VK_F8; break; case kbF9: pAccel[k++].key = VK_F9; break; case kbF10: pAccel[k++].key = VK_F10; break; case kbF11: pAccel[k++].key = VK_F11; break; case kbF12: pAccel[k++].key = VK_F12; break; case kbClear: pAccel[k++].key = VK_CLEAR; break; } } action = action->next; } } pMap->hAccelTable = CreateAcceleratorTable(pAccel, pMap->nAccelCount); free(pAccel); return pMap->hAccelTable; }; int getMenuPos(ActionsMap *pMap, MenuHandle handle) { int pos; MenuHandle h; if (handle->type != MENU_POPUP) h = handle->parent ? handle->parent->children : pMap->menus; else h = pMap->popupMenus; pos = 0; while (h && h != handle) { pos++; h = h->sibling; } return pos; }; HMENU getParentHMENU(MenuHandle handle) { if (handle->type != MENU_POPUP) if (handle->parent == NULL) return GetMenu(ghWndFrame); else return handle->parent->hMenu; else return NULL; } int getChildrenCount(ActionsMap *pMap, MenuHandle handle) { int count; MenuHandle child; count = 0; child = handle ? handle->children : pMap->menus; while (child != NULL) { count++; child = child->sibling; } return count; } MenuHandle getNthChild(ActionsMap *pMap, MenuHandle handle, int index) { MenuHandle child; child = handle ? handle->children : pMap->menus; while (child != NULL && index > 0) { index--; child = child->sibling; } return child; } --- NEW FILE: ActionsMap.h --- #ifndef MENU_ITEMS_MAP_H #define MENU_ITEMS_MAP_H #include "Types.h" #define HASH_BLOCK_SIZE 10 #define HASH_TABLE_SIZE 17 enum MENU_TYPE { MENU_POPUP = 1 , MENU_SUBMENU = 2 , MENU_SEPARATOR = 4 , MENU_ITEM = 8 , MENU_CHECK_ITEM = 16 , MENU_RADIO_ITEM = 32 }; typedef enum MENU_TYPE MENU_TYPE; enum ACTION_TYPE { ACTION_NORMAL, ACTION_CHECK, ACTION_RADIO, ACTION_DROPDOWN }; struct ActionHandle { // Unique identity UINT id; // chain; ActionHandle next; // next action in the hash table ActionHandle nextInGroup; // next action in the radio group // Attributes enum ACTION_TYPE type; // the action type char *title; char *short_title; char *tooltip; BitmapHandle bitmap; BOOL enabled : 1; // TRUE if the action is enabled BOOL checked : 1; // TRUE if the action is checked MenuHandle menu; // Accelerator int key, keyMods; // the collection of all proxies (menu items or toolbar buttons) associated to this action MenuHandle menuProxies; ToolHandle toolProxies; }; struct ToolHandle { HWND hToolBar; // toolbar handle ToolHandle nextInAction; // the link to the next tool with the same action ActionHandle action; // the associated action }; struct MenuHandle { struct MenuHandle *parent; struct MenuHandle *children; struct MenuHandle *sibling; HMENU hMenu; MENU_TYPE type; MenuHandle nextInAction; // the link to the next menu item with the same action ActionHandle action; // the associated action }; typedef struct Block_tag { struct Block_tag *pNext; } Block; typedef struct { int nNextActionID; struct MenuHandle *menus; struct MenuHandle *popupMenus; Block* pBlocks; ActionHandle pFreeList; ActionHandle HashTable[HASH_TABLE_SIZE]; HACCEL hAccelTable; int nAccelCount; } ActionsMap; ActionsMap *newActionsMap(); void deleteActionsMap(ActionsMap *pMap); ActionHandle newActionHandle(ActionsMap *pMap, enum ACTION_TYPE type); void deleteActionHandle(ActionsMap *pMap, ActionHandle handle); ActionHandle getActionHandle(ActionsMap *pMap, UINT id); void updateAccelTable(ActionsMap *pMap, ActionHandle item, int key, int mods); HACCEL getAccelTableFromMap(ActionsMap *pMap); MenuHandle newMenuHandle(ActionsMap *pMap, MenuHandle parent, int pos, MENU_TYPE type, ActionHandle action); void deleteMenuHandle(ActionsMap *pMap, MenuHandle handle); int getMenuPos(ActionsMap *pMap, MenuHandle handle); HMENU getParentHMENU(MenuHandle handle); int getChildrenCount(ActionsMap *pMap, MenuHandle handle); MenuHandle getNthChild(ActionsMap *pMap, MenuHandle handle, int index); #endif Index: DockBar.c =================================================================== RCS file: /cvsroot/htoolkit/port/src/cbits/Win32/DockBar.c,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** DockBar.c 7 May 2004 14:44:50 -0000 1.10 --- DockBar.c 14 May 2004 23:01:39 -0000 1.11 *************** *** 1,5 **** #include "Types.h" - #include "Internals.h" #include "DockBar.h" #include "Handlers_stub.h" --- 1,6 ---- #include "Types.h" #include "DockBar.h" + #include "Action.h" + #include "Internals.h" #include "Handlers_stub.h" *************** *** 124,132 **** } - extern void osActivateToolItem(ToolHandle toolButton); - LRESULT CALLBACK HDockBarFunction(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { DockBarData *pData = (DockBarData *) GetWindowLong(hWnd, GWL_USERDATA); switch (uMsg) --- 125,132 ---- } LRESULT CALLBACK HDockBarFunction(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { DockBarData *pData = (DockBarData *) GetWindowLong(hWnd, GWL_USERDATA); + FrameData *pFrameData = (FrameData *) GetWindowLong(ghWndFrame,GWL_USERDATA); switch (uMsg) *************** *** 174,208 **** return 0; case WM_COMMAND: ! { ! ToolHandle handle; ! TBBUTTONINFO tbbi; ! HWND hToolBar = (HWND) lParam; ! ! tbbi.cbSize = sizeof(tbbi); ! tbbi.dwMask = TBIF_LPARAM; ! tbbi.lParam = 0; ! SendMessage(hToolBar, TB_GETBUTTONINFO, LOWORD(wParam), (LPARAM) &tbbi); ! ! handle = (ToolHandle) tbbi.lParam; ! if (handle) osActivateToolItem(handle); ! } break; case WM_NOTIFY: { ! ToolHandle handle; ! TBBUTTONINFO tbbi; ! LPNMTOOLBAR lpNMToolBar = (LPNMTOOLBAR) lParam; ! if (lpNMToolBar->hdr.code == TBN_DROPDOWN) { ! tbbi.cbSize = sizeof(tbbi); ! tbbi.dwMask = TBIF_LPARAM; ! tbbi.lParam = 0; ! SendMessage(lpNMToolBar->hdr.hwndFrom, TB_GETBUTTONINFO, lpNMToolBar->iItem, (LPARAM) &tbbi); ! handle = (ToolHandle) tbbi.lParam; ! if (handle) ! osActivateToolItem(handle); } } break; --- 174,210 ---- return 0; case WM_COMMAND: ! osActivateAction(LOWORD(wParam)); break; case WM_NOTIFY: { ! LPNMHDR lpNMHdr = (LPNMHDR) lParam; ! if (lpNMHdr->code == TBN_DROPDOWN) { ! LPNMTOOLBAR lpNMToolBar = (LPNMTOOLBAR) lpNMHdr; ! ActionHandle action = getActionHandle(pFrameData->pActionsMap, lpNMToolBar->iItem); ! if (action && action->menu) ! { ! RECT rect; ! int nIndex; ! ! memset(&rect, 0, sizeof(rect)); ! nIndex = SendMessage(lpNMHdr->hwndFrom, TB_COMMANDTOINDEX, action->id, 0); ! SendMessage(lpNMHdr->hwndFrom, TB_GETITEMRECT, nIndex, (LPARAM)&rect); ! MapWindowPoints(lpNMHdr->hwndFrom, NULL, (LPPOINT) &rect, 2); ! ! TrackPopupMenu(action->menu->hMenu, TPM_LEFTALIGN | TPM_TOPALIGN, rect.left, rect.bottom, 0, ghWndFrame, NULL); ! } } + else + if (lpNMHdr->code == TTN_NEEDTEXT) + { + LPNMTTDISPINFO lpNMTTDispInfo = (LPNMTTDISPINFO) lpNMHdr; + + ActionHandle action = getActionHandle(pFrameData->pActionsMap, lpNMHdr->idFrom); + if (action) + lpNMTTDispInfo->lpszText = action->tooltip; + } } break; Index: Frame.c =================================================================== RCS file: /cvsroot/htoolkit/port/src/cbits/Win32/Frame.c,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** Frame.c 8 May 2004 09:46:00 -0000 1.26 --- Frame.c 14 May 2004 23:01:39 -0000 1.27 *************** *** 1,8 **** #include "Types.h" #include "Window.h" - #include "Menu.h" #include "DockBar.h" #include "StatusBar.h" ! #include "MenuHandlesMap.h" #include "Canvas.h" #include "ConfigKey.h" --- 1,8 ---- #include "Types.h" #include "Window.h" #include "DockBar.h" #include "StatusBar.h" ! #include "Action.h" ! #include "ActionsMap.h" #include "Canvas.h" #include "ConfigKey.h" *************** *** 14,24 **** #define Spacing 1 ! void DrawMenuText(HDC hdc, LPTSTR lpchText, LPRECT lpRect) { ! int n = 0; ! while (lpchText[n] && lpchText[n] != '\t') n++; ! DrawText(hdc, lpchText, n, lpRect, DT_SINGLELINE|DT_VCENTER|DT_LEFT); ! DrawText(hdc, lpchText+n+1, -1, lpRect, DT_SINGLELINE|DT_VCENTER|DT_RIGHT); } --- 14,94 ---- #define Spacing 1 ! static void BuildAccelString(ActionHandle action, char *text) { ! *text = 0; ! if (!action || !action->key) ! return; ! ! if (action->keyMods & altBIT ) strcat(text, "Alt+"); ! if (action->keyMods & ctrlBIT ) strcat(text, "Ctrl+"); ! if (action->keyMods & shiftBIT) strcat(text, "Shift+"); ! ! switch (action->key) ! { ! case kbBackSpace: strcat(text, "BackSpace"); break; ! case kbTab: strcat(text, "Tab"); break; ! case kbEnter: strcat(text, "Enter"); break; ! case kbEscape: strcat(text, "Esc"); break; ! case kbBegin: strcat(text, "Home"); break; ! case kbClear: strcat(text, "Clear"); break; ! case kbDelete: strcat(text, "Del"); break; ! case kbDown: strcat(text, "Down"); break; ! case kbEnd: strcat(text, "End"); break; ! case kbF1: strcat(text, "F1"); break; ! case kbF2: strcat(text, "F2"); break; ! case kbF3: strcat(text, "F3"); break; ! case kbF4: strcat(text, "F4"); break; ! case kbF5: strcat(text, "F5"); break; ! case kbF6: strcat(text, "F6"); break; ! case kbF7: strcat(text, "F7"); break; ! case kbF8: strcat(text, "F8"); break; ! case kbF9: strcat(text, "F9"); break; ! case kbF10: strcat(text, "F10"); break; ! case kbF11: strcat(text, "F11"); break; ! case kbF12: strcat(text, "F12"); break; ! case kbF13: strcat(text, "F13"); break; ! case kbF14: strcat(text, "F14"); break; ! case kbF15: strcat(text, "F15"); break; ! case kbHelp: strcat(text, "Help"); break; ! case kbLeft: strcat(text, "Left"); break; ! case kbPgDown: strcat(text, "PgDown"); break; ! case kbPgUp: strcat(text, "PgUp"); break; ! case kbRight: strcat(text, "Right"); break; ! case kbUp: strcat(text, "Up"); break; ! case ' ': strcat(text, "Space"); break; ! default: ! { ! char s[2]; ! ! if (action->key >= 256) ! { ! strcat(text,"Alt+"); ! s[0] = action->key-256; ! } ! ! if (iscntrl(action->key)) ! { ! s[0] = '@'+action->key; ! strcat(text,"Ctrl+"); ! } ! else ! if (isupper(action->key)) strcat(text,"Shift+"); ! else s[0] = toupper(action->key); ! ! s[1] = 0; ! strcat(text, s); ! } ! break; ! } ! } ! ! static void DrawMenuText(HDC hdc, ActionHandle action, LPRECT lpRect) ! { ! char szAccText[32]; ! BuildAccelString(action, szAccText); ! ! DrawText(hdc, action->title, -1, lpRect, DT_SINGLELINE|DT_VCENTER|DT_LEFT); ! DrawText(hdc, szAccText, -1, lpRect, DT_SINGLELINE|DT_VCENTER|DT_RIGHT); } *************** *** 59,66 **** LRESULT CALLBACK HFrameSharedFunction(int DocumentInterface, HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { ! int pos; ! HMENU hParent; ! MENUITEMINFO mii; ! MenuHandle handle; FrameData *pData = (FrameData *) GetWindowLong(hWnd,GWL_USERDATA); --- 129,133 ---- LRESULT CALLBACK HFrameSharedFunction(int DocumentInterface, HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { ! ActionHandle action; FrameData *pData = (FrameData *) GetWindowLong(hWnd,GWL_USERDATA); *************** *** 72,80 **** return 0; case WM_DESTROY: - notifyAllHandlesForDestroy(pData->pMenuHandlesMap); handleProcessDestroy(); free(pData->lpszAppName); free(pData->lpszAppVersion); ! deleteMenuHandlesMap(pData->pMenuHandlesMap); // clear StatusBar context stack --- 139,146 ---- return 0; case WM_DESTROY: handleProcessDestroy(); free(pData->lpszAppName); free(pData->lpszAppVersion); ! deleteActionsMap(pData->pActionsMap); // clear StatusBar context stack *************** *** 115,119 **** pData->lpszAppName = NULL; pData->lpszAppVersion = NULL; ! pData->pMenuHandlesMap = newMenuHandlesMap(); pData->hLeftBar = CreateWindow("HDOCKBAR", --- 181,185 ---- pData->lpszAppName = NULL; pData->lpszAppVersion = NULL; ! pData->pActionsMap = newActionsMap(); pData->hLeftBar = CreateWindow("HDOCKBAR", *************** *** 171,184 **** case WM_COMMAND: if (lParam == 0) ! { ! handle = getMenuHandle(pData->pMenuHandlesMap, (UINT) LOWORD(wParam)); ! if (handle) ! { ! if (handle->type & (MENU_RADIO_ITEM | MENU_CHECK_ITEM)) ! osSetMenuItemChecked(handle, !osGetMenuItemChecked(handle)); ! else ! handleMenuCommand(handle); ! } ! } break; case WM_MEASUREITEM: --- 237,241 ---- case WM_COMMAND: if (lParam == 0) ! osActivateAction(LOWORD(wParam)); break; case WM_MEASUREITEM: *************** *** 188,201 **** if (lpMIS->CtlType == ODT_MENU) { ! handle = getMenuHandle(pData->pMenuHandlesMap, lpMIS->itemID); ! if (handle && handle->bitmap) { NONCLIENTMETRICS ncm; HFONT hFont, hOldFont; ! RECT rc; HDC hDC; long lDims; WORD wCheckWidth, wCheckHeight; hDC = GetDC(hWnd); --- 245,261 ---- if (lpMIS->CtlType == ODT_MENU) { ! action = getActionHandle(pData->pActionsMap, lpMIS->itemID); ! if (action) { NONCLIENTMETRICS ncm; HFONT hFont, hOldFont; ! RECT rc[2]; HDC hDC; long lDims; WORD wCheckWidth, wCheckHeight; + char szAccText[32]; + + BuildAccelString(action, szAccText); hDC = GetDC(hWnd); *************** *** 213,248 **** // Draw out menu item caption - text. ! pos = getMenuPos(pData->pMenuHandlesMap, handle); ! hParent = getParentHMENU(handle); ! ! ZeroMemory(&mii,sizeof(mii)); ! mii.cbSize = sizeof(mii); ! mii.fMask = MIIM_STRING; ! mii.fType = MFT_STRING; ! mii.dwTypeData = NULL; ! mii.cch = 0; ! GetMenuItemInfo(hParent, pos, TRUE, &mii); ! mii.cch++; ! mii.dwTypeData = malloc(mii.cch); ! ! if (mii.dwTypeData) ! { ! GetMenuItemInfo(hParent, pos, TRUE, &mii); ! ! ZeroMemory(&rc,sizeof(rc)); ! DrawText(hDC,mii.dwTypeData,mii.cch,&rc,DT_SINGLELINE|DT_VCENTER|DT_LEFT|DT_CALCRECT); ! lDims = GetMenuCheckMarkDimensions(); ! wCheckWidth = (WORD)(LOWORD(lDims)+Spacing); ! wCheckHeight = (WORD)(HIWORD(lDims)+Spacing); ! wCheckWidth = (WORD)max(handle->bitmap->destsize.cx, wCheckWidth); ! wCheckHeight = (WORD)max(handle->bitmap->destsize.cy, wCheckHeight); ! lpMIS->itemWidth = (rc.right-rc.left) + wCheckWidth + (Spacing*3); // Text width ! lpMIS->itemHeight = max((rc.bottom-rc.top),wCheckHeight) + (Spacing*2); // Text Height } ! free(mii.dwTypeData); // Clean up resources --- 273,296 ---- // Draw out menu item caption - text. ! ZeroMemory(&rc,sizeof(rc)); ! DrawText(hDC,action->title,-1,&rc[0],DT_SINGLELINE|DT_VCENTER|DT_LEFT|DT_CALCRECT); ! DrawText(hDC,szAccText, -1,&rc[1],DT_SINGLELINE|DT_VCENTER|DT_LEFT|DT_CALCRECT); ! rc[0].right += rc[1].right-rc[1].left; ! rc[0].bottom = max(rc[0].bottom, rc[1].bottom); ! lDims = GetMenuCheckMarkDimensions(); ! wCheckWidth = (WORD)(LOWORD(lDims)+Spacing); ! wCheckHeight = (WORD)(HIWORD(lDims)+Spacing); ! if (action->bitmap) ! { ! wCheckWidth = (WORD)max(action->bitmap->destsize.cx, wCheckWidth); ! wCheckHeight = (WORD)max(action->bitmap->destsize.cy, wCheckHeight); } ! lpMIS->itemWidth = (rc[0].right-rc[0].left) + wCheckWidth + (Spacing*3); // Text width ! lpMIS->itemHeight = max((rc[0].bottom-rc[0].top),wCheckHeight) + (Spacing*2); // Text Height ! // Clean up resources *************** *** 260,266 **** if (lpDIS->CtlType == ODT_MENU) { ! handle = getMenuHandle(pData->pMenuHandlesMap, lpDIS->itemID); ! if (handle && handle->bitmap) { long lDims; --- 308,314 ---- if (lpDIS->CtlType == ODT_MENU) { ! action = getActionHandle(pData->pActionsMap, lpDIS->itemID); ! if (action) { long lDims; *************** *** 280,285 **** wCheckHeight = HIWORD(lDims); ! wWidth = max(handle->bitmap->destsize.cx, wCheckWidth) + (Spacing*2); ! wHeight = max(handle->bitmap->destsize.cy, wCheckHeight) + (Spacing*2); rcFrame.left = lpDIS->rcItem.left; --- 328,336 ---- wCheckHeight = HIWORD(lDims); ! wWidth = (action->bitmap) ? action->bitmap->destsize.cx : 0; ! wHeight = (action->bitmap) ? action->bitmap->destsize.cy : 0; ! ! wWidth = max(wWidth, wCheckWidth) + (Spacing*2); ! wHeight = max(wHeight, wCheckHeight) + (Spacing*2); rcFrame.left = lpDIS->rcItem.left; *************** *** 323,380 **** // Draw out the bitmap associated with the menu item. ! pt.x = rcFrame.left+(((rcFrame.right-rcFrame.left) - handle->bitmap->destsize.cx)/2); ! pt.y = rcFrame.top +(((rcFrame.bottom-rcFrame.top) - handle->bitmap->destsize.cy)/2); ! osDrawBitmap(pt.x, pt.y, handle->bitmap, &canvas); ! // Draw bounding frame ! if (lpDIS->itemState & ODS_SELECTED) DrawEdge(lpDIS->hDC,&rcFrame,BDR_RAISEDINNER,BF_RECT); rc.left+=Spacing; ! // Draw out menu item caption - text. ! pos = getMenuPos(pData->pMenuHandlesMap, handle); ! hParent = getParentHMENU(handle); ! ! ZeroMemory(&mii,sizeof(mii)); ! mii.cbSize = sizeof(mii); ! mii.fMask = MIIM_STRING; ! mii.fType = MFT_STRING; ! mii.dwTypeData = NULL; ! mii.cch = 0; ! GetMenuItemInfo(hParent, pos, TRUE, &mii); ! mii.cch++; ! mii.dwTypeData = malloc(mii.cch); ! ! if (mii.dwTypeData) { ! GetMenuItemInfo(hParent, pos, TRUE, &mii); ! ! if (lpDIS->itemState & ODS_GRAYED) { ! // This will give it a disable text look ! if (!(lpDIS->itemState & ODS_SELECTED)) ! { ! SetTextColor(lpDIS->hDC, GetSysColor(COLOR_3DHILIGHT)); ! OffsetRect(&rc,1,1); ! DrawMenuText(lpDIS->hDC,mii.dwTypeData,&rc); ! OffsetRect(&rc,-1,-1); ! ! SetTextColor(lpDIS->hDC,GetSysColor(COLOR_GRAYTEXT)); ! DrawMenuText(lpDIS->hDC,mii.dwTypeData,&rc); ! } ! else ! { ! COLORREF crGray = (GetSysColor(COLOR_GRAYTEXT) + RGB(64,64,64)); ! SetTextColor(lpDIS->hDC,crGray); ! DrawMenuText(lpDIS->hDC,mii.dwTypeData,&rc); ! } } else ! DrawMenuText(lpDIS->hDC,mii.dwTypeData,&rc); } - free(mii.dwTypeData); RestoreDC(lpDIS->hDC,nIndexDC); --- 374,411 ---- // Draw out the bitmap associated with the menu item. ! if (action->bitmap) ! { ! pt.x = rcFrame.left+(((rcFrame.right-rcFrame.left) - action->bitmap->destsize.cx)/2); ! pt.y = rcFrame.top +(((rcFrame.bottom-rcFrame.top) - action->bitmap->destsize.cy)/2); ! osDrawBitmap(pt.x, pt.y, action->bitmap, &canvas); ! ! // Draw bounding frame ! if (lpDIS->itemState & ODS_SELECTED) DrawEdge(lpDIS->hDC,&rcFrame,BDR_RAISEDINNER,BF_RECT); + } rc.left+=Spacing; ! if (lpDIS->itemState & ODS_GRAYED) { ! // This will give it a disable text look ! if (!(lpDIS->itemState & ODS_SELECTED)) { ! SetTextColor(lpDIS->hDC, GetSysColor(COLOR_3DHILIGHT)); ! OffsetRect(&rc,1,1); ! DrawMenuText(lpDIS->hDC,action,&rc); ! OffsetRect(&rc,-1,-1); ! SetTextColor(lpDIS->hDC,GetSysColor(COLOR_GRAYTEXT)); } else ! { ! COLORREF crGray = (GetSysColor(COLOR_GRAYTEXT) + RGB(64,64,64)); ! SetTextColor(lpDIS->hDC,crGray); ! } } + DrawMenuText(lpDIS->hDC,action,&rc); RestoreDC(lpDIS->hDC,nIndexDC); *************** *** 383,411 **** } return TRUE; - case WM_INITMENUPOPUP: - { - HMENU hMenu; - int i, nCount; - - hMenu = (HMENU) wParam; - nCount = GetMenuItemCount((HMENU) wParam); - for (i = 0; i < nCount; i++) - { - mii.cbSize = sizeof(mii); - mii.fMask = MIIM_ID; - GetMenuItemInfo(hMenu, i, TRUE, &mii); - - handle = getMenuHandle(pData->pMenuHandlesMap, (UINT) mii.wID); - if (handle) handleMenuUpdate(handle); - } - } - break; case WM_MENUSELECT: if ((HIWORD(wParam) & MF_POPUP) == 0) { ! handle = getMenuHandle(pData->pMenuHandlesMap, (UINT) LOWORD(wParam)); ! if (handle) { ! SetWindowText(pData->hStatusBar, handle->tip ? handle->tip : ""); } } --- 414,424 ---- } return TRUE; case WM_MENUSELECT: if ((HIWORD(wParam) & MF_POPUP) == 0) { ! action = getActionHandle(pData->pActionsMap, (UINT) LOWORD(wParam)); ! if (action) { ! SetWindowText(pData->hStatusBar, action->tooltip ? action->tooltip : ""); } } Index: Internals.h =================================================================== RCS file: /cvsroot/htoolkit/port/src/cbits/Win32/Internals.h,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** Internals.h 7 May 2004 14:23:48 -0000 1.21 --- Internals.h 14 May 2004 23:01:39 -0000 1.22 *************** *** 4,8 **** #include <config.h> ! #include "MenuHandlesMap.h" extern BOOL gInKey; --- 4,8 ---- #include <config.h> ! #include "ActionsMap.h" extern BOOL gInKey; *************** *** 29,33 **** LPSTR lpszAppName; LPSTR lpszAppVersion; ! MenuHandlesMap *pMenuHandlesMap; HWND hLeftBar, hTopBar, hRightBar, hBottomBar; --- 29,33 ---- LPSTR lpszAppName; LPSTR lpszAppVersion; ! ActionsMap *pActionsMap; HWND hLeftBar, hTopBar, hRightBar, hBottomBar; *************** *** 62,66 **** } WindowData; - extern void rfree(void *ptr); extern void *rmalloc(unsigned long bytes); --- 62,65 ---- *************** *** 75,77 **** --- 74,78 ---- void RestoreWindowState(HWND hWnd, int nShow); + void osActivateAction(int id); + #endif Index: Menu.c =================================================================== RCS file: /cvsroot/htoolkit/port/src/cbits/Win32/Menu.c,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** Menu.c 15 Nov 2003 10:31:49 -0000 1.19 --- Menu.c 14 May 2004 23:01:39 -0000 1.20 *************** *** 12,16 **** return ret; \ } ! #define CHECK_MENU_TYPE_V(handle,mask) \ if (((handle ? handle->type : MENU_SUBMENU) & (mask)) == 0) \ --- 12,16 ---- return ret; \ } ! #define CHECK_MENU_TYPE_V(handle,mask) \ if (((handle ? handle->type : MENU_SUBMENU) & (mask)) == 0) \ *************** *** 20,94 **** } - static void AddAccelString(int nKeyCode, int mods, char *text) - { - if (!nKeyCode) - return; - - strcat(text, "\t"); - - if (mods & altBIT ) strcat(text, "Alt+"); - if (mods & ctrlBIT ) strcat(text, "Ctrl+"); - if (mods & shiftBIT) strcat(text, "Shift+"); - - switch (nKeyCode) - { - case kbBackSpace: strcat(text, "BackSpace"); break; - case kbTab: strcat(text, "Tab"); break; - case kbEnter: strcat(text, "Enter"); break; - case kbEscape: strcat(text, "Esc"); break; - case kbBegin: strcat(text, "Home"); break; - case kbClear: strcat(text, "Clear"); break; - case kbDelete: strcat(text, "Del"); break; - case kbDown: strcat(text, "Down"); break; - case kbEnd: strcat(text, "End"); break; - case kbF1: strcat(text, "F1"); break; - case kbF2: strcat(text, "F2"); break; - case kbF3: strcat(text, "F3"); break; - case kbF4: strcat(text, "F4"); break; - case kbF5: strcat(text, "F5"); break; - case kbF6: strcat(text, "F6"); break; - case kbF7: strcat(text, "F7"); break; - case kbF8: strcat(text, "F8"); break; - case kbF9: strcat(text, "F9"); break; - case kbF10: strcat(text, "F10"); break; - case kbF11: strcat(text, "F11"); break; - case kbF12: strcat(text, "F12"); break; - case kbF13: strcat(text, "F13"); break; - case kbF14: strcat(text, "F14"); break; - case kbF15: strcat(text, "F15"); break; - case kbHelp: strcat(text, "Help"); break; - case kbLeft: strcat(text, "Left"); break; - case kbPgDown: strcat(text, "PgDown"); break; - case kbPgUp: strcat(text, "PgUp"); break; - case kbRight: strcat(text, "Right"); break; - case kbUp: strcat(text, "Up"); break; - case ' ': strcat(text, "Space"); break; - default: - { - char s[2]; - - if (nKeyCode >= 256) - { - strcat(text,"Alt+"); - nKeyCode -= 256; - } - - if (iscntrl(nKeyCode)) - { - nKeyCode += '@'; - strcat(text,"Ctrl+"); - } - else - if (isupper(nKeyCode)) strcat(text,"Shift+"); - else nKeyCode = toupper(nKeyCode); - - s[0] = (char) nKeyCode; - s[1] = 0; - strcat(text, s); - } - break; - } - } - static void updateMenuBar(MenuHandle parent) { --- 20,23 ---- *************** *** 101,110 **** MenuHandle osCreatePopupMenu() ! { MenuHandle handle; FrameData *pFrameData; ! pFrameData = (FrameData *) GetWindowLong(ghWndFrame,GWL_USERDATA); ! handle = newMenuHandle(pFrameData->pMenuHandlesMap, NULL, MENU_POPUP, -1); if (handle) --- 30,39 ---- MenuHandle osCreatePopupMenu() ! { MenuHandle handle; FrameData *pFrameData; ! pFrameData = (FrameData *) GetWindowLong(ghWndFrame,GWL_USERDATA); ! handle = newMenuHandle(pFrameData->pActionsMap, NULL, -1, MENU_POPUP, NULL); if (handle) *************** *** 117,124 **** { POINT pos; - int i, nCount; - MenuHandle handle; - MENUITEMINFO mii; - FrameData *pData = (FrameData *) GetWindowLong(ghWndFrame,GWL_USERDATA); pos.x = x; --- 46,49 ---- *************** *** 126,158 **** ClientToScreen(hWnd, &pos); - nCount = GetMenuItemCount(menu->hMenu); - for (i = 0; i < nCount; i++) - { - mii.cbSize = sizeof(mii); - mii.fMask = MIIM_ID; - GetMenuItemInfo(menu->hMenu, i, TRUE, &mii); - - handle = getMenuHandle(pData->pMenuHandlesMap, (UINT) mii.wID); - if (handle) handleMenuUpdate(handle); - } - TrackPopupMenu(menu->hMenu, TPM_LEFTALIGN | TPM_TOPALIGN, pos.x, pos.y, 0, ghWndFrame, NULL); } MenuHandle osInsertMenu(MenuHandle parent, int pos) ! { MenuHandle handle; FrameData *pFrameData; ! CHECK_MENU_TYPE(parent, MENU_SUBMENU | MENU_POPUP, NULL); ! pFrameData = (FrameData *) GetWindowLong(ghWndFrame,GWL_USERDATA); ! handle = newMenuHandle(pFrameData->pMenuHandlesMap, parent, MENU_SUBMENU, pos); ! if (handle) { handle->hMenu = CreateMenu(); ! InsertMenu(getParentHMENU(handle),getMenuPos(pFrameData->pMenuHandlesMap, handle),MF_BYPOSITION | MF_POPUP,(UINT)handle->hMenu,""); updateMenuBar(parent); --- 51,72 ---- ClientToScreen(hWnd, &pos); TrackPopupMenu(menu->hMenu, TPM_LEFTALIGN | TPM_TOPALIGN, pos.x, pos.y, 0, ghWndFrame, NULL); } MenuHandle osInsertMenu(MenuHandle parent, int pos) ! { MenuHandle handle; FrameData *pFrameData; ! CHECK_MENU_TYPE(parent, MENU_SUBMENU | MENU_POPUP, NULL); ! pFrameData = (FrameData *) GetWindowLong(ghWndFrame,GWL_USERDATA); ! handle = newMenuHandle(pFrameData->pActionsMap, parent, pos, MENU_SUBMENU, NULL); ! if (handle) { handle->hMenu = CreateMenu(); ! InsertMenu(getParentHMENU(handle),getMenuPos(pFrameData->pActionsMap, handle),MF_BYPOSITION | MF_POPUP,(UINT)handle->hMenu,""); updateMenuBar(parent); *************** *** 162,272 **** }; ! MenuHandle osInsertMenuItem(MenuHandle parent, int pos) { MenuHandle handle; FrameData *pFrameData; - - CHECK_MENU_TYPE(parent, MENU_SUBMENU | MENU_POPUP, NULL); - - pFrameData = (FrameData *) GetWindowLong(ghWndFrame,GWL_USERDATA); - handle = newMenuHandle(pFrameData->pMenuHandlesMap, parent, MENU_ITEM, pos); - - if (handle) - { - InsertMenu(getParentHMENU(handle),getMenuPos(pFrameData->pMenuHandlesMap, handle),MF_BYPOSITION | MF_STRING,handle->id,""); - updateMenuBar(parent); - } - - return handle; - }; - MenuHandle osInsertMenuCheckItem(MenuHandle parent, int pos) - { - MenuHandle handle; - FrameData *pFrameData; - CHECK_MENU_TYPE(parent, MENU_SUBMENU | MENU_POPUP, NULL); ! pFrameData = (FrameData *) GetWindowLong(ghWndFrame,GWL_USERDATA); ! handle = newMenuHandle(pFrameData->pMenuHandlesMap, parent, MENU_CHECK_ITEM, pos); ! ! if (handle) { ! InsertMenu(getParentHMENU(handle),getMenuPos(pFrameData->pMenuHandlesMap, handle),MF_BYPOSITION | MF_STRING,handle->id,""); ! updateMenuBar(parent); } ! return handle; }; MenuHandle osInsertMenuSeparatorItem(MenuHandle parent, int pos) { MenuHandle handle; FrameData *pFrameData; - - CHECK_MENU_TYPE(parent, MENU_SUBMENU | MENU_POPUP, NULL); - - pFrameData = (FrameData *) GetWindowLong(ghWndFrame,GWL_USERDATA); - handle = newMenuHandle(pFrameData->pMenuHandlesMap, parent, MENU_SEPARATOR, pos); - - if (handle) - { - InsertMenu(getParentHMENU(handle),getMenuPos(pFrameData->pMenuHandlesMap, handle),MF_BYPOSITION | MF_SEPARATOR,0,NULL); - updateMenuBar(parent); - } - - return handle; - } - MenuHandle osInsertMenuRadioItem(MenuHandle parent, int pos) - { - MenuHandle handle; - FrameData *pFrameData; - MENUITEMINFO mii; - CHECK_MENU_TYPE(parent, MENU_SUBMENU | MENU_POPUP, NULL); pFrameData = (FrameData *) GetWindowLong(ghWndFrame,GWL_USERDATA); ! handle = newMenuHandle(pFrameData->pMenuHandlesMap, parent, MENU_RADIO_ITEM, pos); if (handle) { ! mii.cbSize = sizeof(mii); ! mii.fMask = MIIM_ID | MIIM_STATE | MIIM_TYPE; ! mii.wID = handle->id; ! mii.fState = MFS_ENABLED; ! mii.fType = MFT_RADIOCHECK | MFT_STRING; ! mii.dwTypeData = ""; ! mii.cch = 0; ! InsertMenuItem(getParentHMENU(handle),getMenuPos(pFrameData->pMenuHandlesMap, handle),TRUE,&mii); updateMenuBar(parent); } - return handle; - }; - - void osSetMenuRadioGroup(MenuHandle *handles) - { - MenuHandle child, handle, *phandle; - - if (!(handles && *handles)) - return; ! phandle=handles; ! for (;;) ! { ! handle = *phandle; ! ! child = handle->nextInGroup; ! while (child->nextInGroup != handle) ! child = child->nextInGroup; ! child->nextInGroup = handle->nextInGroup; ! ! phandle++; ! if (*phandle) ! handle->nextInGroup = *phandle; ! else ! { ! handle->nextInGroup = *handles; ! break; ! } ! } } --- 76,139 ---- }; ! MenuHandle osInsertMenuItem(ActionHandle action, MenuHandle parent, int pos) { + MENUITEMINFO mii; MenuHandle handle; FrameData *pFrameData; CHECK_MENU_TYPE(parent, MENU_SUBMENU | MENU_POPUP, NULL); ! pFrameData = (FrameData *) GetWindowLong(ghWndFrame,GWL_USERDATA); ! ! mii.cbSize = sizeof(mii); ! mii.fMask = MIIM_ID | MIIM_STATE | MIIM_TYPE; ! mii.wID = action->id; ! mii.fState = action->enabled ? MFS_ENABLED : MFS_DISABLED; ! mii.fType = MFT_OWNERDRAW; ! ! handle = NULL; ! switch (action->type) { ! case ACTION_NORMAL: ! handle = newMenuHandle(pFrameData->pActionsMap, parent, pos, MENU_ITEM, action); ! break; ! case ACTION_CHECK: ! handle = newMenuHandle(pFrameData->pActionsMap, parent, pos, MENU_CHECK_ITEM, action); ! break; ! case ACTION_RADIO: ! handle = newMenuHandle(pFrameData->pActionsMap, parent, pos, MENU_RADIO_ITEM, action); ! mii.fType |= MFT_RADIOCHECK; ! break; ! case ACTION_DROPDOWN: ! handle = newMenuHandle(pFrameData->pActionsMap, parent, pos, MENU_SUBMENU, action); ! mii.fMask |= MIIM_SUBMENU; ! mii.hSubMenu = action->menu->hMenu; ! break; } ! ! InsertMenuItem(getParentHMENU(handle),getMenuPos(pFrameData->pActionsMap, handle),TRUE,&mii); ! ! updateMenuBar(parent); return handle; }; + MenuHandle osInsertMenuSeparatorItem(MenuHandle parent, int pos) { MenuHandle handle; FrameData *pFrameData; CHECK_MENU_TYPE(parent, MENU_SUBMENU | MENU_POPUP, NULL); + pFrameData = (FrameData *) GetWindowLong(ghWndFrame,GWL_USERDATA); ! handle = newMenuHandle(pFrameData->pActionsMap, parent, pos, MENU_SEPARATOR, NULL); ! if (handle) { ! InsertMenu(getParentHMENU(handle),getMenuPos(pFrameData->pActionsMap, handle),MF_BYPOSITION | MF_SEPARATOR,0,NULL); updateMenuBar(parent); } ! return handle; } *************** *** 275,287 **** FrameData *pFrameData = (FrameData *) GetWindowLong(ghWndFrame,GWL_USERDATA); - notifyHandleForDestroy(handle); - if (handle->type != MENU_POPUP) { ! DeleteMenu(getParentHMENU(handle), getMenuPos(pFrameData->pMenuHandlesMap, handle), MF_BYPOSITION); updateMenuBar(handle->parent); } ! deleteMenuHandle(pFrameData->pMenuHandlesMap, handle); } --- 142,152 ---- FrameData *pFrameData = (FrameData *) GetWindowLong(ghWndFrame,GWL_USERDATA); if (handle->type != MENU_POPUP) { ! DeleteMenu(getParentHMENU(handle), getMenuPos(pFrameData->pActionsMap, handle), MF_BYPOSITION); updateMenuBar(handle->parent); } ! deleteMenuHandle(pFrameData->pActionsMap, handle); } *************** *** 289,298 **** { FrameData *pFrameData; ! CHECK_MENU_TYPE(handle, MENU_SUBMENU | MENU_POPUP, 0); ! pFrameData = (FrameData *) GetWindowLong(ghWndFrame,GWL_USERDATA); ! ! return getChildrenCount(pFrameData->pMenuHandlesMap, handle); } --- 154,163 ---- { FrameData *pFrameData; ! CHECK_MENU_TYPE(handle, MENU_SUBMENU | MENU_POPUP, 0); ! pFrameData = (FrameData *) GetWindowLong(ghWndFrame,GWL_USERDATA); ! ! return getChildrenCount(pFrameData->pActionsMap, handle); } *************** *** 307,311 **** pFrameData = (FrameData *) GetWindowLong(ghWndFrame,GWL_USERDATA); ! EnableMenuItem(getParentHMENU(handle), getMenuPos(pFrameData->pMenuHandlesMap, handle), (bState ? MF_ENABLED : MF_GRAYED) | MF_BYPOSITION); updateMenuBar(handle->parent); } --- 172,176 ---- pFrameData = (FrameData *) GetWindowLong(ghWndFrame,GWL_USERDATA); ! EnableMenuItem(getParentHMENU(handle), getMenuPos(pFrameData->pActionsMap, handle), (bState ? MF_ENABLED : MF_GRAYED) | MF_BYPOSITION); updateMenuBar(handle->parent); } *************** *** 321,329 **** CHECK_MENU_TYPE(handle, MENU_RADIO_ITEM | MENU_CHECK_ITEM | MENU_ITEM | MENU_SUBMENU, FALSE); ! pFrameData = (FrameData *) GetWindowLong(ghWndFrame,GWL_USERDATA); mii.cbSize = sizeof(mii); mii.fMask = MIIM_STATE; ! GetMenuItemInfo(getParentHMENU(handle), getMenuPos(pFrameData->pMenuHandlesMap, handle), TRUE, &mii); return (mii.fState & MFS_DISABLED) == 0; } --- 186,194 ---- CHECK_MENU_TYPE(handle, MENU_RADIO_ITEM | MENU_CHECK_ITEM | MENU_ITEM | MENU_SUBMENU, FALSE); ! pFrameData = (FrameData *) GetWindowLong(ghWndFrame,GWL_USERDATA); mii.cbSize = sizeof(mii); mii.fMask = MIIM_STATE; ! GetMenuItemInfo(getParentHMENU(handle), getMenuPos(pFrameData->pActionsMap, handle), TRUE, &mii); return (mii.fState & MFS_DISABLED) == 0; } *************** *** 332,378 **** }; - void osSetMenuItemChecked(MenuHandle handle, BOOL bState) - { - FrameData *pFrameData; - MenuHandle child; - - CHECK_MENU_TYPE_V(handle, MENU_CHECK_ITEM | MENU_RADIO_ITEM); - - pFrameData = (FrameData *) GetWindowLong(ghWndFrame,GWL_USERDATA); - - if (bState) - { - child = handle->nextInGroup; - while (child != handle) - { - CheckMenuItem(getParentHMENU(child), getMenuPos(pFrameData->pMenuHandlesMap, child), MF_UNCHECKED | MF_BYPOSITION); - child = child->nextInGroup; - } - - CheckMenuItem(getParentHMENU(handle), getMenuPos(pFrameData->pMenuHandlesMap, handle), MF_CHECKED | MF_BYPOSITION); - } - else - CheckMenuItem(getParentHMENU(handle), getMenuPos(pFrameData->pMenuHandlesMap, handle), MF_UNCHECKED | MF_BYPOSITION); - - updateMenuBar(handle->parent); - - handleMenuCommand(handle); - }; - - BOOL osGetMenuItemChecked(MenuHandle handle) - { - MENUITEMINFO mii; - FrameData *pFrameData; - - CHECK_MENU_TYPE(handle, MENU_CHECK_ITEM | MENU_RADIO_ITEM, FALSE); - - pFrameData = (FrameData *) GetWindowLong(ghWndFrame,GWL_USERDATA); - - mii.cbSize = sizeof(mii); - mii.fMask = MIIM_STATE; - GetMenuItemInfo(getParentHMENU(handle), getMenuPos(pFrameData->pMenuHandlesMap, handle), TRUE, &mii); - return (mii.fState & MFS_CHECKED) != 0; - } - char *osGetMenuLabel(MenuHandle handle) { --- 197,200 ---- *************** *** 388,392 **** pFrameData = (FrameData *) GetWindowLong(ghWndFrame,GWL_USERDATA); ! pos = getMenuPos(pFrameData->pMenuHandlesMap, handle); hParent = getParentHMENU(handle); --- 210,214 ---- pFrameData = (FrameData *) GetWindowLong(ghWndFrame,GWL_USERDATA); ! pos = getMenuPos(pFrameData->pActionsMap, handle); hParent = getParentHMENU(handle); *************** *** 420,424 **** if (handle->type != MENU_POPUP) { - char *s, *temp; MENUITEMINFO mii; FrameData *pFrameData; --- 242,245 ---- *************** *** 428,559 **** 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); - } - } - - char *osGetMenuTip(MenuHandle handle) - { - CHECK_MENU_TYPE(handle, MENU_RADIO_ITEM | MENU_CHECK_ITEM | MENU_ITEM, NULL); - return handle->tip; - } - - void osSetMenuTip(MenuHandle handle, char *tip) - { - CHECK_MENU_TYPE_V(handle, MENU_RADIO_ITEM | MENU_CHECK_ITEM | MENU_ITEM); - - if (handle->tip) - free(handle->tip); - - handle->tip = strdup(tip); - } - - void osSetMenuItemAccel(MenuHandle handle, int key, unsigned int mods) - { - int pos; - HMENU hParent; - char *s; - MENUITEMINFO mii; - FrameData *pFrameData; - - CHECK_MENU_TYPE_V(handle, MENU_RADIO_ITEM | MENU_CHECK_ITEM | MENU_ITEM); - - pFrameData = (FrameData *) GetWindowLong(ghWndFrame,GWL_USERDATA); - pos = getMenuPos(pFrameData->pMenuHandlesMap, handle); - hParent = getParentHMENU(handle); - - 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); ! ! s = mii.dwTypeData; ! 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); } } - void osGetMenuItemAccel(MenuHandle handle, int *key, unsigned int *mods) - { - CHECK_MENU_TYPE_V(handle, MENU_RADIO_ITEM | MENU_CHECK_ITEM | MENU_ITEM); - - *key = handle->key; - *mods = handle->mods; - } - - void osSetMenuItemBitmap(MenuHandle handle, BitmapHandle bitmap) - { - MENUITEMINFO mii; - FrameData *pFrameData; - - CHECK_MENU_TYPE_V(handle, MENU_ITEM); - - pFrameData = (FrameData *) GetWindowLong(ghWndFrame,GWL_USERDATA); - handle->bitmap = bitmap; - - memset(&mii,0,sizeof(mii)); - mii.cbSize = sizeof(mii); - mii.fMask = MIIM_FTYPE; - mii.fType = bitmap ? MFT_OWNERDRAW : MFT_STRING; - SetMenuItemInfo(getParentHMENU(handle), getMenuPos(pFrameData->pMenuHandlesMap, handle), TRUE, &mii); - - updateMenuBar(handle->parent); - } - int osGetMenuItemPos(MenuHandle handle) { FrameData *pFrameData = (FrameData *) GetWindowLong(ghWndFrame,GWL_USERDATA); ! return getMenuPos(pFrameData->pMenuHandlesMap, handle); } --- 249,267 ---- pFrameData = (FrameData *) GetWindowLong(ghWndFrame,GWL_USERDATA); memset(&mii,0,sizeof(mii)); mii.cbSize = sizeof(mii); mii.fMask = MIIM_STRING; mii.fType = MFT_STRING; ! mii.dwTypeData = title; ! mii.cch = strlen(title); ! SetMenuItemInfo(getParentHMENU(handle), getMenuPos(pFrameData->pActionsMap, handle), TRUE, &mii); updateMenuBar(handle->parent); } } int osGetMenuItemPos(MenuHandle handle) { FrameData *pFrameData = (FrameData *) GetWindowLong(ghWndFrame,GWL_USERDATA); ! return getMenuPos(pFrameData->pActionsMap, handle); } Index: ToolBar.c =================================================================== RCS file: /cvsroot/htoolkit/port/src/cbits/Win32/ToolBar.c,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** ToolBar.c 7 May 2004 14:44:50 -0000 1.20 --- ToolBar.c 14 May 2004 23:01:41 -0000 1.21 *************** *** 18,41 **** WNDPROC DefToolBarProc = NULL; - static int nNextToolButtonID = 0; - - enum TOOL_TYPE - { TOOL_SUBMENU = 1 - , TOOL_SEPARATOR = 2 - , TOOL_ITEM = 4 - , TOOL_CHECK_ITEM = 8 - , TOOL_RADIO_ITEM = 16 - }; - - struct ToolHandle - { - int nCommand; - HWND hToolBar; - BitmapHandle bitmap; - enum TOOL_TYPE type; - ToolHandle nextInGroup; - MenuHandle menu; - }; - //////////////////////////////////////////// // Drawing & GDI utilities --- 18,21 ---- *************** *** 817,821 **** } ! ToolHandle osInsertToolButton(WindowHandle toolBar, int pos) { TBBUTTON tbb; --- 797,801 ---- } ! ToolHandle osInsertToolButton(ActionHandle action, WindowHandle toolBar, int pos) { TBBUTTON tbb; *************** *** 825,962 **** if (!btn) return NULL; - btn->nCommand = ++nNextToolButtonID; btn->hToolBar = toolBar; ! btn->menu = NULL; ! btn->bitmap = NULL; ! btn->type = TOOL_ITEM; ! btn->nextInGroup = btn; ! ! tbb.iBitmap = I_IMAGENONE; ! tbb.idCommand = btn->nCommand; ! tbb.fsState = TBSTATE_ENABLED; ! tbb.fsStyle = TBSTYLE_BUTTON; ! tbb.dwData = (DWORD)btn; ! tbb.iString = 0; ! ! if (pos > 0) ! SendMessage(toolBar,TB_INSERTBUTTON,pos,(LPARAM)&tbb); ! else ! SendMessage(toolBar,TB_ADDBUTTONS, 1, (LPARAM)&tbb); ! ! RelayoutFrameBars(); ! return btn; ! } ! ! ToolHandle osInsertToolCheckButton(WindowHandle toolBar, int pos) ! { ! TBBUTTON tbb; ! ToolHandle btn; ! ! btn = malloc(sizeof(struct ToolHandle)); ! if (!btn) return NULL; ! btn->nCommand = ++nNextToolButtonID; ! btn->hToolBar = toolBar; ! btn->menu = NULL; ! btn->bitmap = NULL; ! btn->type = TOOL_CHECK_ITEM; ! btn->nextInGroup = btn; ! tbb.iBitmap = I_IMAGENONE; ! tbb.idCommand = btn->nCommand; ! tbb.fsState = TBSTATE_ENABLED; ! tbb.fsStyle = TBSTYLE_BUTTON | TBSTYLE_CHECK; ! tbb.dwData = (DWORD)btn; ! tbb.iString = 0; ! if (pos > 0) ! SendMessage(toolBar,TB_INSERTBUTTON,pos,(LPARAM)&tbb); else ! SendMessage(toolBar,TB_ADDBUTTONS, 1, (LPARAM)&tbb); ! ! RelayoutFrameBars(); ! return btn; ! } ! ! ToolHandle osInsertToolRadioButton(WindowHandle toolBar, int pos) ! { ! TBBUTTON tbb; ! ToolHandle btn; ! ! btn = malloc(sizeof(struct ToolHandle)); ! if (!btn) return NULL; ! ! btn->nCommand = ++nNextToolButtonID; ! btn->hToolBar = toolBar; ! btn->menu = NULL; ! btn->bitmap = NULL; ! btn->type = TOOL_RADIO_ITEM; ! btn->nextInGroup = btn; ! tbb.iBitmap = I_IMAGENONE; ! tbb.idCommand = btn->nCommand; ! tbb.fsState = TBSTATE_ENABLED; ! tbb.fsStyle = TBSTYLE_BUTTON; tbb.dwData = (DWORD)btn; tbb.iString = 0; ! if (pos > 0) ! SendMessage(toolBar,TB_INSERTBUTTON,pos,(LPARAM)&tbb); ! else ! SendMessage(toolBar,TB_ADDBUTTONS, 1, (LPARAM)&tbb); ! ! RelayoutFrameBars(); ! return btn; ! } ! ! void osSetToolRadioGroup(ToolHandle *handles) ! { ! ToolHandle next, handle, *phandle; ! ! if (!(handles && *handles)) ! return; ! ! phandle=handles; ! for (;;) { ! handle = *phandle; ! ! next = handle->nextInGroup; ! while (next->nextInGroup != handle) ! next = next->nextInGroup; ! next->nextInGroup = handle->nextInGroup; ! ! phandle++; ! if (*phandle) ! handle->nextInGroup = *phandle; ! else ! { ! handle->nextInGroup = *handles; break; - } } - } - - ToolHandle osInsertToolDropDownButton(WindowHandle toolBar, MenuHandle hmenu, int pos) - { - TBBUTTON tbb; - ToolHandle btn; - - btn = malloc(sizeof(struct ToolHandle)); - if (!btn) return NULL; - - btn->nCommand = ++nNextToolButtonID; - btn->hToolBar = toolBar; - btn->menu = hmenu; - btn->bitmap = NULL; - btn->type = TOOL_SUBMENU; - btn->nextInGroup = btn; - - tbb.iBitmap = I_IMAGENONE; - tbb.idCommand = btn->nCommand; - tbb.fsState = TBSTATE_ENABLED; - tbb.fsStyle = TBSTYLE_BUTTON | BTNS_WHOLEDROPDOWN; - tbb.dwData = (DWORD)btn; - tbb.iString = 0; if (pos > 0) --- 805,848 ---- if (!btn) return NULL; btn->hToolBar = toolBar; ! btn->action = action; ! // link the button to the chain ! btn->nextInAction = action->toolProxies; ! action->toolProxies = btn; ! TBADDBITMAP tbab; ! if (action->bitmap) ! { ! tbab.hInst = NULL; ! tbab.nID = (UINT) action->bitmap->hBitmap; ! tbb.iBitmap = SendMessage(toolBar, TB_ADDBITMAP, 1, (LPARAM) &tbab); ! } else ! { ! tbb.iBitmap = I_IMAGENONE; ! } ! tbb.idCommand = action->id; ! tbb.fsState = action->enabled ? TBSTATE_ENABLED : 0; tbb.dwData = (DWORD)btn; tbb.iString = 0; ! switch (btn->action->type) { ! case ACTION_NORMAL: ! tbb.fsStyle = TBSTYLE_BUTTON; ! break; ! case ACTION_CHECK: ! tbb.fsStyle = TBSTYLE_BUTTON | TBSTYLE_CHECK; ! break; ! case ACTION_RADIO: ! tbb.fsStyle = TBSTYLE_BUTTON; ! break; ! case ACTION_DROPDOWN: ! tbb.fsStyle = TBSTYLE_BUTTON | BTNS_WHOLEDROPDOWN; break; } if (pos > 0) *************** *** 969,1000 **** } - void osActivateToolItem(ToolHandle toolButton) - { - switch (toolButton->type) - { - case TOOL_RADIO_ITEM: - osSetToolButtonChecked(toolButton, TRUE); - break; - case TOOL_SUBMENU: - { - RECT rect; - int nBtnPos; - - memset(&rect, 0, sizeof(rect)); - nBtnPos = SendMessage(toolButton->hToolBar, TB_COMMANDTOINDEX, toolButton->nCommand, 0); - SendMessage(toolButton->hToolBar, TB_GETITEMRECT, nBtnPos, (LPARAM)&rect); - - ClientToScreen(toolButton->hToolBar, ((POINT *) &rect)); - ClientToScreen(toolButton->hToolBar, ((POINT *) &rect)+1); - - TrackPopupMenu(toolButton->menu->hMenu, TPM_LEFTALIGN | TPM_TOPALIGN, rect.left, rect.bottom, 0, ghWndFrame, NULL); - } - break; - default: - handleToolCommand(toolButton)... [truncated message content] |
From: <kr_...@us...> - 2004-05-12 20:42:56
|
Update of /cvsroot/htoolkit/gio In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5356/gio Modified Files: makefile Log Message: This is a major rewrite of menu and toolbar support. The main feature is that the new API provides action based menu and toolbar. The another advantage is that now the code is more simpler and shorter. The low lever API is implemented only under Linux for now. Index: makefile =================================================================== RCS file: /cvsroot/htoolkit/gio/makefile,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** makefile 23 Nov 2003 16:29:13 -0000 1.18 --- makefile 12 May 2004 20:42:16 -0000 1.19 *************** *** 31,38 **** GIO/Bitmap.hs GIO/Canvas.hs \ GIO/Events.hs GIO/Timer.hs GIO/Layout.hs \ ! GIO/Window.hs GIO/Menu.hs \ ! GIO/CommonDialogs.hs GIO/Controls.hs \ ! GIO/Messages.hs GIO/Process.hs \ GIO/ToolBar.hs GIO/StatusBar.hs \ GIO.hs \ --- 31,38 ---- GIO/Bitmap.hs GIO/Canvas.hs \ GIO/Events.hs GIO/Timer.hs GIO/Layout.hs \ ! GIO/Window.hs GIO/CommonDialogs.hs GIO/Controls.hs \ ! GIO/MenuType.hs GIO/Action.hs GIO/Menu.hs \ GIO/ToolBar.hs GIO/StatusBar.hs \ + GIO/Messages.hs GIO/Process.hs \ GIO.hs \ |
From: <kr_...@us...> - 2004-05-12 20:42:50
|
Update of /cvsroot/htoolkit/port/src/cbits/GTK In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5356/port/src/cbits/GTK Modified Files: Internals.h Menu.c ToolBar.c Util.c Added Files: Action.c Log Message: This is a major rewrite of menu and toolbar support. The main feature is that the new API provides action based menu and toolbar. The another advantage is that now the code is more simpler and shorter. The low lever API is implemented only under Linux for now. --- NEW FILE: Action.c --- #include "Action.h" #include "Internals.h" #include "Handlers_stub.h" #include "Window.h" #include <gdk/gdkkeysyms.h> // The pointer to the first live action. All actions are linked together using the "next_action" field static ActionHandle first_action = NULL; static ActionHandle create_action(enum ActionType type) { ActionHandle action = malloc(sizeof(struct ActionHandle)); action->type = type; action->title = NULL; action->short_title = NULL; action->tooltip = NULL; action->bitmap = NULL; action->enabled = TRUE; action->checked = FALSE; action->busy = FALSE; action->key = 0; action->keyMods = 0; action->menu = NULL; action->proxies = NULL; // link the action action->next_action = first_action; first_action = action; // by default the action is in its own group action->next_action_in_group = action; return action; } static gboolean find_accel_by_widget(GtkAccelKey *key, GClosure *closure, gpointer data) { return (closure->data == data); } void menu_item_set_accel(GtkWidget *item, ActionHandle action) { int key; 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 (action->key == 0) return; modifier = 0; if (action->keyMods & shiftBIT) modifier |= GDK_SHIFT_MASK; if (action->keyMods & ctrlBIT) modifier |= GDK_CONTROL_MASK; if (action->keyMods & altBIT) modifier |= GDK_MOD1_MASK; switch (action->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 (action->key >= 256) { key = action->key - 256; modifier = GDK_MOD1_MASK; } if (iscntrl(action->key)) { key = action->key + '@'; modifier |= GDK_CONTROL_MASK; } else if (isupper(action->key)) modifier |= GDK_SHIFT_MASK; else key = toupper(action->key); break; } gtk_widget_add_accelerator(item, "activate", accel_group, key, modifier, GTK_ACCEL_VISIBLE); }; void destroy_all_actions() { while (first_action) osDestroyAction(first_action); } ActionHandle osCreateAction() { return create_action(ACTION_NORMAL); } ActionHandle osCreateCheckAction() { return create_action(ACTION_CHECK); } ActionHandle osCreateRadioAction() { return create_action(ACTION_RADIO); } ActionHandle osCreateDropDownAction(MenuHandle menu) { ActionHandle action = create_action(ACTION_DROPDOWN); action->menu = menu; return action; } void osSetActionRadioGroup(ActionHandle *handles) { ActionHandle *phandle, handle, child; if (!handles || *handles == NULL) return; phandle=handles; for (;;) { handle = *phandle; child = handle->next_action_in_group; while (child->next_action_in_group != handle) child = child->next_action_in_group; child->next_action_in_group = handle->next_action_in_group; phandle++; if (*phandle) handle->next_action_in_group = *phandle; else { handle->next_action_in_group = *handles; break; } } } void osSetActionBitmap(ActionHandle action, BitmapHandle bitmap) { GSList *list; GtkWidget *proxy, *image; action->bitmap = bitmap; for (list = action->proxies; list != NULL; list=list->next) { proxy = (GtkWidget *) list->data; if (GTK_IS_IMAGE_MENU_ITEM(proxy)) { image = gtk_image_menu_item_get_image(GTK_IMAGE_MENU_ITEM(proxy)); if (action->bitmap) { if (!image) { image = gtk_image_new_from_pixbuf(action->bitmap->pixbuf); gtk_widget_show(image); gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(proxy), image); } else gtk_image_set_from_pixbuf(GTK_IMAGE(image),action->bitmap->pixbuf); } else { if (image) { gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(proxy), NULL); } } } else if (GTK_IS_TOOL_BUTTON(proxy)) { image = gtk_tool_button_get_icon_widget (GTK_TOOL_BUTTON(proxy)); gtk_image_set_from_pixbuf(GTK_IMAGE(image), action->bitmap->pixbuf); } } } void osSetActionEnabled(ActionHandle action, BOOL enabled) { GSList *list; GtkWidget *proxy; action->enabled = enabled; for (list = action->proxies; list != NULL; list=list->next) { proxy = (GtkWidget *) list->data; gtk_widget_set_sensitive(proxy,action->enabled); } } BOOL osGetActionEnabled(ActionHandle action) { return action->enabled; } void osSetActionTip(ActionHandle action, char *text) { GSList *list; GtkWidget *proxy; action->tooltip = strdup(text); for (list = action->proxies; list != NULL; list=list->next) { proxy = (GtkWidget *) list->data; if (GTK_IS_TOOL_BUTTON(proxy)) { GtkWidget *toolbar = gtk_widget_get_parent(proxy); gtk_tool_item_set_tooltip(GTK_TOOL_ITEM(proxy), GTK_TOOLBAR(toolbar)->tooltips, text, NULL); } } } char *osGetActionTip(ActionHandle action) { return strdup(action->tooltip); } void osSetActionText(ActionHandle action, char *text) { GSList *list; GtkWidget *proxy; char *short_text; action->title = strdup(text); text = toMnemonicString(action->title); short_text = toMnemonicString(action->short_title); for (list = action->proxies; list != NULL; list=list->next) { proxy = (GtkWidget *) list->data; if (GTK_IS_MENU_ITEM(proxy)) gtk_label_set_text_with_mnemonic(GTK_LABEL(GTK_BIN(proxy)->child), text); else if (GTK_IS_TOOL_BUTTON(proxy)) gtk_tool_button_set_label(GTK_TOOL_BUTTON(proxy), short_text ? short_text : text); } rfree(short_text); rfree(text); } char *osGetActionText(ActionHandle action) { return strdup(action->title); } void osSetActionShortText(ActionHandle action, char *text) { GSList *list; GtkWidget *proxy; action->short_title = (text && *text) ? strdup(text) : NULL; text = toMnemonicString(action->short_title ? action->short_title : action->title); for (list = action->proxies; list != NULL; list=list->next) { proxy = (GtkWidget *) list->data; if (GTK_IS_TOOL_BUTTON(proxy)) gtk_tool_button_set_label(GTK_TOOL_BUTTON(proxy), text); } rfree(text); } char *osGetActionShortText(ActionHandle action) { return strdup(action->short_title); } void osSetActionChecked(ActionHandle action, BOOL checked) { GSList *list; GtkWidget *proxy; ActionHandle action_in_group; action_in_group = action; do { action_in_group->busy = TRUE; action_in_group->checked = checked; for (list = action_in_group->proxies; list != NULL; list=list->next) { proxy = (GtkWidget *) list->data; if (GTK_IS_CHECK_MENU_ITEM(proxy)) gtk_check_menu_item_set_active ( GTK_CHECK_MENU_ITEM (proxy), action_in_group->checked); else if (GTK_IS_TOGGLE_TOOL_BUTTON(proxy)) gtk_toggle_tool_button_set_active ( GTK_TOGGLE_TOOL_BUTTON(proxy), action_in_group->checked); } action_in_group->busy = FALSE; action_in_group = action_in_group->next_action_in_group; checked = FALSE; } while (action_in_group != action); handleActionCommand(action); }; BOOL osGetActionChecked(ActionHandle action) { return action->checked; }; void osSetActionAccel(ActionHandle action, int key, unsigned int mods) { GSList *list; GtkWidget *proxy; action->key = key; action->keyMods = mods; for (list = action->proxies; list != NULL; list=list->next) { proxy = (GtkWidget *) list->data; if (GTK_IS_MENU_ITEM(proxy)) menu_item_set_accel(proxy, action); } }; void osGetActionAccel(ActionHandle action, int *key, unsigned int *mods) { *key = action->key; *mods = action->keyMods; }; void osDestroyAction(ActionHandle action) { ActionHandle act; if (action->menu) gtk_widget_destroy(action->menu); // destroy all proxies associated with the action while (action->proxies) gtk_widget_destroy((GtkWidget *) action->proxies->data); handleActionDestroy(action); if (first_action == action) first_action = action->next_action; else { for (act = first_action; act != NULL; act=act->next_action) { if (act->next_action == action) { act->next_action = action->next_action; break; } } } free(action->title); free(action->short_title); free(action->tooltip); free(action); } Index: Internals.h =================================================================== RCS file: /cvsroot/htoolkit/port/src/cbits/GTK/Internals.h,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** Internals.h 8 May 2004 09:21:09 -0000 1.7 --- Internals.h 12 May 2004 20:42:34 -0000 1.8 *************** *** 5,8 **** --- 5,37 ---- #include "LayoutContainer.h" + enum ActionType { ACTION_NORMAL, ACTION_CHECK, ACTION_RADIO, ACTION_DROPDOWN }; + + struct ActionHandle + { + // chain; + ActionHandle next_action; + ActionHandle next_action_in_group; + + // Attributes + enum ActionType type; // the action type + char *title; + char *short_title; + char *tooltip; + BitmapHandle bitmap; + BOOL enabled : 1; // TRUE if the action is enabled + BOOL checked : 1; // TRUE if the action is checked + BOOL busy : 1; // TRUE if we currently update the proxies state + + GtkWidget *menu; + + // Accelerator + int key; + unsigned int keyMods; + + GSList *proxies; // the collection of all proxies (menu items or toolbar buttons) associated to this action + }; + + extern void menu_item_set_accel(GtkWidget *item, ActionHandle action); + extern BOOL gInKey; extern int gCurChar; Index: Menu.c =================================================================== RCS file: /cvsroot/htoolkit/port/src/cbits/GTK/Menu.c,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** Menu.c 5 May 2004 21:06:56 -0000 1.14 --- Menu.c 12 May 2004 20:42:34 -0000 1.15 *************** *** 1,4 **** --- 1,5 ---- #include "Menu.h" #include "Window.h" + #include "Action.h" #include "Internals.h" #include "Handlers_stub.h" *************** *** 17,31 **** } ! static void menu_put_hint_in_statusbar(GtkWidget *menuitem, gpointer data) { ! gchar* hint = g_object_get_data(G_OBJECT(menuitem), apphelper_statusbar_hint); ! // if (GNOME_APP(gFrameWidget)->statusbar) ! // gnome_appbar_push(GNOME_APPBAR(GNOME_APP(gFrameWidget)->statusbar), hint); } ! static void menu_remove_hint_from_statusbar(GtkWidget *menu) { ! // if (GNOME_APP(gFrameWidget)->statusbar) ! // gnome_appbar_pop(GNOME_APPBAR(GNOME_APP(gFrameWidget)->statusbar)); } --- 18,64 ---- } ! static void menu_item_put_hint_in_statusbar(GtkWidget *menuitem, ActionHandle action) { ! if (action && action->tooltip) ! { ! if (GNOME_APP(gFrameWidget)->statusbar) ! gnome_appbar_push(GNOME_APPBAR(GNOME_APP(gFrameWidget)->statusbar), action->tooltip); ! } } ! static void menu_item_remove_hint_from_statusbar(GtkWidget *menu, ActionHandle action) { ! if (action && action->tooltip) ! { ! if (GNOME_APP(gFrameWidget)->statusbar) ! gnome_appbar_pop(GNOME_APPBAR(GNOME_APP(gFrameWidget)->statusbar)); ! } ! } ! ! static void menu_item_activate(GtkMenuItem *menuitem, ActionHandle action) ! { ! if (action->busy) ! return; ! ! switch (action->type) ! { ! case ACTION_NORMAL: ! handleActionCommand(action); ! break; ! case ACTION_CHECK: ! osSetActionChecked(action, !action->checked); ! break; ! case ACTION_RADIO: ! osSetActionChecked(action, TRUE); ! break; ! case ACTION_DROPDOWN: ! break; ! } ! } ! ! static void menu_item_destroy(GtkWidget *menu, ActionHandle action) ! { ! handleMenuDestroy(menu); ! action->proxies = g_slist_remove(action->proxies, menu); } *************** *** 78,101 **** } - 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 osCreatePopupMenu() { --- 111,114 ---- *************** *** 104,110 **** GTK_SIGNAL_FUNC(menu_destroy), NULL); - gtk_signal_connect (GTK_OBJECT(popUpMenu), "show", - GTK_SIGNAL_FUNC(menu_show), - NULL); return popUpMenu; } --- 117,120 ---- *************** *** 138,142 **** } ! MenuHandle osInsertMenu(MenuHandle parent, int pos) { GtkWidget *menu; --- 148,152 ---- } ! MenuHandle osInsertMenu(MenuHandle hmenu, int pos) { GtkWidget *menu; *************** *** 148,156 **** GTK_SIGNAL_FUNC(menu_destroy), NULL); - gtk_signal_connect (GTK_OBJECT(popUpMenu), "show", - GTK_SIGNAL_FUNC(menu_show), - NULL); ! menu = getMenu(parent); pos = recalcPos(menu, pos); --- 158,163 ---- GTK_SIGNAL_FUNC(menu_destroy), NULL); ! menu = getMenu(hmenu); pos = recalcPos(menu, pos); *************** *** 160,216 **** }; ! 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(menu_destroy), ! NULL); ! gtk_signal_connect (GTK_OBJECT(menuItem), "select", ! GTK_SIGNAL_FUNC(menu_put_hint_in_statusbar), ! NULL); ! gtk_signal_connect (GTK_OBJECT(menuItem), "deselect", ! GTK_SIGNAL_FUNC(menu_remove_hint_from_statusbar), ! 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(menu_destroy), ! NULL); gtk_signal_connect (GTK_OBJECT(menuItem), "select", ! GTK_SIGNAL_FUNC(menu_put_hint_in_statusbar), ! NULL); gtk_signal_connect (GTK_OBJECT(menuItem), "deselect", ! GTK_SIGNAL_FUNC(menu_remove_hint_from_statusbar), ! NULL); menu = getMenu(parent); --- 167,229 ---- }; ! MenuHandle osInsertMenuItem(ActionHandle action, MenuHandle parent, int pos) { ! GtkWidget *menu, *popUpMenu; GtkWidget *label, *menuItem; + gchar *text; ! switch (action->type) ! { ! case ACTION_NORMAL: ! menuItem = gtk_image_menu_item_new(); ! if (action->bitmap) ! gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menuItem), ! gtk_image_new_from_pixbuf(action->bitmap->pixbuf)); ! break; ! case ACTION_CHECK: ! menuItem = gtk_check_menu_item_new(); ! gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM(menuItem), action->checked); ! break; ! case ACTION_RADIO: ! menuItem = gtk_check_menu_item_new(); ! gtk_check_menu_item_set_draw_as_radio(GTK_CHECK_MENU_ITEM(menuItem), TRUE); ! gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM(menuItem), action->checked); ! break; ! case ACTION_DROPDOWN: ! text = toMnemonicString(action->title ? action->title : ""); ! menuItem = gtk_menu_item_new_with_mnemonic(text); ! rfree(text); ! if (action->menu) ! gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuItem), action->menu); ! break; ! } ! gtk_widget_set_sensitive(menuItem,action->enabled); ! if (action->type != ACTION_DROPDOWN) ! { ! label = gtk_accel_label_new(""); ! text = toMnemonicString(action->title ? action->title : ""); ! gtk_label_set_text_with_mnemonic(GTK_LABEL(label) , text); ! rfree(text); ! gtk_container_add(GTK_CONTAINER(menuItem), label); ! gtk_accel_label_set_accel_widget(GTK_ACCEL_LABEL(label), menuItem); ! menu_item_set_accel(menuItem, action); ! gtk_signal_connect (GTK_OBJECT(menuItem), "activate", ! GTK_SIGNAL_FUNC(menu_item_activate), ! action); ! } gtk_signal_connect (GTK_OBJECT(menuItem), "destroy", ! GTK_SIGNAL_FUNC(menu_item_destroy), ! action); gtk_signal_connect (GTK_OBJECT(menuItem), "select", ! GTK_SIGNAL_FUNC(menu_item_put_hint_in_statusbar), ! action); gtk_signal_connect (GTK_OBJECT(menuItem), "deselect", ! GTK_SIGNAL_FUNC(menu_item_remove_hint_from_statusbar), ! action); menu = getMenu(parent); *************** *** 219,222 **** --- 232,239 ---- gtk_menu_shell_insert(GTK_MENU_SHELL(menu), menuItem, pos); gtk_widget_show_all(menuItem); + + // add the item to the list of all menu items associated to this action + action->proxies = g_slist_append(action->proxies, menuItem); + return menuItem; }; *************** *** 227,231 **** GtkWidget *item = gtk_separator_menu_item_new(); gtk_signal_connect (GTK_OBJECT(item), "destroy", ! GTK_SIGNAL_FUNC(menu_destroy), NULL); --- 244,248 ---- GtkWidget *item = gtk_separator_menu_item_new(); gtk_signal_connect (GTK_OBJECT(item), "destroy", ! GTK_SIGNAL_FUNC(handleMenuDestroy), NULL); *************** *** 238,292 **** } - static void handleRadioMenuCommand(GtkMenuItem *menuitem) - { - if (gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(menuitem))) - handleMenuCommand(menuitem); - } - - MenuHandle osInsertMenuRadioItem(MenuHandle parent, int pos) - { - GtkWidget *menu; - GtkWidget *menuItem, *label; - - menuItem = gtk_radio_menu_item_new(NULL); - GTK_CHECK_MENU_ITEM (menuItem)->active = FALSE; - 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(menu_destroy), - NULL); - gtk_signal_connect (GTK_OBJECT(menuItem), "select", - GTK_SIGNAL_FUNC(menu_put_hint_in_statusbar), - NULL); - gtk_signal_connect (GTK_OBJECT(menuItem), "deselect", - GTK_SIGNAL_FUNC(menu_remove_hint_from_statusbar), - 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; - } - - void osSetMenuRadioGroup(MenuHandle *handles) - { - MenuHandle *phandle; - GSList *group = NULL; - - for (phandle = handles; *phandle; phandle++) - { - gtk_radio_menu_item_set_group(GTK_RADIO_MENU_ITEM(*phandle), group); - group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM(*phandle)); - } - } - void osDestroyMenu(MenuHandle handle) { --- 255,258 ---- *************** *** 324,337 **** }; - 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 osSetMenuLabel(MenuHandle item, char* title) { --- 290,293 ---- *************** *** 352,537 **** }; - void osSetMenuTip(MenuHandle item, char* title) - { - gchar *hint = g_object_get_data(G_OBJECT(item), apphelper_statusbar_hint); - if (hint) free(hint); - - g_object_set_data(G_OBJECT(item), apphelper_statusbar_hint, strdup(title)); - } - - char *osGetMenuTip(MenuHandle item) - { - return g_object_get_data(G_OBJECT(item), apphelper_statusbar_hint); - }; - - 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) { --- 308,311 ---- Index: ToolBar.c =================================================================== RCS file: /cvsroot/htoolkit/port/src/cbits/GTK/ToolBar.c,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** ToolBar.c 5 May 2004 22:10:16 -0000 1.12 --- ToolBar.c 12 May 2004 20:42:34 -0000 1.13 *************** *** 1,7 **** --- 1,35 ---- #include "ToolBar.h" + #include "Action.h" #include "Internals.h" #include "Handlers_stub.h" #include "gtkdropdowntoolbutton.h" + static void tool_item_clicked(GtkWidget *widget, ActionHandle action) + { + if (action->busy) + return; + + switch (action->type) + { + case ACTION_NORMAL: + handleActionCommand(action); + break; + case ACTION_CHECK: + osSetActionChecked(action, !action->checked); + break; + case ACTION_RADIO: + osSetActionChecked(action, TRUE); + break; + case ACTION_DROPDOWN: + break; + } + } + + static void tool_item_destroy(GtkWidget *tool, ActionHandle action) + { + handleToolDestroy(tool); + action->proxies = g_slist_remove(action->proxies, tool); + } + WindowHandle osCreateToolBar(char *name, PositionType place, int band_num, int band_position, int offset) { *************** *** 10,14 **** toolbar = gtk_toolbar_new(); ! gtk_toolbar_set_show_arrow(toolbar,FALSE); gtk_signal_connect (GTK_OBJECT(toolbar), "destroy", GTK_SIGNAL_FUNC(handleWindowDestroy), --- 38,42 ---- toolbar = gtk_toolbar_new(); ! gtk_toolbar_set_show_arrow(GTK_TOOLBAR(toolbar),FALSE); gtk_signal_connect (GTK_OBJECT(toolbar), "destroy", GTK_SIGNAL_FUNC(handleWindowDestroy), *************** *** 46,125 **** } ! ToolHandle osInsertToolButton(WindowHandle toolbar, int pos) { ! GtkToolItem *item = gtk_tool_button_new(gtk_image_new(), ""); ! gtk_tool_button_set_use_underline (GTK_TOOL_BUTTON(item), TRUE); ! gtk_signal_connect (GTK_OBJECT(item), "clicked", ! GTK_SIGNAL_FUNC(handleToolCommand), ! NULL); ! gtk_signal_connect (GTK_OBJECT(item), "destroy", ! GTK_SIGNAL_FUNC(handleToolDestroy), ! NULL); ! gtk_toolbar_insert(GTK_TOOLBAR(toolbar), item, pos); ! gtk_widget_show_all(GTK_WIDGET(item)); ! return GTK_WIDGET(item); ! } ! ToolHandle osInsertToolCheckButton(WindowHandle toolbar, int pos) ! { ! GtkToolItem *item = gtk_toggle_tool_button_new(); ! gtk_tool_button_set_use_underline (GTK_TOOL_BUTTON(item), TRUE); ! gtk_signal_connect (GTK_OBJECT(item), "clicked", ! GTK_SIGNAL_FUNC(handleToolCommand), ! NULL); ! gtk_signal_connect (GTK_OBJECT(item), "destroy", ! GTK_SIGNAL_FUNC(handleToolDestroy), ! NULL); ! gtk_tool_button_set_icon_widget(GTK_TOOL_BUTTON(item), gtk_image_new()); ! gtk_toolbar_insert(GTK_TOOLBAR(toolbar), item, pos); ! gtk_widget_show_all(GTK_WIDGET(item)); ! return GTK_WIDGET(item); ! } ! static void tool_radio_button_clicked(GtkWidget *widget, gpointer user_data) ! { ! if (gtk_toggle_tool_button_get_active(GTK_TOGGLE_TOOL_BUTTON(widget))) ! handleToolCommand(widget); ! } - ToolHandle osInsertToolRadioButton(WindowHandle toolbar, int pos) - { - GtkToolItem *item = gtk_radio_tool_button_new(NULL); gtk_tool_button_set_use_underline (GTK_TOOL_BUTTON(item), TRUE); ! gtk_toggle_tool_button_set_active(GTK_TOGGLE_TOOL_BUTTON (item), FALSE); ! gtk_signal_connect (GTK_OBJECT(item), "clicked", ! GTK_SIGNAL_FUNC(tool_radio_button_clicked), ! NULL); ! gtk_signal_connect (GTK_OBJECT(item), "destroy", ! GTK_SIGNAL_FUNC(handleToolDestroy), ! NULL); ! gtk_tool_button_set_icon_widget(GTK_TOOL_BUTTON(item), gtk_image_new()); ! gtk_toolbar_insert(GTK_TOOLBAR(toolbar), item, pos); ! gtk_widget_show_all(GTK_WIDGET(item)); ! return GTK_WIDGET(item); ! } ! void osSetToolRadioGroup(ToolHandle *handles) ! { ! ToolHandle *phandle; ! GSList *group = NULL; ! for (phandle = handles; *phandle; phandle++) { ! gtk_radio_tool_button_set_group(GTK_RADIO_TOOL_BUTTON(*phandle), group); ! group = gtk_radio_tool_button_get_group(GTK_RADIO_TOOL_BUTTON(*phandle)); } - } - ToolHandle osInsertToolDropDownButton(WindowHandle toolbar, MenuHandle hmenu, int pos) - { - GtkToolItem *item = gtk_drop_down_tool_button_new(gtk_image_new(), "", NULL); - gtk_tool_button_set_use_underline (GTK_TOOL_BUTTON(item), TRUE); - gtk_drop_down_tool_button_set_menu(GTK_DROP_DOWN_TOOL_BUTTON(item), hmenu); gtk_signal_connect (GTK_OBJECT(item), "destroy", ! GTK_SIGNAL_FUNC(handleToolDestroy), ! NULL); gtk_toolbar_insert(GTK_TOOLBAR(toolbar), item, pos); gtk_widget_show_all(GTK_WIDGET(item)); return GTK_WIDGET(item); } --- 74,132 ---- } ! ToolHandle osInsertToolButton(ActionHandle action, WindowHandle toolbar, int pos) { ! GtkToolItem *item; ! GtkWidget *image; ! char *text; ! image = gtk_image_new(); ! if (action->bitmap) ! gtk_image_set_from_pixbuf(GTK_IMAGE(image), action->bitmap->pixbuf); ! switch (action->type) ! { ! case ACTION_NORMAL: ! item = gtk_tool_button_new(image, ""); ! break; ! case ACTION_CHECK: ! case ACTION_RADIO: ! item = gtk_toggle_tool_button_new(); ! gtk_tool_button_set_icon_widget(GTK_TOOL_BUTTON(item), image); ! gtk_toggle_tool_button_set_active(GTK_TOGGLE_TOOL_BUTTON(item), action->checked); ! break; ! case ACTION_DROPDOWN: ! item = gtk_drop_down_tool_button_new(image, "", NULL); ! if (action->menu) ! gtk_drop_down_tool_button_set_menu(GTK_DROP_DOWN_TOOL_BUTTON(item), action->menu); ! break; ! } ! ! gtk_widget_set_sensitive(GTK_WIDGET(item),action->enabled); gtk_tool_button_set_use_underline (GTK_TOOL_BUTTON(item), TRUE); ! text = toMnemonicString(action->short_title ? action->short_title : action->title ? action->title : ""); ! gtk_tool_button_set_label(GTK_TOOL_BUTTON(item), text); ! rfree(text); ! if (action->tooltip) ! gtk_tool_item_set_tooltip(GTK_TOOL_ITEM(item), GTK_TOOLBAR(toolbar)->tooltips, action->tooltip, NULL); ! if (action->type != ACTION_DROPDOWN) { ! gtk_signal_connect (GTK_OBJECT(item), "clicked", ! GTK_SIGNAL_FUNC(tool_item_clicked), ! action); } gtk_signal_connect (GTK_OBJECT(item), "destroy", ! GTK_SIGNAL_FUNC(tool_item_destroy), ! action); ! gtk_toolbar_insert(GTK_TOOLBAR(toolbar), item, pos); gtk_widget_show_all(GTK_WIDGET(item)); + + // add the button to the list of all menu items associated to this action + action->proxies = g_slist_append(action->proxies, item); + return GTK_WIDGET(item); } *************** *** 136,188 **** } - void osSetToolButtonBitmap(ToolHandle toolButton, BitmapHandle bitmap) - { - gtk_image_set_from_pixbuf(GTK_IMAGE(gtk_tool_button_get_icon_widget (GTK_TOOL_BUTTON(toolButton))), bitmap->pixbuf); - } - - void osSetToolButtonEnabled(ToolHandle toolButton, BOOL enabled) - { - gtk_widget_set_sensitive(toolButton,enabled); - } - - BOOL osGetToolButtonEnabled(ToolHandle toolButton) - { - return GTK_WIDGET_SENSITIVE(toolButton); - } - - void osSetToolButtonTip(ToolHandle toolButton, char *text) - { - GtkWidget *toolbar = gtk_widget_get_parent(toolButton); - gtk_tool_item_set_tooltip(GTK_TOOL_ITEM(toolButton), GTK_TOOLBAR(toolbar)->tooltips, text, NULL); - } - - char *osGetToolButtonTip(ToolHandle toolButton) - { - GtkTooltipsData *tips_data = gtk_tooltips_data_get(GTK_BIN (toolButton)->child); - return strdup(tips_data->tip_text); - } - - void osSetToolButtonText(ToolHandle toolButton, char *text) - { - gchar *szText = toMnemonicString(text); - gtk_tool_button_set_label(GTK_TOOL_BUTTON(toolButton), szText); - rfree(szText); - } - - char *osGetToolButtonText(ToolHandle toolButton) - { - return fromMnemonicString(gtk_tool_button_get_label(GTK_TOOL_BUTTON(toolButton))); - } - - void osSetToolButtonChecked(ToolHandle toolButton, BOOL bState) - { - gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON(toolButton), bState); - }; - - BOOL osGetToolButtonChecked(ToolHandle toolButton) - { - return gtk_toggle_tool_button_get_active(GTK_TOGGLE_TOOL_BUTTON(toolButton)); - }; - void osDestroyToolItem(ToolHandle toolItem) { --- 143,146 ---- Index: Util.c =================================================================== RCS file: /cvsroot/htoolkit/port/src/cbits/GTK/Util.c,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** Util.c 8 May 2004 09:21:09 -0000 1.20 --- Util.c 12 May 2004 20:42:34 -0000 1.21 *************** *** 24,28 **** void rfree (void *ptr) { ! free(ptr); } --- 24,29 ---- void rfree (void *ptr) { ! if (ptr) ! free(ptr); } *************** *** 99,102 **** --- 100,104 ---- { gtk_main(); + destroy_all_actions(); handleProcessDestroy(); free(gAppTitle); gAppTitle = NULL; *************** *** 114,119 **** gchar *toMnemonicString(const gchar *source) { ! gchar *dest = (gchar *) rmalloc(strlen(source)*2+1); ! gchar *s = dest; while (*source) --- 116,126 ---- gchar *toMnemonicString(const gchar *source) { ! gchar *dest, *s; ! ! if (!source) ! return NULL; ! ! dest = (gchar *) rmalloc(strlen(source)*2+1); ! s = dest; while (*source) |
From: <kr_...@us...> - 2004-05-12 20:42:50
|
Update of /cvsroot/htoolkit/port/src/Port In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5356/port/src/Port Modified Files: Handlers.hs Menu.hs ToolBar.hs Types.hs Added Files: Action.hs Log Message: This is a major rewrite of menu and toolbar support. The main feature is that the new API provides action based menu and toolbar. The another advantage is that now the code is more simpler and shorter. The low lever API is implemented only under Linux for now. --- NEW FILE: Action.hs --- {-# OPTIONS -fffi -#include Action.h #-} ----------------------------------------------------------------------------------------- {-| Module : Action Copyright : (c) Krasimir Angelov 2003 License : BSD-style Maintainer : ka2...@ya... Stability : provisional Portability : portable Actions represent operations that the user can be perform, along with some information how it should be presented in the interface. There are functions which allows to create menu and toolbar items from a given action. As well as the event that is fired when the action gets activated, the following also gets associated with the action: a label, an accelerator, a tooltip and a toolbar label (usually shorter than label). Apart from regular actions, there are check actions, which can be toggled between two states and radio actions, of which only one in a group can be in the 'selected' state. -} ----------------------------------------------------------------------------------------- module Graphics.UI.Port.Action ( createAction , createCheckAction , createRadioAction , createDropDownAction , setActionRadioGroup , setActionBitmap, getActionBitmap , setActionEnabled, getActionEnabled , setActionTip, getActionTip , setActionText, getActionText , setActionShortText, getActionShortText , setActionChecked, getActionChecked , setActionAccel, getActionAccel , destroyAction ) where import Graphics.UI.Port.Types import Graphics.UI.Port.Handlers import Graphics.UI.Port.PtrMap as PtrMap import Foreign import Foreign.C import Control.Concurrent.MVar foreign import ccall "osCreateAction" createAction :: IO ActionHandle foreign import ccall "osCreateCheckAction" createCheckAction :: IO ActionHandle foreign import ccall "osCreateRadioAction" createRadioAction :: IO ActionHandle foreign import ccall "osCreateDropDownAction" createDropDownAction :: MenuHandle -> IO ActionHandle setActionRadioGroup :: [ActionHandle] -> IO () setActionRadioGroup handles = withArray0 nullHandle handles osSetActionRadioGroup foreign import ccall osSetActionRadioGroup :: Ptr ActionHandle -> IO () setActionBitmap :: ActionHandle -> Maybe Bitmap -> IO () setActionBitmap haction (Just bmp) = do map <- takeMVar actionBitmaps withCBitmap bmp (osSetActionBitmap haction) putMVar actionBitmaps (insert haction bmp map) setActionBitmap haction Nothing = do map <- takeMVar actionBitmaps osSetActionBitmap haction nullPtr putMVar actionBitmaps (delete haction map) foreign import ccall osSetActionBitmap :: ActionHandle -> BitmapHandle -> IO () getActionBitmap :: ActionHandle -> IO (Maybe Bitmap) getActionBitmap haction = do map <- readMVar actionBitmaps return (PtrMap.lookup haction map) foreign import ccall "osSetActionEnabled" setActionEnabled :: ActionHandle -> Bool -> IO () foreign import ccall "osGetActionEnabled" getActionEnabled :: ActionHandle -> IO Bool setActionTip :: ActionHandle -> String -> IO () setActionTip haction tip = withCString tip (osSetActionTip haction) foreign import ccall osSetActionTip :: ActionHandle -> CString -> IO () getActionTip :: ActionHandle -> IO String getActionTip haction = resultCString (osGetActionTip haction) foreign import ccall osGetActionTip :: ActionHandle -> IO CString setActionText :: ActionHandle -> String -> IO () setActionText haction tip = withCString tip (osSetActionText haction) foreign import ccall osSetActionText :: ActionHandle -> CString -> IO () getActionText :: ActionHandle -> IO String getActionText haction = resultCString (osGetActionText haction) foreign import ccall osGetActionText :: ActionHandle -> IO CString setActionShortText :: ActionHandle -> String -> IO () setActionShortText haction tip = withCString tip (osSetActionShortText haction) foreign import ccall osSetActionShortText :: ActionHandle -> CString -> IO () getActionShortText :: ActionHandle -> IO String getActionShortText haction = resultCString (osGetActionShortText haction) foreign import ccall osGetActionShortText :: ActionHandle -> IO CString foreign import ccall "osSetActionChecked" setActionChecked :: ActionHandle -> Bool -> IO () foreign import ccall "osGetActionChecked" getActionChecked :: ActionHandle -> IO Bool getActionAccel :: ActionHandle -> IO Key getActionAccel haction = alloca $ \pckey -> alloca $ \pcmods -> do osGetActionAccel haction pckey pcmods ckey <- peek pckey cmods <- peek pcmods return (fromCKey ckey cmods) foreign import ccall osGetActionAccel :: ActionHandle -> Ptr CInt -> Ptr CWord -> IO () setActionAccel :: ActionHandle -> Key -> IO () setActionAccel haction key = let (ckey,cmods) = toCKey key in osSetActionAccel haction ckey cmods foreign import ccall osSetActionAccel :: ActionHandle -> CInt -> CWord -> IO () foreign import ccall "osDestroyAction" destroyAction :: ActionHandle -> IO () Index: Handlers.hs =================================================================== RCS file: /cvsroot/htoolkit/port/src/Port/Handlers.hs,v retrieving revision 1.32 retrieving revision 1.33 diff -C2 -d -r1.32 -r1.33 *** Handlers.hs 23 Nov 2003 10:23:13 -0000 1.32 --- Handlers.hs 12 May 2004 20:42:34 -0000 1.33 *************** *** 22,36 **** -- * Clean up unregisterAllWindowHandlers ! -- * Timers ! ,registerTimer, unregisterTimer, getAllTimerHandles ! -- ** Events ,setTimerHandler, setTimerDefHandler, getTimerHandler ,setTimerDestroyHandler, setTimerDestroyDefHandler, getTimerDestroyHandler ! -- * Windows ,registerWindow, unregisterWindow, getAllWindowHandles ! -- ** Events ,setContainerReLayoutHandler,setContainerReLayoutDefHandler,getContainerReLayoutHandler --- 22,36 ---- -- * Clean up unregisterAllWindowHandlers ! -- * Timers ! ,registerTimer, unregisterTimer, getAllTimerHandles ! -- ** Events ,setTimerHandler, setTimerDefHandler, getTimerHandler ,setTimerDestroyHandler, setTimerDestroyDefHandler, getTimerDestroyHandler ! -- * Windows ,registerWindow, unregisterWindow, getAllWindowHandles ! -- ** Events ,setContainerReLayoutHandler,setContainerReLayoutDefHandler,getContainerReLayoutHandler *************** *** 41,50 **** ,setWindowScrollHandler, setWindowScrollDefHandler, getWindowScrollHandler ,setWindowMouseHandler, setWindowMouseDefHandler, getWindowMouseHandler ! ,setWindowKeyboardHandler, setWindowKeyboardDefHandler, getWindowKeyboardHandler ,setWindowActivateHandler, setWindowActivateDefHandler, getWindowActivateHandler ,setWindowDeactivateHandler, setWindowDeactivateDefHandler, getWindowDeactivateHandler ,setWindowContextMenuHandler,setWindowContextMenuDefHandler,getWindowContextMenuHandler - -- * Process events ,setProcessDismissHandler, setProcessDismissDefHandler, getProcessDismissHandler --- 41,49 ---- ,setWindowScrollHandler, setWindowScrollDefHandler, getWindowScrollHandler ,setWindowMouseHandler, setWindowMouseDefHandler, getWindowMouseHandler ! ,setWindowKeyboardHandler, setWindowKeyboardDefHandler, getWindowKeyboardHandler ,setWindowActivateHandler, setWindowActivateDefHandler, getWindowActivateHandler ,setWindowDeactivateHandler, setWindowDeactivateDefHandler, getWindowDeactivateHandler ,setWindowContextMenuHandler,setWindowContextMenuDefHandler,getWindowContextMenuHandler -- * Process events ,setProcessDismissHandler, setProcessDismissDefHandler, getProcessDismissHandler *************** *** 53,57 **** -- * Control commands ,setControlCommandHandler, setControlCommandDefHandler, getControlCommandHandler ! -- * TrackBar Increment\/Decrement events ,setTrackBarIncrementHandler, setTrackBarIncrementDefHandler, getTrackBarIncrementHandler --- 52,56 ---- -- * Control commands ,setControlCommandHandler, setControlCommandDefHandler, getControlCommandHandler ! -- * TrackBar Increment\/Decrement events ,setTrackBarIncrementHandler, setTrackBarIncrementDefHandler, getTrackBarIncrementHandler *************** *** 59,69 **** -- * Menu events - ,setMenuCommandHandler, setMenuCommandDefHandler, getMenuCommandHandler - ,setMenuUpdateHandler, setMenuUpdateDefHandler, getMenuUpdateHandler ,setMenuDestroyHandler, setMenuDestroyDefHandler, getMenuDestroyHandler -- * ToolBar events ! ,setToolCommandHandler, setToolCommandDefHandler, getToolCommandHandler ! ,setToolDestroyHandler, setToolDestroyDefHandler, getToolDestroyHandler -- * Indicator events --- 58,70 ---- -- * Menu events ,setMenuDestroyHandler, setMenuDestroyDefHandler, getMenuDestroyHandler -- * ToolBar events ! ,setToolDestroyHandler, setToolDestroyDefHandler, getToolDestroyHandler ! ! -- * Action events ! ,setActionCommandHandler, setActionCommandDefHandler, getActionCommandHandler ! ,setActionUpdateHandler, setActionUpdateDefHandler, getActionUpdateHandler ! ,setActionDestroyHandler, setActionDestroyDefHandler, getActionDestroyHandler -- * Indicator events *************** *** 72,76 **** -- ** Internals ! ,toolBitmaps, menuBitmaps, windowBitmaps ) where --- 73,77 ---- -- ** Internals ! ,actionBitmaps, windowBitmaps ) where *************** *** 94,100 **** invokeHandler :: Ptr a -> MVar (PtrMap a b) -> (b -> IO ()) -> IO () invokeHandler handle varMap f ! = do map <- readMVar varMap case lookup handle map of ! Just x -> safeio (f x) Nothing -> return () --- 95,101 ---- invokeHandler :: Ptr a -> MVar (PtrMap a b) -> (b -> IO ()) -> IO () invokeHandler handle varMap f ! = do map <- readMVar varMap case lookup handle map of ! Just x -> safeio (f x) Nothing -> return () *************** *** 527,587 **** ----------------------------------------------------------------------------------------- - -- MenuUpdate - ----------------------------------------------------------------------------------------- - - {-# NOINLINE handlersMenuUpdate #-} - handlersMenuUpdate :: MVar (PtrMap MenuHandle (IO ())) - handlersMenuUpdate - = unsafePerformIO (newMVar empty) - - setMenuUpdateHandler :: MenuHandle -> IO () -> IO () - setMenuUpdateHandler hmenu handler - = setHandler hmenu handler handlersMenuUpdate - - setMenuUpdateDefHandler :: MenuHandle -> IO () - setMenuUpdateDefHandler hmenu - = setDefHandler hmenu handlersMenuUpdate - - getMenuUpdateHandler :: MenuHandle -> IO (IO ()) - getMenuUpdateHandler hmenu - = getHandler hmenu (return ()) handlersMenuUpdate - - handleMenuUpdate :: MenuHandle -> IO () - handleMenuUpdate hmenu - = invokeHandler hmenu handlersMenuUpdate id - - ----------------------------------------------------------------------------------------- - -- MenuCommand - ----------------------------------------------------------------------------------------- - - {-# NOINLINE handlersMenuCommand #-} - handlersMenuCommand :: MVar (PtrMap MenuHandle (IO ())) - handlersMenuCommand - = unsafePerformIO (newMVar empty) - - setMenuCommandHandler :: MenuHandle -> IO () -> IO () - setMenuCommandHandler hmenu handler - = setHandler hmenu handler handlersMenuCommand - - setMenuCommandDefHandler :: MenuHandle -> IO () - setMenuCommandDefHandler hmenu - = setDefHandler hmenu handlersMenuCommand - - getMenuCommandHandler :: MenuHandle -> IO (IO ()) - getMenuCommandHandler hmenu - = getHandler hmenu (return ()) handlersMenuCommand - - handleMenuCommand :: MenuHandle -> IO () - handleMenuCommand hmenu - = invokeHandler hmenu handlersMenuCommand id - - ----------------------------------------------------------------------------------------- -- MenuDestroy ----------------------------------------------------------------------------------------- - {-# NOINLINE menuBitmaps #-} - menuBitmaps :: MVar (PtrMap MenuHandle Bitmap) - menuBitmaps = unsafePerformIO (newMVar empty) - {-# NOINLINE handlersMenuDestroy #-} handlersMenuDestroy :: MVar (PtrMap MenuHandle (IO ())) --- 528,534 ---- *************** *** 604,611 **** handleMenuDestroy hmenu = do map <- takeMVar handlersMenuDestroy - bmps <- takeMVar toolBitmaps - putMVar toolBitmaps (delete hmenu bmps) - setMenuCommandDefHandler hmenu - setMenuUpdateDefHandler hmenu putMVar handlersMenuDestroy (delete hmenu map) case lookup hmenu map of --- 551,554 ---- *************** *** 613,616 **** --- 556,646 ---- Just io -> safeio io + ----------------------------------------------------------------------------------------- + -- ActionUpdate + ----------------------------------------------------------------------------------------- + + {-# NOINLINE handlersActionUpdate #-} + handlersActionUpdate :: MVar (PtrMap ActionHandle (IO ())) + handlersActionUpdate + = unsafePerformIO (newMVar empty) + + setActionUpdateHandler :: ActionHandle -> IO () -> IO () + setActionUpdateHandler haction handler + = setHandler haction handler handlersActionUpdate + + setActionUpdateDefHandler :: ActionHandle -> IO () + setActionUpdateDefHandler haction + = setDefHandler haction handlersActionUpdate + + getActionUpdateHandler :: ActionHandle -> IO (IO ()) + getActionUpdateHandler haction + = getHandler haction (return ()) handlersActionUpdate + + handleActionUpdate :: ActionHandle -> IO () + handleActionUpdate haction + = invokeHandler haction handlersActionUpdate id + + ----------------------------------------------------------------------------------------- + -- ActionCommand + ----------------------------------------------------------------------------------------- + + {-# NOINLINE handlersActionCommand #-} + handlersActionCommand :: MVar (PtrMap ActionHandle (IO ())) + handlersActionCommand + = unsafePerformIO (newMVar empty) + + setActionCommandHandler :: ActionHandle -> IO () -> IO () + setActionCommandHandler haction handler + = setHandler haction handler handlersActionCommand + + setActionCommandDefHandler :: ActionHandle -> IO () + setActionCommandDefHandler haction + = setDefHandler haction handlersActionCommand + + getActionCommandHandler :: ActionHandle -> IO (IO ()) + getActionCommandHandler haction + = getHandler haction (return ()) handlersActionCommand + + handleActionCommand :: ActionHandle -> IO () + handleActionCommand haction + = invokeHandler haction handlersActionCommand id + + ----------------------------------------------------------------------------------------- + -- ActionDestroy + ----------------------------------------------------------------------------------------- + + {-# NOINLINE actionBitmaps #-} + actionBitmaps :: MVar (PtrMap ActionHandle Bitmap) + actionBitmaps = unsafePerformIO (newMVar empty) + + {-# NOINLINE handlersActionDestroy #-} + handlersActionDestroy :: MVar (PtrMap ActionHandle (IO ())) + handlersActionDestroy + = unsafePerformIO (newMVar empty) + + setActionDestroyHandler :: ActionHandle -> IO () -> IO () + setActionDestroyHandler haction handler + = setHandler haction handler handlersActionDestroy + + setActionDestroyDefHandler :: ActionHandle -> IO () + setActionDestroyDefHandler haction + = setDefHandler haction handlersActionDestroy + + getActionDestroyHandler :: ActionHandle -> IO (IO ()) + getActionDestroyHandler haction + = getHandler haction (return ()) handlersActionDestroy + + handleActionDestroy :: ActionHandle -> IO () + handleActionDestroy haction + = do map <- takeMVar handlersActionDestroy + bmps <- takeMVar actionBitmaps + putMVar actionBitmaps (delete haction bmps) + setActionCommandDefHandler haction + setActionUpdateDefHandler haction + putMVar handlersActionDestroy (delete haction map) + case lookup haction map of + Nothing -> return () + Just io -> safeio io + {----------------------------------------------------------------------------------------- ProcessDismiss *************** *** 743,778 **** ----------------------------------------------------------------------------------------- - -- ToolCommand - ----------------------------------------------------------------------------------------- - - {-# NOINLINE handlersToolCommand #-} - handlersToolCommand :: MVar (PtrMap ToolHandle (IO ())) - handlersToolCommand - = unsafePerformIO (newMVar empty) - - handleToolCommand :: ToolHandle -> IO () - handleToolCommand htool - = invokeHandler htool handlersToolCommand id - - setToolCommandHandler :: ToolHandle -> IO () -> IO () - setToolCommandHandler htool handler - = setHandler htool handler handlersToolCommand - - setToolCommandDefHandler :: ToolHandle -> IO () - setToolCommandDefHandler htool - = setDefHandler htool handlersToolCommand - - getToolCommandHandler :: ToolHandle -> IO (IO ()) - getToolCommandHandler htool - = getHandler htool (return ()) handlersToolCommand - - ----------------------------------------------------------------------------------------- -- ToolDestroy ----------------------------------------------------------------------------------------- - {-# NOINLINE toolBitmaps #-} - toolBitmaps :: MVar (PtrMap WindowHandle Bitmap) - toolBitmaps = unsafePerformIO (newMVar empty) - {-# NOINLINE handlersToolDestroy #-} handlersToolDestroy :: MVar (PtrMap ToolHandle (IO ())) --- 773,779 ---- *************** *** 795,801 **** handleToolDestroy htool = do map <- takeMVar handlersToolDestroy - bmps <- takeMVar toolBitmaps - putMVar toolBitmaps (delete htool bmps) - setToolCommandDefHandler htool putMVar handlersToolDestroy (delete htool map) case lookup htool map of --- 796,799 ---- *************** *** 881,893 **** foreign export ccall handleTrackBarIncrement :: WindowHandle -> IO () foreign export ccall handleTrackBarDecrement :: 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 () foreign export ccall handleProcessDismiss :: IO () foreign export ccall handleProcessDestroy :: IO () - foreign export ccall handleToolCommand :: ToolHandle -> IO () - foreign export ccall handleToolDestroy :: ToolHandle -> IO () foreign export ccall handleIndicatorCommand :: IndicatorHandle -> IO () foreign export ccall handleIndicatorDestroy :: IndicatorHandle -> IO () --- 879,891 ---- foreign export ccall handleTrackBarIncrement :: WindowHandle -> IO () foreign export ccall handleTrackBarDecrement :: WindowHandle -> IO () foreign export ccall handleMenuDestroy :: MenuHandle -> IO () + foreign export ccall handleToolDestroy :: ToolHandle -> IO () + foreign export ccall handleActionCommand :: ActionHandle -> IO () + foreign export ccall handleActionUpdate :: ActionHandle -> IO () + foreign export ccall handleActionDestroy :: ActionHandle -> IO () foreign export ccall handleTimer :: TimerHandle -> IO () foreign export ccall handleTimerDestroy :: TimerHandle -> IO () foreign export ccall handleProcessDismiss :: IO () foreign export ccall handleProcessDestroy :: IO () foreign export ccall handleIndicatorCommand :: IndicatorHandle -> IO () foreign export ccall handleIndicatorDestroy :: IndicatorHandle -> IO () Index: Menu.hs =================================================================== RCS file: /cvsroot/htoolkit/port/src/Port/Menu.hs,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** Menu.hs 15 Nov 2003 10:31:49 -0000 1.12 --- Menu.hs 12 May 2004 20:42:34 -0000 1.13 *************** *** 10,17 **** The module contains all functions for creation and management of menus. ! A menu is a list of items that specify options or groups of options (a submenu). ! Clicking a menu item opens a submenu or causes the application to carry out a command. ! A menu is arranged in a hierarchy. At the top level of the hierarchy is the menu bar; ! which contains a list of menus, which in turn can contain submenus. -} ----------------------------------------------------------------------------------------- --- 10,17 ---- The module contains all functions for creation and management of menus. ! A menu is a list of items that specify options or groups of options (a submenu). ! Clicking a menu item opens a submenu or causes the application to carry out a command. ! A menu is arranged in a hierarchy. At the top level of the hierarchy is the menu bar; ! which contains a list of menus, which in turn can contain submenus. -} ----------------------------------------------------------------------------------------- *************** *** 29,44 **** , insertMenuItem , insertMenuSeparatorItem - , insertMenuCheckItem - , insertMenuRadioItem - , setMenuRadioGroup - , setMenuItemAccel, getMenuItemAccel - , setMenuItemEnabled, getMenuItemEnabled - , setMenuItemChecked, getMenuItemChecked - , setMenuItemBitmap, getMenuItemBitmap -- * Common functions , destroyMenu , getMenuItemPos ! , setMenuLabel, getMenuLabel ! , setMenuTip, getMenuTip ) where --- 29,37 ---- , insertMenuItem , insertMenuSeparatorItem -- * Common functions , destroyMenu , getMenuItemPos ! , setMenuItemEnabled, getMenuItemEnabled ! , setMenuLabel, getMenuLabel ) where *************** *** 64,70 **** ----------------------------------------------------------------------------------------- ! -- | The 'insertMenu' function creates and inserts an item with submenu in the parent menu. ! -- The created submenu is initially empty. You can insert or append menu items by using the ! -- 'insertMenuItem', 'insertMenuCheckItem', 'insertMenuRadioItem' or 'insertMenuSeparatorItem' -- functions. Using the 'insertMenu' you can create nested submenus. insertMenu :: MenuHandle -- ^ The handle of the parent menu. --- 57,63 ---- ----------------------------------------------------------------------------------------- ! -- | The 'insertMenu' function creates and inserts an item with submenu in the parent menu. ! -- The created submenu is initially empty. You can insert or append menu items by using the ! -- 'insertMenuItem', 'insertMenuCheckItem', 'insertMenuRadioItem' or 'insertMenuSeparatorItem' -- functions. Using the 'insertMenu' you can create nested submenus. insertMenu :: MenuHandle -- ^ The handle of the parent menu. *************** *** 77,81 **** foreign import ccall osInsertMenu :: MenuHandle -> Int -> IO MenuHandle ! -- | The 'getMenuItemCount' function determines the number of items in the -- specified popup or sub menu. foreign import ccall "osGetMenuItemCount" getMenuItemCount :: MenuHandle -> IO Int --- 70,74 ---- foreign import ccall osInsertMenu :: MenuHandle -> Int -> IO MenuHandle ! -- | The 'getMenuItemCount' function determines the number of items in the -- specified popup or sub menu. foreign import ccall "osGetMenuItemCount" getMenuItemCount :: MenuHandle -> IO Int *************** *** 91,95 **** foreign import ccall "osCreatePopupMenu" createPopupMenu :: IO MenuHandle -- ^ The handle of the created popup menu. ! -- | The 'trackPopupMenu' function displays a shortcut menu at the specified location in the -- window and tracks the selection of items on the menu. trackPopupMenu :: MenuHandle -- ^ The handle of the popup menu --- 84,88 ---- foreign import ccall "osCreatePopupMenu" createPopupMenu :: IO MenuHandle -- ^ The handle of the created popup menu. ! -- | The 'trackPopupMenu' function displays a shortcut menu at the specified location in the -- window and tracks the selection of items on the menu. trackPopupMenu :: MenuHandle -- ^ The handle of the popup menu *************** *** 106,128 **** -- | Add a menu item. An event handler for a menu item can be -- installed with 'setMenuCommandHandler'. ! 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 'setMenuCommandHandler'. ! 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 radio item. . An event handler for a menu item can be ! -- installed with 'setMenuCommandHandler'. ! insertMenuRadioItem :: MenuHandle -> Maybe Int -> IO MenuHandle ! insertMenuRadioItem handle pos = osInsertMenuRadioItem handle (fromMaybe (-1) pos) ! foreign import ccall osInsertMenuRadioItem :: MenuHandle -> Int -> IO MenuHandle ! ! setMenuRadioGroup :: [MenuHandle] -> IO () ! setMenuRadioGroup handles = withArray0 nullHandle handles osSetMenuRadioGroup ! foreign import ccall osSetMenuRadioGroup :: Ptr MenuHandle -> IO () -- | Add a menu item separator line. --- 99,105 ---- -- | Add a menu item. An event handler for a menu item can be -- installed with 'setMenuCommandHandler'. ! insertMenuItem :: ActionHandle -> MenuHandle -> Maybe Int -> IO MenuHandle ! insertMenuItem haction hmenu pos = osInsertMenuItem haction hmenu (fromMaybe (-1) pos) ! foreign import ccall osInsertMenuItem :: ActionHandle -> MenuHandle -> Int -> IO MenuHandle -- | Add a menu item separator line. *************** *** 131,178 **** 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 - - 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) - ----------------------------------------------------------------------------------------- -- Common functions --- 108,111 ---- *************** *** 181,215 **** -- | 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 - - -- | Change the tooltip of a menu item (or checkable menu item). - setMenuTip :: MenuHandle -> String -> IO () - setMenuTip hmenu tip - = withCString tip (osSetMenuTip hmenu) - foreign import ccall osSetMenuTip :: MenuHandle -> CString -> IO () - - -- | Returns the tooltip of a menu item (or checkable menu item). - getMenuTip :: MenuHandle -> IO String - getMenuTip hmenu - = resultCString (osGetMenuTip hmenu) - foreign import ccall osGetMenuTip :: MenuHandle -> IO CString --- 114,135 ---- -- | 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. ! foreign import ccall "osDestroyMenu" destroyMenu :: MenuHandle -> IO () -- | Returns the position of the item in the parent menu foreign import ccall "osGetMenuItemPos" getMenuItemPos :: MenuHandle -> IO Int + -- | 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 + -- | 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 Index: ToolBar.hs =================================================================== RCS file: /cvsroot/htoolkit/port/src/Port/ToolBar.hs,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** ToolBar.hs 31 Aug 2003 12:56:26 -0000 1.6 --- ToolBar.hs 12 May 2004 20:42:34 -0000 1.7 *************** *** 20,33 **** , insertToolButton - , insertToolCheckButton - , insertToolRadioButton - , insertToolDropDownButton , insertToolLine - , setToolRadioGroup - , setToolButtonBitmap, getToolButtonBitmap - , setToolButtonEnabled, getToolButtonEnabled - , setToolButtonTip, getToolButtonTip - , setToolButtonText, getToolButtonText - , setToolButtonChecked, getToolButtonChecked , getToolItemPos , destroyToolItem --- 20,24 ---- *************** *** 52,74 **** foreign import ccall "osGetToolBarButtonCount" getToolBarButtonCount :: WindowHandle -> IO Int ! insertToolButton :: WindowHandle -> Maybe Int -> IO ToolHandle ! insertToolButton toolBar pos = osInsertToolButton toolBar (fromMaybe (-1) pos) ! foreign import ccall osInsertToolButton :: WindowHandle -> Int -> IO ToolHandle ! ! insertToolCheckButton :: WindowHandle -> Maybe Int -> IO ToolHandle ! insertToolCheckButton toolBar pos = osInsertToolCheckButton toolBar (fromMaybe (-1) pos) ! foreign import ccall osInsertToolCheckButton :: WindowHandle -> Int -> IO ToolHandle ! ! insertToolRadioButton :: WindowHandle -> Maybe Int -> IO ToolHandle ! insertToolRadioButton toolBar pos = osInsertToolRadioButton toolBar (fromMaybe (-1) pos) ! foreign import ccall osInsertToolRadioButton :: WindowHandle -> Int -> IO ToolHandle ! ! setToolRadioGroup :: [ToolHandle] -> IO () ! setToolRadioGroup handles = withArray0 nullHandle handles osSetToolRadioGroup ! foreign import ccall osSetToolRadioGroup :: Ptr ToolHandle -> IO () ! ! insertToolDropDownButton :: WindowHandle -> MenuHandle -> Maybe Int -> IO ToolHandle ! insertToolDropDownButton toolBar menu pos = osInsertToolDropDownButton toolBar menu (fromMaybe (-1) pos) ! foreign import ccall osInsertToolDropDownButton :: WindowHandle -> MenuHandle -> Int -> IO ToolHandle insertToolLine :: WindowHandle -> Maybe Int -> IO ToolHandle --- 43,49 ---- foreign import ccall "osGetToolBarButtonCount" getToolBarButtonCount :: WindowHandle -> IO Int ! insertToolButton :: ActionHandle -> WindowHandle -> Maybe Int -> IO ToolHandle ! insertToolButton action toolBar pos = osInsertToolButton action toolBar (fromMaybe (-1) pos) ! foreign import ccall osInsertToolButton :: ActionHandle -> WindowHandle -> Int -> IO ToolHandle insertToolLine :: WindowHandle -> Maybe Int -> IO ToolHandle *************** *** 76,117 **** foreign import ccall osInsertToolLine :: WindowHandle -> Int -> IO ToolHandle - setToolButtonBitmap :: ToolHandle -> Maybe Bitmap -> IO () - setToolButtonBitmap htool (Just bmp) = do - map <- takeMVar toolBitmaps - withCBitmap bmp (osSetToolButtonBitmap htool) - putMVar toolBitmaps (insert htool bmp map) - setToolButtonBitmap htool Nothing = do - map <- takeMVar toolBitmaps - osSetToolButtonBitmap htool nullPtr - putMVar toolBitmaps (delete htool map) - foreign import ccall osSetToolButtonBitmap :: ToolHandle -> BitmapHandle -> IO () - - getToolButtonBitmap :: ToolHandle -> IO (Maybe Bitmap) - getToolButtonBitmap htool = do - map <- readMVar toolBitmaps - return (PtrMap.lookup htool map) - - foreign import ccall "osSetToolButtonEnabled" setToolButtonEnabled :: ToolHandle -> Bool -> IO () - foreign import ccall "osGetToolButtonEnabled" getToolButtonEnabled :: ToolHandle -> IO Bool - - setToolButtonTip :: ToolHandle -> String -> IO () - setToolButtonTip htool tip = withCString tip (osSetToolButtonTip htool) - foreign import ccall osSetToolButtonTip :: ToolHandle -> CString -> IO () - - getToolButtonTip :: ToolHandle -> IO String - getToolButtonTip htool = resultCString (osGetToolButtonTip htool) - foreign import ccall osGetToolButtonTip :: ToolHandle -> IO CString - - setToolButtonText :: ToolHandle -> String -> IO () - setToolButtonText htool tip = withCString tip (osSetToolButtonText htool) - foreign import ccall osSetToolButtonText :: ToolHandle -> CString -> IO () - - getToolButtonText :: ToolHandle -> IO String - getToolButtonText htool = resultCString (osGetToolButtonText htool) - foreign import ccall osGetToolButtonText :: ToolHandle -> IO CString - - foreign import ccall "osSetToolButtonChecked" setToolButtonChecked :: ToolHandle -> Bool -> IO () - foreign import ccall "osGetToolButtonChecked" getToolButtonChecked :: ToolHandle -> IO Bool - foreign import ccall "osGetToolItemPos" getToolItemPos :: ToolHandle -> IO Int --- 51,54 ---- Index: Types.hs =================================================================== RCS file: /cvsroot/htoolkit/port/src/Port/Types.hs,v retrieving revision 1.37 retrieving revision 1.38 diff -C2 -d -r1.37 -r1.38 *** Types.hs 7 May 2004 07:57:10 -0000 1.37 --- Types.hs 12 May 2004 20:42:34 -0000 1.38 *************** *** 86,89 **** --- 86,90 ---- , TimerHandle , ToolHandle + , ActionHandle , IndicatorHandle , nullHandle *************** *** 156,163 **** data TH = TH ! -- | Abstract handle to a tool type ToolHandle = Ptr TLH data TLH = TLH -- | Abstract handle to a indicator in the status bar type IndicatorHandle = Ptr IH --- 157,168 ---- data TH = TH ! -- | Abstract handle to a tool button type ToolHandle = Ptr TLH data TLH = TLH + -- | Abstract handle to an action + type ActionHandle = Ptr ACT + data ACT = ACT + -- | Abstract handle to a indicator in the status bar type IndicatorHandle = Ptr IH |
Update of /cvsroot/htoolkit/gio/src/Graphics/UI/GIO In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5356/gio/src/Graphics/UI/GIO Modified Files: Attributes.hs Events.hs Menu.hs ToolBar.hs Types.hs Added Files: Action.hs MenuType.hs Log Message: This is a major rewrite of menu and toolbar support. The main feature is that the new API provides action based menu and toolbar. The another advantage is that now the code is more simpler and shorter. The low lever API is implemented only under Linux for now. --- NEW FILE: Action.hs --- ----------------------------------------------------------------------------------------- {-| Module : Action Copyright : (c) Krasimir Angelov 2003 License : BSD-style Maintainer : ka2...@ya... Stability : provisional Portability : portable Actions represent operations that the user can be perform, along with some information how it should be presented in the interface. There are functions which allows to create menu and toolbar items from a given action. As well as the event that is fired when the action gets activated, the following also gets associated with the action: a label, an accelerator, a tooltip and a toolbar label (usually shorter than label). Apart from regular actions, there are check actions, which can be toggled between two states and radio actions, of which only one in a group can be in the 'selected' state. -} ----------------------------------------------------------------------------------------- module Graphics.UI.GIO.Action ( Action, action , CheckAction, checkAction , RadioAction, radioAction, setActionRadioGroup , DropDownAction, dropDownAction , IsAction, haction ) where import Graphics.UI.GIO.Attributes import Graphics.UI.GIO.Events import Graphics.UI.GIO.Types import Graphics.UI.GIO.MenuType import qualified Graphics.UI.Port as Lib class IsAction a where haction :: a -> ActionHandle -------------------------------------------------------------------- -- Action -------------------------------------------------------------------- newtype Action = Action ActionHandle action :: [Prop Action] -> IO Action action props = do act <- do haction <- Lib.createAction return (Action haction) set act props return act instance IsAction Action where haction (Action h) = h instance Able Action where enabled = newStdAttr haction Lib.getActionEnabled Lib.setActionEnabled instance Commanding Action where command = newStdEvent haction Lib.getActionCommandHandler Lib.setActionCommandHandler Lib.setActionCommandDefHandler instance DynamicUpdate Action where update = newStdEvent haction Lib.getActionUpdateHandler Lib.setActionUpdateHandler Lib.setActionUpdateDefHandler instance HasIcon Action where icon = newStdAttr haction Lib.getActionBitmap Lib.setActionBitmap instance Tipped Action where tooltip = newStdAttr haction Lib.getActionTip Lib.setActionTip instance Titled Action where title = newStdAttr haction Lib.getActionText Lib.setActionText shortTitle = newStdAttr haction Lib.getActionShortText Lib.setActionShortText instance Accelerated Action where accel = newStdAttr haction Lib.getActionAccel Lib.setActionAccel instance Deadly Action where destroyWidget t = Lib.destroyAction (haction t) destroy = newStdEvent haction Lib.getActionDestroyHandler Lib.setActionDestroyHandler Lib.setActionDestroyDefHandler -------------------------------------------------------------------- -- CheckAction -------------------------------------------------------------------- newtype CheckAction = CheckAction ActionHandle checkAction :: [Prop CheckAction] -> IO CheckAction checkAction props = do act <- do haction <- Lib.createCheckAction return (CheckAction haction) set act props return act instance IsAction CheckAction where haction (CheckAction h) = h instance Able CheckAction where enabled = newStdAttr haction Lib.getActionEnabled Lib.setActionEnabled instance Commanding CheckAction where command = newStdEvent haction Lib.getActionCommandHandler Lib.setActionCommandHandler Lib.setActionCommandDefHandler instance DynamicUpdate CheckAction where update = newStdEvent haction Lib.getActionUpdateHandler Lib.setActionUpdateHandler Lib.setActionUpdateDefHandler instance HasIcon CheckAction where icon = newStdAttr haction Lib.getActionBitmap Lib.setActionBitmap instance Tipped CheckAction where tooltip = newStdAttr haction Lib.getActionTip Lib.setActionTip instance Titled CheckAction where title = newStdAttr haction Lib.getActionText Lib.setActionText shortTitle = newStdAttr haction Lib.getActionShortText Lib.setActionShortText instance Checked CheckAction where checked = newStdAttr haction Lib.getActionChecked Lib.setActionChecked instance Accelerated CheckAction where accel = newStdAttr haction Lib.getActionAccel Lib.setActionAccel instance Deadly CheckAction where destroyWidget t = Lib.destroyAction (haction t) destroy = newStdEvent haction Lib.getActionDestroyHandler Lib.setActionDestroyHandler Lib.setActionDestroyDefHandler -------------------------------------------------------------------- -- RadioAction -------------------------------------------------------------------- newtype RadioAction = RadioAction ActionHandle radioAction :: [Prop RadioAction] -> IO RadioAction radioAction props = do act <- do haction <- Lib.createRadioAction return (RadioAction haction) set act props return act instance IsAction RadioAction where haction (RadioAction h) = h instance Able RadioAction where enabled = newStdAttr haction Lib.getActionEnabled Lib.setActionEnabled instance Commanding RadioAction where command = newStdEvent haction Lib.getActionCommandHandler Lib.setActionCommandHandler Lib.setActionCommandDefHandler instance DynamicUpdate RadioAction where update = newStdEvent haction Lib.getActionUpdateHandler Lib.setActionUpdateHandler Lib.setActionUpdateDefHandler instance HasIcon RadioAction where icon = newStdAttr haction Lib.getActionBitmap Lib.setActionBitmap instance Tipped RadioAction where tooltip = newStdAttr haction Lib.getActionTip Lib.setActionTip instance Titled RadioAction where title = newStdAttr haction Lib.getActionText Lib.setActionText shortTitle = newStdAttr haction Lib.getActionShortText Lib.setActionShortText instance Checked RadioAction where checked = newStdAttr haction Lib.getActionChecked Lib.setActionChecked instance Accelerated RadioAction where accel = newStdAttr haction Lib.getActionAccel Lib.setActionAccel instance Deadly RadioAction where destroyWidget t = Lib.destroyAction (haction t) destroy = newStdEvent haction Lib.getActionDestroyHandler Lib.setActionDestroyHandler Lib.setActionDestroyDefHandler setActionRadioGroup :: [RadioAction] -> IO () setActionRadioGroup acts = Lib.setActionRadioGroup (map haction acts) -------------------------------------------------------------------- -- DropDownAction -------------------------------------------------------------------- newtype DropDownAction = DropDownAction ActionHandle dropDownAction :: Menu -> [Prop DropDownAction] -> IO DropDownAction dropDownAction menu props = do act <- do haction <- Lib.createDropDownAction (hmenu menu) return (DropDownAction haction) set act props return act instance IsAction DropDownAction where haction (DropDownAction h) = h instance Able DropDownAction where enabled = newStdAttr haction Lib.getActionEnabled Lib.setActionEnabled instance DynamicUpdate DropDownAction where update = newStdEvent haction Lib.getActionUpdateHandler Lib.setActionUpdateHandler Lib.setActionUpdateDefHandler instance HasIcon DropDownAction where icon = newStdAttr haction Lib.getActionBitmap Lib.setActionBitmap instance Tipped DropDownAction where tooltip = newStdAttr haction Lib.getActionTip Lib.setActionTip instance Titled DropDownAction where title = newStdAttr haction Lib.getActionText Lib.setActionText instance Deadly DropDownAction where destroyWidget t = Lib.destroyAction (haction t) destroy = newStdEvent haction Lib.getActionDestroyHandler Lib.setActionDestroyHandler Lib.setActionDestroyDefHandler --- NEW FILE: MenuType.hs --- -- #hide module Graphics.UI.GIO.MenuType where import Graphics.UI.GIO.Types -- | A menu is a widget that contains menu items or other (sub) menus. -- The top level menu is always a 'mainMenu'. newtype Menu = Menu {hmenu :: MenuHandle} Index: Attributes.hs =================================================================== RCS file: /cvsroot/htoolkit/gio/src/Graphics/UI/GIO/Attributes.hs,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** Attributes.hs 23 Nov 2003 16:29:13 -0000 1.21 --- Attributes.hs 12 May 2004 20:42:32 -0000 1.22 *************** *** 37,56 **** ----------------------------------------------------------------------------------------- module Graphics.UI.GIO.Attributes ! ( -- * Attributes and properties Attr, Prop , set1, set, get, with, (=:), (~:), (=::), (~::) ! -- * Generic attribute creators - , mapAttr , newAttr , newStdAttr - , newProp , varAttr , readAttr , writeAttr ! -- * Common widget classes ! -- ** Dimensions , Dimensions --- 37,58 ---- ----------------------------------------------------------------------------------------- module Graphics.UI.GIO.Attributes ! ( -- * Attributes and properties Attr, Prop , set1, set, get, with, (=:), (~:), (=::), (~::) ! -- * Generic attribute creators , newAttr , newStdAttr , varAttr , readAttr , writeAttr ! , mapAttr ! , mapAttrObj ! , newProp ! , mapProp ! -- * Common widget classes ! -- ** Dimensions , Dimensions *************** *** 59,84 **** -- ** HasFont , HasFont, font ! -- ** Drawn , Drawn, bufferMode, pen , color, bgcolor, hatch ! , thickness, capstyle, linestyle, joinstyle , drawMode, bkDrawMode ! -- ** Titled ! , Titled, title -- ** Able , Able, enabled ! -- ** Tipped , Tipped, tooltip ! -- ** Accelerated ! , Accelerated, accel ! -- ** Positioned , Positioned, pos ! -- ** Visible , Visible, visible --- 61,86 ---- -- ** HasFont , HasFont, font ! -- ** Drawn , Drawn, bufferMode, pen , color, bgcolor, hatch ! , thickness, capstyle, linestyle, joinstyle , drawMode, bkDrawMode ! -- ** Titled ! , Titled, title, shortTitle -- ** Able , Able, enabled ! -- ** Tipped , Tipped, tooltip ! -- ** Accelerated ! , Accelerated, accel ! -- ** Positioned , Positioned, pos ! -- ** Visible , Visible, visible *************** *** 91,98 **** , MultiSelect, selection , RangedSelect, range, selectedPos ! -- ** Valued , Valued, value ! -- ** Icon , HasIcon, icon --- 93,100 ---- , MultiSelect, selection , RangedSelect, range, selectedPos ! -- ** Valued , Valued, value ! -- ** Icon , HasIcon, icon *************** *** 108,112 **** --------------------------------------------------------------------} -- | Widgets @w@ can have attributes of type @a@. ! data Attr w a = Attr (w -> IO a) (w -> a -> IO ()) -- | Create a new attribute with a specified getter and setter function. --- 110,114 ---- --------------------------------------------------------------------} -- | Widgets @w@ can have attributes of type @a@. ! data Attr w a = Attr !(w -> IO a) !(w -> a -> IO ()) -- | Create a new attribute with a specified getter and setter function. *************** *** 125,130 **** -- is already associated with a value. Properties are -- constructed with the '(=:)' operator. ! data Prop w = Prop{ propSet :: (w -> IO ()) ! , propRestore :: (w -> IO (IO ())) -- a function that returns a restoration function :-) } --- 127,132 ---- -- is already associated with a value. Properties are -- constructed with the '(=:)' operator. ! data Prop w = Prop{ propSet :: !(w -> IO ()) ! , propRestore :: !(w -> IO (IO ())) -- a function that returns a restoration function :-) } *************** *** 140,143 **** --- 142,153 ---- + -- | (@mapAttrObj f attr@) maps an attribute of @Attr w1 a@ to + -- @Attr w2 b@ where (@f :: w2 -> w1@). + mapAttrObj :: (w2 -> w1) -> Attr w1 a -> Attr w2 a + mapAttrObj f (Attr getter setter) = Attr (getter . f) (setter . f) + + mapProp :: (w2 -> w1) -> Prop w1 -> Prop w2 + mapProp f (Prop set restore) = Prop (set . f) (restore . f) + -- | Helper function to implement an attribute that just gets or sets a 'Var' member. varAttr :: (w -> Var a) -> Attr w a *************** *** 285,288 **** --- 295,303 ---- -- | The title. title :: Attr w String + -- | The short title. The @shortTitle@ attribute is used only in cases when + -- one and the same widget must have two titles: one short and one more desctiptive. + -- If the function is not overriden then the default value is a equal to 'title' + shortTitle :: Attr w String + shortTitle = title -- | Widgets that can be enabled or disabled. Index: Events.hs =================================================================== RCS file: /cvsroot/htoolkit/gio/src/Graphics/UI/GIO/Events.hs,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** Events.hs 31 Aug 2003 11:48:26 -0000 1.17 --- Events.hs 12 May 2004 20:42:32 -0000 1.18 *************** *** 55,63 **** ----------------------------------------------------------------------------------------- module Graphics.UI.GIO.Events ! ( -- * Event Event , on, off , mapEvent -- * Basic events --- 55,64 ---- ----------------------------------------------------------------------------------------- module Graphics.UI.GIO.Events ! ( -- * Event Event , on, off , mapEvent + , mapEventObj -- * Basic events *************** *** 122,126 **** --------------------------------------------------------------------} -- | An event for a widget @w@ that expects an event handler of type @a@. ! data Event w a = Event (Attr w a) (Prop w) -- | Get the event handler attribute for a certain event. --- 123,127 ---- --------------------------------------------------------------------} -- | An event for a widget @w@ that expects an event handler of type @a@. ! data Event w a = Event !(Attr w a) !(Prop w) -- | Get the event handler attribute for a certain event. *************** *** 135,140 **** -- | Change the event type. mapEvent :: (a -> b) -> (a -> b -> a) -> Event w a -> Event w b ! mapEvent get set (Event attr off) ! = Event (mapAttr get set attr) off {-------------------------------------------------------------------- --- 136,144 ---- -- | Change the event type. mapEvent :: (a -> b) -> (a -> b -> a) -> Event w a -> Event w b ! mapEvent get set (Event attr off) = Event (mapAttr get set attr) off ! ! -- | Change the object\'s type in the event. ! mapEventObj :: (w2 -> w1) -> Event w1 a -> Event w2 a ! mapEventObj f (Event attr off) = Event (mapAttrObj f attr) (mapProp f off) {-------------------------------------------------------------------- *************** *** 360,362 **** newStdEvent :: (w -> h) -> (h -> IO a) -> (h -> a -> IO ()) -> (h -> IO ()) -> Event w a newStdEvent map getHandler setHandler setDefHandler ! = newEvent (getHandler . map) (setHandler . map) (setDefHandler . map) \ No newline at end of file --- 364,366 ---- newStdEvent :: (w -> h) -> (h -> IO a) -> (h -> a -> IO ()) -> (h -> IO ()) -> Event w a newStdEvent map getHandler setHandler setDefHandler ! = newEvent (getHandler . map) (setHandler . map) (setDefHandler . map) Index: Menu.hs =================================================================== RCS file: /cvsroot/htoolkit/gio/src/Graphics/UI/GIO/Menu.hs,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** Menu.hs 15 Nov 2003 10:52:30 -0000 1.17 --- Menu.hs 12 May 2004 20:42:32 -0000 1.18 *************** *** 9,16 **** The module contains all utilitites required for creation and management of menus. ! A menu is a list of items that specify options or groups of options (a submenu). ! Clicking a menu item opens a submenu or causes the application to carry out a command. ! A menu is arranged in a hierarchy. At the top level of the hierarchy is the menu bar; ! which contains a list of menus, which in turn can contain submenus. -} ----------------------------------------------------------------------------------------- --- 9,16 ---- The module contains all utilitites required for creation and management of menus. ! A menu is a list of items that specify options or groups of options (a submenu). ! Clicking a menu item opens a submenu or causes the application to carry out a command. ! A menu is arranged in a hierarchy. At the top level of the hierarchy is the menu bar; ! which contains a list of menus, which in turn can contain submenus. -} ----------------------------------------------------------------------------------------- *************** *** 20,23 **** --- 20,25 ---- , popupMenu, trackPopupMenu -- * Menu items + -- ** Action based items + , MenuActionItem, menuActionItemAt, menuActionItem, getMenuAction -- ** Command items , MenuItem, menuitemAt, menuitem *************** *** 41,52 **** import Graphics.UI.GIO.Events import Graphics.UI.GIO.Window {-------------------------------------------------------------------- Menus --------------------------------------------------------------------} - -- | 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 (the menu bar) --- 43,52 ---- import Graphics.UI.GIO.Events import Graphics.UI.GIO.Window + import Graphics.UI.GIO.Action + import Graphics.UI.GIO.MenuType {-------------------------------------------------------------------- Menus --------------------------------------------------------------------} -- | The main application menu (the menu bar) *************** *** 75,79 **** -- | The 'popupMenu' function creates a popup menu. The menu is initially empty. ! -- You can populate it with items by using the 'menuitemAt', 'menucheckAt', -- 'menuRadioItemAt' or 'menulineAt' functions. Using the 'menuAt' you can create nested submenus. popupMenu :: [Prop Menu] -> IO Menu --- 75,79 ---- -- | The 'popupMenu' function creates a popup menu. The menu is initially empty. ! -- You can populate it with items by using the 'menuitemAt', 'menucheckAt', -- 'menuRadioItemAt' or 'menulineAt' functions. Using the 'menuAt' you can create nested submenus. popupMenu :: [Prop Menu] -> IO Menu *************** *** 103,107 **** instance Positioned Menu where pos = readAttr "pos" (Lib.getMenuItemPos . hmenu) ! instance Deadly Menu where destroyWidget m = Lib.destroyMenu (hmenu m) --- 103,107 ---- instance Positioned Menu where pos = readAttr "pos" (Lib.getMenuItemPos . hmenu) ! instance Deadly Menu where destroyWidget m = Lib.destroyMenu (hmenu m) *************** *** 109,226 **** -------------------------------------------------------------------- ! -- 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 = newStdAttr hitem Lib.getMenuItemEnabled Lib.setMenuItemEnabled ! instance Commanding MenuItem where ! command = newStdEvent hitem Lib.getMenuCommandHandler Lib.setMenuCommandHandler Lib.setMenuCommandDefHandler ! ! instance DynamicUpdate MenuItem where ! update = newStdEvent hitem Lib.getMenuUpdateHandler Lib.setMenuUpdateHandler Lib.setMenuUpdateDefHandler ! instance Titled MenuItem where ! title = newStdAttr hitem Lib.getMenuLabel Lib.setMenuLabel ! instance Accelerated MenuItem where ! accel = newStdAttr hitem Lib.getMenuItemAccel Lib.setMenuItemAccel ! instance HasIcon MenuItem where ! icon = newStdAttr hitem Lib.getMenuItemBitmap Lib.setMenuItemBitmap ! ! instance Tipped MenuItem where ! tooltip = newStdAttr hitem Lib.getMenuTip Lib.setMenuTip ! instance Positioned MenuItem where pos = readAttr "pos" (Lib.getMenuItemPos . hitem) ! instance Deadly MenuItem where destroyWidget m = Lib.destroyMenu (hitem m) destroy = newStdEvent hitem Lib.getMenuDestroyHandler Lib.setMenuDestroyHandler Lib.setMenuDestroyDefHandler ! -------------------------------------------------------------------- -- Menu radio items -------------------------------------------------------------------- ! -- | Radio menu items are labeled entries in a menu with bookmark. -- Sometimes, a group of menu items corresponds to a set of mutually exclusive options. -- In this case, you can indicate the selected option by using a selected radio menu item. -- To check a menu item use the 'checked' attribute. ! newtype MenuRadioItem = MenuRadioItem MenuHandle ! hradioitem (MenuRadioItem h) = h -- | Create a radio menu item and insert it at specified position. menuRadioItemAt :: Maybe Int -- ^ The position where to place the item ! -- or Nothing if you want to append it. -> [Prop MenuRadioItem] -- ^ The setup of the radio item attributes -> Menu -- ^ The parent menu -> IO MenuRadioItem -- ^ The created radio item ! menuRadioItemAt pos props menu ! = do mradioitem <- do hradioitem <- Lib.insertMenuRadioItem (hmenu menu) pos ! return (MenuRadioItem hradioitem) ! set mradioitem props ! return mradioitem ! -- | The function is the same as the 'menuRadioItemAt' function but always appends the item. The 'menuRadioItem' -- function is semantically equal to @menuRadioItemAt Nothing@ menuRadioItem :: [Prop MenuRadioItem] -> Menu -> IO MenuRadioItem ! menuRadioItem = menuRadioItemAt Nothing ! ! instance Able MenuRadioItem where ! enabled = newStdAttr hradioitem Lib.getMenuItemEnabled Lib.setMenuItemEnabled ! ! instance Commanding MenuRadioItem where ! command = newStdEvent hradioitem Lib.getMenuCommandHandler Lib.setMenuCommandHandler Lib.setMenuCommandDefHandler ! ! instance DynamicUpdate MenuRadioItem where ! update = newStdEvent hradioitem Lib.getMenuUpdateHandler Lib.setMenuUpdateHandler Lib.setMenuUpdateDefHandler ! ! instance Positioned MenuRadioItem where ! pos = readAttr "pos" (Lib.getMenuItemPos . hradioitem) ! ! instance Checked MenuRadioItem where ! checked = newStdAttr hradioitem Lib.getMenuItemChecked Lib.setMenuItemChecked ! ! instance Deadly MenuRadioItem where ! destroyWidget m = Lib.destroyMenu (hradioitem m) ! destroy = newStdEvent hradioitem Lib.getMenuDestroyHandler Lib.setMenuDestroyHandler Lib.setMenuDestroyDefHandler ! ! instance Titled MenuRadioItem where ! title = newStdAttr hradioitem Lib.getMenuLabel Lib.setMenuLabel ! ! instance Accelerated MenuRadioItem where ! accel = newStdAttr hradioitem Lib.getMenuItemAccel Lib.setMenuItemAccel ! ! instance Tipped MenuRadioItem where ! tooltip = newStdAttr hradioitem Lib.getMenuTip Lib.setMenuTip -- | The 'setMenuRadioGroup' function specifies a set of mutually exclusive options. setMenuRadioGroup :: [MenuRadioItem] -> IO () ! setMenuRadioGroup items = Lib.setMenuRadioGroup (map hradioitem items) ! -------------------------------------------------------------------- -- Checked menu items -------------------------------------------------------------------- -- | Checked menu items are labeled entries in a menu with check mark. ! -- Applications typically check or clear a menu item to indicate whether -- an option is in effect. ! newtype MenuCheck = MenuCheck MenuHandle ! hcheck (MenuCheck h) = h -- | Create a check menu item and insert it at specified position. --- 109,215 ---- -------------------------------------------------------------------- ! -- Action based menu items -------------------------------------------------------------------- ! data MenuActionItem a = MenuActionItem !MenuHandle !a ! hitem (MenuActionItem h action) = h ! menuActionItemAt :: IsAction a => Maybe Int -> [Prop (MenuActionItem a)] -> a -> Menu -> IO (MenuActionItem a) ! menuActionItemAt pos props action menu = do ! mitem <- do ! hitem <- Lib.insertMenuItem (haction action) (hmenu menu) pos ! return (MenuActionItem hitem action) ! set mitem props ! return mitem ! menuActionItem :: IsAction a => [Prop (MenuActionItem a)] -> a -> Menu -> IO (MenuActionItem a) ! menuActionItem = menuActionItemAt Nothing ! getMenuAction :: MenuActionItem a -> a ! getMenuAction (MenuActionItem h action) = action ! instance Able a => Able (MenuActionItem a) where ! enabled = mapAttrObj getMenuAction enabled ! instance Commanding a => Commanding (MenuActionItem a) where ! command = mapEventObj getMenuAction command ! instance DynamicUpdate a => DynamicUpdate (MenuActionItem a) where ! update = mapEventObj getMenuAction update ! instance Titled a => Titled (MenuActionItem a) where ! title = mapAttrObj getMenuAction title ! ! instance HasIcon a => HasIcon (MenuActionItem a) where ! icon = mapAttrObj getMenuAction icon ! ! instance Tipped a => Tipped (MenuActionItem a) where ! tooltip = mapAttrObj getMenuAction tooltip ! ! instance Checked a => Checked (MenuActionItem a) where ! checked = mapAttrObj getMenuAction checked ! ! instance Accelerated a => Accelerated (MenuActionItem a) where ! accel = mapAttrObj getMenuAction accel ! ! instance Positioned (MenuActionItem a) where pos = readAttr "pos" (Lib.getMenuItemPos . hitem) ! instance Deadly (MenuActionItem a) where destroyWidget m = Lib.destroyMenu (hitem m) destroy = newStdEvent hitem Lib.getMenuDestroyHandler Lib.setMenuDestroyHandler Lib.setMenuDestroyDefHandler ! ! -------------------------------------------------------------------- ! -- Menu items ! -------------------------------------------------------------------- ! -- | Menu items are labeled entries in a menu. ! type MenuItem = MenuActionItem Action ! ! -- | Create a menu item and insert it at specified position. ! menuitemAt :: Maybe Int -> [Prop MenuItem] -> Menu -> IO MenuItem ! menuitemAt pos props menu = do ! act <- action [] ! menuActionItemAt pos props act menu ! ! -- | Create a menu item and appends it to parent menu. ! menuitem :: [Prop MenuItem] -> Menu -> IO MenuItem ! menuitem = menuitemAt Nothing ! -------------------------------------------------------------------- -- Menu radio items -------------------------------------------------------------------- ! -- | Radio menu items are labeled entries in a menu with bookmark. -- Sometimes, a group of menu items corresponds to a set of mutually exclusive options. -- In this case, you can indicate the selected option by using a selected radio menu item. -- To check a menu item use the 'checked' attribute. ! type MenuRadioItem = MenuActionItem RadioAction -- | Create a radio menu item and insert it at specified position. menuRadioItemAt :: Maybe Int -- ^ The position where to place the item ! -- or Nothing if you want to append it. -> [Prop MenuRadioItem] -- ^ The setup of the radio item attributes -> Menu -- ^ The parent menu -> IO MenuRadioItem -- ^ The created radio item ! menuRadioItemAt pos props menu = do ! act <- radioAction [] ! menuActionItemAt pos props act menu ! -- | The function is the same as the 'menuRadioItemAt' function but always appends the item. The 'menuRadioItem' -- function is semantically equal to @menuRadioItemAt Nothing@ menuRadioItem :: [Prop MenuRadioItem] -> Menu -> IO MenuRadioItem ! menuRadioItem = menuRadioItemAt Nothing -- | The 'setMenuRadioGroup' function specifies a set of mutually exclusive options. setMenuRadioGroup :: [MenuRadioItem] -> IO () ! setMenuRadioGroup items = setActionRadioGroup (map getMenuAction items) ! -------------------------------------------------------------------- -- Checked menu items -------------------------------------------------------------------- -- | Checked menu items are labeled entries in a menu with check mark. ! -- Applications typically check or clear a menu item to indicate whether -- an option is in effect. ! type MenuCheck = MenuActionItem CheckAction -- | Create a check menu item and insert it at specified position. *************** *** 230,271 **** -> Menu -- ^ The parent menu -> IO MenuCheck -- ^ The created checked item ! menucheckAt pos props menu ! = do mcheck <- do mcheck <- Lib.insertMenuCheckItem (hmenu menu) pos ! return (MenuCheck mcheck) ! set mcheck props ! return mcheck -- | The function is the same as the 'menucheckAt' function but always appends the item. The 'menucheck' -- function is semantically equal to @menucheckAt Nothing@ menucheck :: [Prop MenuCheck] -> Menu -> IO MenuCheck ! menucheck = menucheckAt Nothing ! ! instance Able MenuCheck where ! enabled = newStdAttr hcheck Lib.getMenuItemEnabled Lib.setMenuItemEnabled ! ! instance Commanding MenuCheck where ! command = newStdEvent hcheck Lib.getMenuCommandHandler Lib.setMenuCommandHandler Lib.setMenuCommandDefHandler ! ! instance DynamicUpdate MenuCheck where ! update = newStdEvent hcheck Lib.getMenuUpdateHandler Lib.setMenuUpdateHandler Lib.setMenuUpdateDefHandler ! ! instance Titled MenuCheck where ! title = newStdAttr hcheck Lib.getMenuLabel Lib.setMenuLabel ! ! instance Accelerated MenuCheck where ! accel = newStdAttr hcheck Lib.getMenuItemAccel Lib.setMenuItemAccel ! ! instance Tipped MenuCheck where ! tooltip = newStdAttr hcheck Lib.getMenuTip Lib.setMenuTip ! ! instance Positioned MenuCheck where ! pos = readAttr "pos" (Lib.getMenuItemPos . hcheck) ! ! instance Checked MenuCheck where ! checked = newStdAttr hcheck Lib.getMenuItemChecked Lib.setMenuItemChecked ! ! instance Deadly MenuCheck where ! destroyWidget m = Lib.destroyMenu (hcheck m) ! destroy = newStdEvent hcheck Lib.getMenuDestroyHandler Lib.setMenuDestroyHandler Lib.setMenuDestroyDefHandler -------------------------------------------------------------------- --- 219,230 ---- -> Menu -- ^ The parent menu -> IO MenuCheck -- ^ The created checked item ! menucheckAt pos props menu = do ! act <- checkAction [] ! menuActionItemAt pos props act menu -- | The function is the same as the 'menucheckAt' function but always appends the item. The 'menucheck' -- function is semantically equal to @menucheckAt Nothing@ menucheck :: [Prop MenuCheck] -> Menu -> IO MenuCheck ! menucheck = menucheckAt Nothing -------------------------------------------------------------------- Index: ToolBar.hs =================================================================== RCS file: /cvsroot/htoolkit/gio/src/Graphics/UI/GIO/ToolBar.hs,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** ToolBar.hs 15 Nov 2003 10:52:30 -0000 1.8 --- ToolBar.hs 12 May 2004 20:42:32 -0000 1.9 *************** *** 15,18 **** --- 15,19 ---- -- * Creation ToolBar, toolBar + , ToolActionButton, toolActionButtonAt, toolActionButton, getToolButtonAction , ToolButton, toolButtonAt, toolButton , ToolCheckButton, toolCheckButtonAt, toolCheckButton *************** *** 26,29 **** --- 27,31 ---- import Graphics.UI.GIO.Types import Graphics.UI.GIO.Menu + import Graphics.UI.GIO.Action import qualified Graphics.UI.Port as Lib *************** *** 52,130 **** -------------------------------------------------------------------- ! data ToolButton = ToolButton {hbutton :: ToolHandle} ! toolButtonAt :: Maybe Int -> [Prop ToolButton] -> ToolBar -> IO ToolButton ! toolButtonAt pos props (ToolBar hwnd) = do ! btn <- do hbtn <- Lib.insertToolButton hwnd pos ! return (ToolButton hbtn) set btn props return btn ! toolButton :: [Prop ToolButton] -> ToolBar -> IO ToolButton ! toolButton = toolButtonAt Nothing ! instance Able ToolButton where ! enabled = newStdAttr hbutton Lib.getToolButtonEnabled Lib.setToolButtonEnabled ! instance Commanding ToolButton where ! command = ! newStdEvent hbutton Lib.getToolCommandHandler Lib.setToolCommandHandler Lib.setToolCommandDefHandler ! instance HasIcon ToolButton where ! icon = newStdAttr hbutton Lib.getToolButtonBitmap Lib.setToolButtonBitmap ! instance Positioned ToolButton where ! pos = readAttr "pos" (Lib.getToolItemPos . hbutton) ! instance Tipped ToolButton where ! tooltip = newStdAttr hbutton Lib.getToolButtonTip Lib.setToolButtonTip ! instance Titled ToolButton where ! title = newStdAttr hbutton Lib.getToolButtonText Lib.setToolButtonText ! instance Deadly ToolButton where destroyWidget t = Lib.destroyToolItem (hbutton t) destroy = newStdEvent hbutton Lib.getToolDestroyHandler Lib.setToolDestroyHandler Lib.setToolDestroyDefHandler -------------------------------------------------------------------- ! -- ToolCheckButton -------------------------------------------------------------------- ! data ToolCheckButton = ToolCheckButton {hcheck :: ToolHandle} ! ! toolCheckButtonAt :: Maybe Int -> [Prop ToolCheckButton] -> ToolBar -> IO ToolCheckButton ! toolCheckButtonAt pos props (ToolBar hwnd) = do ! btn <- do hbtn <- Lib.insertToolCheckButton hwnd pos ! return (ToolCheckButton hbtn) ! set btn props ! return btn ! ! toolCheckButton :: [Prop ToolCheckButton] -> ToolBar -> IO ToolCheckButton ! toolCheckButton = toolCheckButtonAt Nothing ! ! instance Able ToolCheckButton where ! enabled = newStdAttr hcheck Lib.getToolButtonEnabled Lib.setToolButtonEnabled ! ! instance Commanding ToolCheckButton where ! command = newStdEvent hcheck Lib.getToolCommandHandler Lib.setToolCommandHandler Lib.setToolCommandDefHandler ! instance HasIcon ToolCheckButton where ! icon = newStdAttr hcheck Lib.getToolButtonBitmap Lib.setToolButtonBitmap ! instance Positioned ToolCheckButton where ! pos = readAttr "pos" (Lib.getToolItemPos . hcheck) ! instance Tipped ToolCheckButton where ! tooltip = newStdAttr hcheck Lib.getToolButtonTip Lib.setToolButtonTip ! instance Titled ToolCheckButton where ! title = newStdAttr hcheck Lib.getToolButtonText Lib.setToolButtonText ! instance Checked ToolCheckButton where ! checked = newStdAttr hcheck Lib.getToolButtonChecked Lib.setToolButtonChecked ! instance Deadly ToolCheckButton where ! destroyWidget t = Lib.destroyToolItem (hcheck t) ! destroy = newStdEvent hcheck Lib.getToolDestroyHandler Lib.setToolDestroyHandler Lib.setToolDestroyDefHandler -------------------------------------------------------------------- --- 54,126 ---- -------------------------------------------------------------------- ! data ToolActionButton a = ToolActionButton !ToolHandle !a ! hbutton (ToolActionButton handle action) = handle ! toolActionButtonAt :: IsAction a => Maybe Int -> [Prop (ToolActionButton a)] -> a -> ToolBar -> IO (ToolActionButton a) ! toolActionButtonAt pos props action (ToolBar hwnd) = do ! btn <- do ! hbtn <- Lib.insertToolButton (haction action) hwnd pos ! return (ToolActionButton hbtn action) set btn props return btn ! toolActionButton :: IsAction a => [Prop (ToolActionButton a)] -> a -> ToolBar -> IO (ToolActionButton a) ! toolActionButton = toolActionButtonAt Nothing ! getToolButtonAction :: ToolActionButton a -> a ! getToolButtonAction (ToolActionButton handle action) = action ! instance Able a => Able (ToolActionButton a) where ! enabled = mapAttrObj getToolButtonAction enabled ! instance Commanding a => Commanding (ToolActionButton a) where ! command = mapEventObj getToolButtonAction command ! instance HasIcon a => HasIcon (ToolActionButton a) where ! icon = mapAttrObj getToolButtonAction icon ! instance Tipped a => Tipped (ToolActionButton a) where ! tooltip = mapAttrObj getToolButtonAction tooltip ! instance Titled a => Titled (ToolActionButton a) where ! title = mapAttrObj getToolButtonAction shortTitle ! instance Checked a => Checked (ToolActionButton a) where ! checked = mapAttrObj getToolButtonAction checked ! ! instance Positioned (ToolActionButton a) where ! pos = readAttr "pos" (Lib.getToolItemPos . hbutton) ! ! instance Deadly (ToolActionButton a) where destroyWidget t = Lib.destroyToolItem (hbutton t) destroy = newStdEvent hbutton Lib.getToolDestroyHandler Lib.setToolDestroyHandler Lib.setToolDestroyDefHandler -------------------------------------------------------------------- ! -- ToolButton -------------------------------------------------------------------- ! type ToolButton = ToolActionButton Action ! toolButtonAt :: Maybe Int -> [Prop ToolButton] -> ToolBar -> IO ToolButton ! toolButtonAt pos props toolbar = do ! act <- action [] ! toolActionButtonAt pos props act toolbar ! toolButton :: [Prop ToolButton] -> ToolBar -> IO ToolButton ! toolButton = toolButtonAt Nothing ! -------------------------------------------------------------------- ! -- ToolCheckButton ! -------------------------------------------------------------------- ! type ToolCheckButton = ToolActionButton CheckAction ! toolCheckButtonAt :: Maybe Int -> [Prop ToolCheckButton] -> ToolBar -> IO ToolCheckButton ! toolCheckButtonAt pos props toolbar = do ! act <- checkAction [] ! toolActionButtonAt pos props act toolbar ! toolCheckButton :: [Prop ToolCheckButton] -> ToolBar -> IO ToolCheckButton ! toolCheckButton = toolCheckButtonAt Nothing -------------------------------------------------------------------- *************** *** 132,174 **** -------------------------------------------------------------------- ! data ToolRadioButton = ToolRadioButton {hradio :: ToolHandle} toolRadioButtonAt :: Maybe Int -> [Prop ToolRadioButton] -> ToolBar -> IO ToolRadioButton ! toolRadioButtonAt pos props (ToolBar hwnd) = do ! btn <- do hbtn <- Lib.insertToolRadioButton hwnd pos ! return (ToolRadioButton hbtn) ! set btn props ! return btn toolRadioButton :: [Prop ToolRadioButton] -> ToolBar -> IO ToolRadioButton toolRadioButton = toolRadioButtonAt Nothing ! instance Able ToolRadioButton where ! enabled = newStdAttr hradio Lib.getToolButtonEnabled Lib.setToolButtonEnabled ! ! instance Commanding ToolRadioButton where ! command = newStdEvent hradio Lib.getToolCommandHandler Lib.setToolCommandHandler Lib.setToolCommandDefHandler ! ! instance HasIcon ToolRadioButton where ! icon = newStdAttr hradio Lib.getToolButtonBitmap Lib.setToolButtonBitmap ! ! instance Positioned ToolRadioButton where ! pos = readAttr "pos" (Lib.getToolItemPos . hradio) ! ! instance Tipped ToolRadioButton where ! tooltip = newStdAttr hradio Lib.getToolButtonTip Lib.setToolButtonTip ! ! instance Titled ToolRadioButton where ! title = newStdAttr hradio Lib.getToolButtonText Lib.setToolButtonText ! ! instance Checked ToolRadioButton where ! checked = newStdAttr hradio Lib.getToolButtonChecked Lib.setToolButtonChecked ! ! instance Deadly ToolRadioButton where ! destroyWidget t = Lib.destroyToolItem (hradio t) ! destroy = newStdEvent hradio Lib.getToolDestroyHandler Lib.setToolDestroyHandler Lib.setToolDestroyDefHandler ! setToolRadioGroup :: [ToolRadioButton] -> IO () ! setToolRadioGroup btns = Lib.setToolRadioGroup (map hradio btns) -------------------------------------------------------------------- --- 128,144 ---- -------------------------------------------------------------------- ! type ToolRadioButton = ToolActionButton RadioAction toolRadioButtonAt :: Maybe Int -> [Prop ToolRadioButton] -> ToolBar -> IO ToolRadioButton ! toolRadioButtonAt pos props toolbar = do ! act <- radioAction [] ! toolActionButtonAt pos props act toolbar toolRadioButton :: [Prop ToolRadioButton] -> ToolBar -> IO ToolRadioButton toolRadioButton = toolRadioButtonAt Nothing ! -- | The 'setToolRadioGroup' function specifies a set of mutually exclusive options. setToolRadioGroup :: [ToolRadioButton] -> IO () ! setToolRadioGroup items = setActionRadioGroup (map getToolButtonAction items) -------------------------------------------------------------------- *************** *** 176,210 **** -------------------------------------------------------------------- ! data ToolDropDownButton = ToolDropDownButton {hdropdown :: ToolHandle} toolDropDownButtonAt :: Maybe Int -> Menu -> [Prop ToolDropDownButton] -> ToolBar -> IO ToolDropDownButton ! toolDropDownButtonAt pos menu props (ToolBar hwnd) = do ! btn <- do hbtn <- Lib.insertToolDropDownButton hwnd (hmenu menu) pos ! return (ToolDropDownButton hbtn) ! set btn props ! return btn toolDropDownButton :: Menu -> [Prop ToolDropDownButton] -> ToolBar -> IO ToolDropDownButton toolDropDownButton = toolDropDownButtonAt Nothing - instance Able ToolDropDownButton where - enabled = newStdAttr hdropdown Lib.getToolButtonEnabled Lib.setToolButtonEnabled - - instance HasIcon ToolDropDownButton where - icon = newStdAttr hdropdown Lib.getToolButtonBitmap Lib.setToolButtonBitmap - - instance Positioned ToolDropDownButton where - pos = readAttr "pos" (Lib.getToolItemPos . hdropdown) - - instance Tipped ToolDropDownButton where - tooltip = newStdAttr hdropdown Lib.getToolButtonTip Lib.setToolButtonTip - - instance Titled ToolDropDownButton where - title = newStdAttr hdropdown Lib.getToolButtonText Lib.setToolButtonText - - instance Deadly ToolDropDownButton where - destroyWidget t = Lib.destroyToolItem (hdropdown t) - destroy = newStdEvent hdropdown Lib.getToolDestroyHandler Lib.setToolDestroyHandler Lib.setToolDestroyDefHandler - -------------------------------------------------------------------- -- ToolLine --- 146,159 ---- -------------------------------------------------------------------- ! type ToolDropDownButton = ToolActionButton DropDownAction toolDropDownButtonAt :: Maybe Int -> Menu -> [Prop ToolDropDownButton] -> ToolBar -> IO ToolDropDownButton ! toolDropDownButtonAt pos menu props toolbar = do ! act <- dropDownAction menu [] ! toolActionButtonAt pos props act toolbar toolDropDownButton :: Menu -> [Prop ToolDropDownButton] -> ToolBar -> IO ToolDropDownButton toolDropDownButton = toolDropDownButtonAt Nothing -------------------------------------------------------------------- -- ToolLine Index: Types.hs =================================================================== RCS file: /cvsroot/htoolkit/gio/src/Graphics/UI/GIO/Types.hs,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** Types.hs 6 May 2004 10:27:47 -0000 1.19 --- Types.hs 12 May 2004 20:42:32 -0000 1.20 *************** *** 111,114 **** --- 111,115 ---- , MenuHandle , ToolHandle + , ActionHandle , IndicatorHandle , FontHandle |
From: <kr_...@us...> - 2004-05-12 20:42:44
|
Update of /cvsroot/htoolkit/port/src/include In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5356/port/src/include Modified Files: HsPort.h Menu.h ToolBar.h Types.h Added Files: Action.h Log Message: This is a major rewrite of menu and toolbar support. The main feature is that the new API provides action based menu and toolbar. The another advantage is that now the code is more simpler and shorter. The low lever API is implemented only under Linux for now. --- NEW FILE: Action.h --- #ifndef ACTION_H #define ACTION_H #include "Types.h" ActionHandle osCreateAction(); ActionHandle osCreateCheckAction(); ActionHandle osCreateRadioAction(); ActionHandle osCreateDropDownAction(MenuHandle menu); void osSetActionRadioGroup(ActionHandle *handles); void osSetActionBitmap(ActionHandle action, BitmapHandle bitmap); void osSetActionEnabled(ActionHandle action, BOOL enabled); BOOL osGetActionEnabled(ActionHandle toolButton); void osSetActionTip(ActionHandle action, char *text); char *osGetActionTip(ActionHandle action); void osSetActionText(ActionHandle action, char *text); char *osGetActionText(ActionHandle action); void osSetActionShortText(ActionHandle action, char *text); char *osGetActionShortText(ActionHandle action); void osSetActionChecked(ActionHandle action, BOOL checked); BOOL osGetActionChecked(ActionHandle action); void osSetActionAccel(ActionHandle action, int key, unsigned int mods); void osGetActionAccel(ActionHandle action, int *key, unsigned int *mods); void osDestroyAction(ActionHandle action); #endif Index: HsPort.h =================================================================== RCS file: /cvsroot/htoolkit/port/src/include/HsPort.h,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** HsPort.h 24 Nov 2003 23:22:39 -0000 1.11 --- HsPort.h 12 May 2004 20:42:34 -0000 1.12 *************** *** 26,27 **** --- 26,29 ---- #include "port/Notebook.h" #include "port/GroupBox.h" + #include "port/Action.h" + Index: Menu.h =================================================================== RCS file: /cvsroot/htoolkit/port/src/include/Menu.h,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** Menu.h 15 Nov 2003 10:31:50 -0000 1.9 --- Menu.h 12 May 2004 20:42:34 -0000 1.10 *************** *** 1,38 **** ! #ifndef MENU_H ! #define MENU_H ! ! #include "Types.h" ! ! MenuHandle osCreatePopupMenu(); ! void osTrackPopupMenu(MenuHandle handle, WindowHandle hwnd, int x, int y); ! ! MenuHandle osInsertMenu(MenuHandle parent, int pos); ! MenuHandle osInsertMenuItem(MenuHandle parent, int pos); ! MenuHandle osInsertMenuCheckItem(MenuHandle parent, int pos); ! MenuHandle osInsertMenuSeparatorItem(MenuHandle parent, int pos); ! MenuHandle osInsertMenuRadioItem(MenuHandle parent, int pos); ! ! void osSetMenuRadioGroup(MenuHandle *handles); ! ! 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 osSetMenuLabel(MenuHandle item, char* title); ! char *osGetMenuLabel(MenuHandle item); ! void osSetMenuTip(MenuHandle item, char* tip); ! char *osGetMenuTip(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 --- 1,25 ---- ! #ifndef MENU_H ! #define MENU_H ! ! #include "Types.h" ! ! MenuHandle osCreatePopupMenu(); ! void osTrackPopupMenu(MenuHandle handle, WindowHandle hwnd, int x, int y); ! ! MenuHandle osInsertMenu(MenuHandle parent, int pos); ! MenuHandle osInsertMenuItem(ActionHandle haction, MenuHandle hmenu, int pos); ! MenuHandle osInsertMenuSeparatorItem(MenuHandle parent, int pos); ! ! void osDestroyMenu(MenuHandle handle); ! ! int osGetMenuItemCount(MenuHandle handle); ! ! void osSetMenuItemEnabled(MenuHandle item, BOOL bState); ! BOOL osGetMenuItemEnabled(MenuHandle item); ! ! void osSetMenuLabel(MenuHandle item, char* title); ! char *osGetMenuLabel(MenuHandle item); ! ! int osGetMenuItemPos(MenuHandle handle); ! ! #endif Index: ToolBar.h =================================================================== RCS file: /cvsroot/htoolkit/port/src/include/ToolBar.h,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** ToolBar.h 31 Aug 2003 12:56:26 -0000 1.8 --- ToolBar.h 12 May 2004 20:42:34 -0000 1.9 *************** *** 8,28 **** int osGetToolBarButtonCount(WindowHandle toolbar); ! ToolHandle osInsertToolButton(WindowHandle toolbar, int pos); ! ToolHandle osInsertToolCheckButton(WindowHandle toolbar, int pos); ! ToolHandle osInsertToolRadioButton(WindowHandle toolBar, int pos); ! ToolHandle osInsertToolDropDownButton(WindowHandle toolBar, MenuHandle hmenu, int pos); ToolHandle osInsertToolLine(WindowHandle toolbar, int pos); - void osSetToolRadioGroup(ToolHandle *handles); - void osSetToolButtonBitmap(ToolHandle toolButton, BitmapHandle bitmap); - void osSetToolButtonEnabled(ToolHandle toolButton, BOOL bEnabled); - BOOL osGetToolButtonEnabled(ToolHandle toolButton); - void osSetToolButtonTip(ToolHandle toolButton, char *text); - char *osGetToolButtonTip(ToolHandle toolButton); - void osSetToolButtonText(ToolHandle toolButton, char *text); - char *osGetToolButtonText(ToolHandle toolButton); void osDestroyToolItem(ToolHandle toolItem); int osGetToolItemPos(ToolHandle toolItem); - void osSetToolButtonChecked(ToolHandle toolButton, BOOL bState); - BOOL osGetToolButtonChecked(ToolHandle toolButton); #endif --- 8,15 ---- int osGetToolBarButtonCount(WindowHandle toolbar); ! ToolHandle osInsertToolButton(ActionHandle action, WindowHandle toolbar, int pos); ToolHandle osInsertToolLine(WindowHandle toolbar, int pos); void osDestroyToolItem(ToolHandle toolItem); int osGetToolItemPos(ToolHandle toolItem); #endif Index: Types.h =================================================================== RCS file: /cvsroot/htoolkit/port/src/include/Types.h,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** Types.h 8 May 2004 09:21:10 -0000 1.22 --- Types.h 12 May 2004 20:42:34 -0000 1.23 *************** *** 49,52 **** --- 49,54 ---- typedef struct ToolHandle *ToolHandle; + typedef struct ActionHandle *ActionHandle; + typedef struct IndicatorHandle { *************** *** 114,121 **** typedef GtkWidget *MenuHandle; - typedef GtkWidget *MenuItemHandle; typedef GtkWidget *ToolHandle; typedef GtkWidget *IndicatorHandle; --- 116,124 ---- typedef GtkWidget *MenuHandle; typedef GtkWidget *ToolHandle; + typedef struct ActionHandle *ActionHandle; + typedef GtkWidget *IndicatorHandle; |
From: <kr_...@us...> - 2004-05-12 20:42:43
|
Update of /cvsroot/htoolkit/port/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5356/port/src Modified Files: Port.hs Log Message: This is a major rewrite of menu and toolbar support. The main feature is that the new API provides action based menu and toolbar. The another advantage is that now the code is more simpler and shorter. The low lever API is implemented only under Linux for now. Index: Port.hs =================================================================== RCS file: /cvsroot/htoolkit/port/src/Port.hs,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** Port.hs 14 Nov 2003 22:35:20 -0000 1.19 --- Port.hs 12 May 2004 20:42:33 -0000 1.20 *************** *** 29,36 **** , module Graphics.UI.Port.Font , module Graphics.UI.Port.Bitmap ! -- ** Timers , module Graphics.UI.Port.Timer -- ** Process , module Graphics.UI.Port.Process --- 29,39 ---- , module Graphics.UI.Port.Font , module Graphics.UI.Port.Bitmap ! -- ** Timers , module Graphics.UI.Port.Timer + -- ** Actions + , module Graphics.UI.Port.Action + -- ** Process , module Graphics.UI.Port.Process *************** *** 39,43 **** , module Graphics.UI.Port.Handlers , module Graphics.UI.Port.Types ! -- ** Configuration , module Graphics.UI.Port.ConfigKey --- 42,46 ---- , module Graphics.UI.Port.Handlers , module Graphics.UI.Port.Types ! -- ** Configuration , module Graphics.UI.Port.ConfigKey *************** *** 45,49 **** import Graphics.UI.Port.Menu ! import Graphics.UI.Port.Window import Graphics.UI.Port.CommonDialogs import Graphics.UI.Port.Message --- 48,52 ---- import Graphics.UI.Port.Menu ! import Graphics.UI.Port.Window import Graphics.UI.Port.CommonDialogs import Graphics.UI.Port.Message *************** *** 59,62 **** --- 62,67 ---- import Graphics.UI.Port.Timer + import Graphics.UI.Port.Action + import Graphics.UI.Port.Process |
From: <kr_...@us...> - 2004-05-12 20:42:42
|
Update of /cvsroot/htoolkit/gio/src/Graphics/UI In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5356/gio/src/Graphics/UI Modified Files: GIO.hs Log Message: This is a major rewrite of menu and toolbar support. The main feature is that the new API provides action based menu and toolbar. The another advantage is that now the code is more simpler and shorter. The low lever API is implemented only under Linux for now. Index: GIO.hs =================================================================== RCS file: /cvsroot/htoolkit/gio/src/Graphics/UI/GIO.hs,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** GIO.hs 15 Nov 2003 10:34:14 -0000 1.12 --- GIO.hs 12 May 2004 20:42:16 -0000 1.13 *************** *** 27,30 **** --- 27,31 ---- , module Graphics.UI.GIO.Timer , module Graphics.UI.GIO.Menu + , module Graphics.UI.GIO.Action , module Graphics.UI.GIO.Layout , module Graphics.UI.GIO.Controls *************** *** 45,49 **** import Graphics.UI.GIO.Timer import Graphics.UI.GIO.Menu import Graphics.UI.GIO.Layout import Graphics.UI.GIO.Controls ! import Graphics.UI.GIO.Process \ No newline at end of file --- 46,51 ---- import Graphics.UI.GIO.Timer import Graphics.UI.GIO.Menu + import Graphics.UI.GIO.Action import Graphics.UI.GIO.Layout import Graphics.UI.GIO.Controls ! import Graphics.UI.GIO.Process |
From: <kr_...@us...> - 2004-05-12 20:42:42
|
Update of /cvsroot/htoolkit/port In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5356/port Modified Files: makefile Log Message: This is a major rewrite of menu and toolbar support. The main feature is that the new API provides action based menu and toolbar. The another advantage is that now the code is more simpler and shorter. The low lever API is implemented only under Linux for now. Index: makefile =================================================================== RCS file: /cvsroot/htoolkit/port/makefile,v retrieving revision 1.45 retrieving revision 1.46 diff -C2 -d -r1.45 -r1.46 *** makefile 24 Nov 2003 22:40:41 -0000 1.45 --- makefile 12 May 2004 20:42:32 -0000 1.46 *************** *** 42,45 **** --- 42,46 ---- Port/ToolBar.hs \ Port/StatusBar.hs \ + Port/Action.hs \ Port.hs *************** *** 49,53 **** FileDialog.c ColorDialog.c FontDialog.c AboutDialog.c PopUp.c Canvas.c Menu.c ListBox.c \ Label.c Font.c RadioBox.c Timer.c Frame.c Message.c Slider.c TrackBar.c ProgressBar.c \ ! ConfigKey.c ToolBar.c StatusBar.c Notebook.c GroupBox.c ifeq "$(GUILIB)" "WIN32" --- 50,54 ---- FileDialog.c ColorDialog.c FontDialog.c AboutDialog.c PopUp.c Canvas.c Menu.c ListBox.c \ Label.c Font.c RadioBox.c Timer.c Frame.c Message.c Slider.c TrackBar.c ProgressBar.c \ ! ConfigKey.c ToolBar.c StatusBar.c Notebook.c GroupBox.c Action.c ifeq "$(GUILIB)" "WIN32" *************** *** 117,124 **** HOBJS = $(patsubst %.hs,$(HOUTDIR)/%.o, $(HSRCS)) ! HDEPS = $(patsubst %.hs,$(HOUTDIR)/%.d, $(HSRCS)) ! COBJS = $(patsubst %.c,$(COUTDIR)/%.c.o, $(CSRCS)) ! CDEPS = $(patsubst %.c,$(COUTDIR)/%.c.d, $(CSRCS)) STUBOBJS = $(patsubst %.hs,$(HOUTDIR)/%.o, $(STUBS)) --- 118,125 ---- HOBJS = $(patsubst %.hs,$(HOUTDIR)/%.o, $(HSRCS)) ! HDEPS = $(patsubst %.hs,$(HOUTDIR)/%.d, $(HSRCS)) ! COBJS = $(patsubst %.c,$(COUTDIR)/%.c.o, $(CSRCS)) ! CDEPS = $(patsubst %.c,$(COUTDIR)/%.c.d, $(CSRCS)) STUBOBJS = $(patsubst %.hs,$(HOUTDIR)/%.o, $(STUBS)) *************** *** 132,136 **** # The main targets ! .PHONY: all release all: release doc --- 133,137 ---- # The main targets ! .PHONY: all release all: release doc *************** *** 162,166 **** # by sed to prepend the proper directory to the target and to move it # into the proper directory (debug or release). The way dependency files ! # are handled was 'discovered' by Tom Tromey, and described by Paul Smith, # see: "http://www.paulandlesley.org/gmake/autodep.html" .SUFFIXES: .hs .hi .o .c --- 163,167 ---- # by sed to prepend the proper directory to the target and to move it # into the proper directory (debug or release). The way dependency files ! # are handled was 'discovered' by Tom Tromey, and described by Paul Smith, # see: "http://www.paulandlesley.org/gmake/autodep.html" .SUFFIXES: .hs .hi .o .c *************** *** 169,175 **** $(HC) -o $@ -package-name port -ohi $(BUILDDIR)/Graphics/UI/$(*D)/$(*F).hi -odir $(HOUTDIR)/$(*D) -c $< $(HC-OPTIONS) $($(*F)_OPTIONS) -i$(BUILDDIR) $(INCDIRS) @# move stub files ! @-if test -f $(<D)/$(*F)_stub.h; then $(MV) $(<D)/$(*F)_stub.[ch] $(HOUTDIR)/$(*D); fi @# create dependency file ! @$(HC) $< $(HC-OPTIONS) -M -optdep-f -optdep$(*F).d -i$(BUILDDIR) @sed -e 's|$(subst .hs,,$<)\.o|$(HOUTDIR)/$*\.o|' $(*F).d > $(HOUTDIR)/$*.d @rm $(*F).d --- 170,176 ---- $(HC) -o $@ -package-name port -ohi $(BUILDDIR)/Graphics/UI/$(*D)/$(*F).hi -odir $(HOUTDIR)/$(*D) -c $< $(HC-OPTIONS) $($(*F)_OPTIONS) -i$(BUILDDIR) $(INCDIRS) @# move stub files ! @-if test -f $(<D)/$(*F)_stub.h; then $(MV) $(<D)/$(*F)_stub.[ch] $(HOUTDIR)/$(*D); fi @# create dependency file ! @$(HC) $< $(HC-OPTIONS) -M -optdep-f -optdep$(*F).d -i$(BUILDDIR) @sed -e 's|$(subst .hs,,$<)\.o|$(HOUTDIR)/$*\.o|' $(*F).d > $(HOUTDIR)/$*.d @rm $(*F).d *************** *** 181,185 **** $(CC) -o $@ -c $< $(CC-OPTIONS) -MD $(INCDIRS) @#move dependendcy files only needed for gcc 2.xx ! @#@mv $(*F).d $(COUTDIR)/$(*F).c.d #-------------------------------------------------------------------------- --- 182,186 ---- $(CC) -o $@ -c $< $(CC-OPTIONS) -MD $(INCDIRS) @#move dependendcy files only needed for gcc 2.xx ! @#@mv $(*F).d $(COUTDIR)/$(*F).c.d #-------------------------------------------------------------------------- *************** *** 194,198 **** #-------------------------------------------------------------------------- # automatically include all dependency information. ! -include $(HDEPS) $(CDEPS) # extra dependency rules since GHC doesn't output dependencies --- 195,199 ---- #-------------------------------------------------------------------------- # automatically include all dependency information. ! -include $(HDEPS) $(CDEPS) # extra dependency rules since GHC doesn't output dependencies |
From: <kr_...@us...> - 2004-05-10 07:53:24
|
Update of /cvsroot/htoolkit/port/src/cbits/Win32 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18027/src/cbits/Win32 Modified Files: Window.c Log Message: bugfix Index: Window.c =================================================================== RCS file: /cvsroot/htoolkit/port/src/cbits/Win32/Window.c,v retrieving revision 1.67 retrieving revision 1.68 diff -C2 -d -r1.67 -r1.68 *** Window.c 7 May 2004 14:44:50 -0000 1.67 --- Window.c 10 May 2004 07:53:13 -0000 1.68 *************** *** 1143,1148 **** { FrameData *pFrameData = (FrameData *) GetWindowLong(ghWndFrame,GWL_USERDATA); ! if (pFrameData->DocumentInterface == 1) { DestroyWindow(window); } --- 1143,1155 ---- { FrameData *pFrameData = (FrameData *) GetWindowLong(ghWndFrame,GWL_USERDATA); ! if (pFrameData->DocumentInterface == 1 || GetParent(window) != pFrameData->hClientWnd) { + HWND hOwner = GetWindow(window, GW_OWNER); + if (hOwner) + { + EnableWindow(hOwner, TRUE); + SetActiveWindow(hOwner); + } + DestroyWindow(window); } |
From: <kr_...@us...> - 2004-05-08 10:20:25
|
Update of /cvsroot/htoolkit/gio/src/examples/simple In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29642/gio/src/examples/simple Modified Files: SimpleDialog.hs SimpleMenu.hs Log Message: Use the new style for version strings Index: SimpleDialog.hs =================================================================== RCS file: /cvsroot/htoolkit/gio/src/examples/simple/SimpleDialog.hs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** SimpleDialog.hs 19 Oct 2003 09:33:20 -0000 1.5 --- SimpleDialog.hs 8 May 2004 10:20:14 -0000 1.6 *************** *** 4,8 **** main ! = start "Simple dialogs" "1.0" SDI [] $ do fm <- menu [title =: "&Open"] mainMenu menuitem [title =: "Modal Dialog", on command =: showDialog True Nothing] fm --- 4,8 ---- main ! = start "Simple dialogs" "SimpleDialogs 1.0" SDI [] $ do fm <- menu [title =: "&Open"] mainMenu menuitem [title =: "Modal Dialog", on command =: showDialog True Nothing] fm Index: SimpleMenu.hs =================================================================== RCS file: /cvsroot/htoolkit/gio/src/examples/simple/SimpleMenu.hs,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** SimpleMenu.hs 22 Nov 2003 10:50:41 -0000 1.13 --- SimpleMenu.hs 8 May 2004 10:20:14 -0000 1.14 *************** *** 4,8 **** main ! = start "SimpleMenu" "1.0" SDI [] $ do w <- window [view =: sz 200 200] showWindow w --- 4,8 ---- main ! = start "Simple menu" "SimpleMenu 1.0" SDI [] $ do w <- window [view =: sz 200 200] showWindow w |
From: <kr_...@us...> - 2004-05-08 10:19:34
|
Update of /cvsroot/htoolkit/gio/src/Graphics/UI/GIO In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29528/gio/src/Graphics/UI/GIO Modified Files: Process.hs Log Message: Comments Index: Process.hs =================================================================== RCS file: /cvsroot/htoolkit/gio/src/Graphics/UI/GIO/Process.hs,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** Process.hs 15 Nov 2003 10:34:14 -0000 1.7 --- Process.hs 8 May 2004 10:19:23 -0000 1.8 *************** *** 40,46 **** destroy = newEvent (const Lib.getProcessDestroyHandler) (const Lib.setProcessDestroyHandler) (const Lib.setProcessDestroyDefHandler) ! -- | Start the event loop. ! start :: String -- ^ Application name ! -> String -- ^ Application version -> DocumentInterface -- ^ Document interface type for application -> [Prop Process] -- ^ Properties --- 40,54 ---- destroy = newEvent (const Lib.getProcessDestroyHandler) (const Lib.setProcessDestroyHandler) (const Lib.setProcessDestroyDefHandler) ! -- | Start the event loop. The event loop will continue until the ! -- process is destroyed. ! start :: String -- ^ Application title. Under Windows and Gnome this is ! -- the title of the main window. ! -> String -- ^ Application version. The version string usually ! -- consists two substrings, separated with space. The first ! -- substring is the internal application name while the second ! -- is the version. If the first string is skipped then the ! -- internal name will be equal to the application title. ! -- The internal name can contain only letters ! -- and digits all other characters will be ignored. -> DocumentInterface -- ^ Document interface type for application -> [Prop Process] -- ^ Properties *************** *** 52,60 **** setCurrentDirectory curdir ! -- | Force the event loop to terminate. quit :: IO Bool quit = Lib.quit ! -- | Force the event loop to terminate. halt :: IO () halt = Lib.halt --- 60,70 ---- setCurrentDirectory curdir ! -- | The 'quit' function sends 'dismiss' event to all opened windows and if after that all windows are closed ! -- then it will close the entire process. This function is the default handler for process\'s 'dismiss' event. quit :: IO Bool quit = Lib.quit ! -- | 'halt' exits the main event loop, closes any windows and menus, destroys all timers, ! -- unregisters all event handlers and terminates the process. halt :: IO () halt = Lib.halt |
From: <kr_...@us...> - 2004-05-08 10:19:34
|
Update of /cvsroot/htoolkit/port/src/Port In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29528/port/src/Port Modified Files: Process.hs Log Message: Comments Index: Process.hs =================================================================== RCS file: /cvsroot/htoolkit/port/src/Port/Process.hs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Process.hs 17 Jul 2003 17:55:48 -0000 1.3 --- Process.hs 8 May 2004 10:19:22 -0000 1.4 *************** *** 22,28 **** import Control.Monad(when) ! -- | Start the event loop. Runs until 'quit' is called. ! start :: String -- ^ Application name ! -> String -- ^ Application version -> DocumentInterface -- ^ Document interface type for application -> IO a -- ^ Startup action --- 22,36 ---- import Control.Monad(when) ! -- | Start the event loop. The event loop will continue until the ! -- 'quit' function is called. ! start :: String -- ^ Application title. Under Windows and Gnome this is ! -- the title of the main window. ! -> String -- ^ Application version. The version string usually ! -- consists two substrings, separated with space. The first ! -- substring is the internal application name while the second ! -- is the version. If the first string is skipped then the ! -- internal name will be equal to the application title. ! -- The internal name can contain only letters ! -- and digits all other characters will be ignored. -> DocumentInterface -- ^ Document interface type for application -> IO a -- ^ Startup action *************** *** 37,43 **** return r ! -- | 'quit' exits the main event loop, closes any windows and menus, destroys all timers ! -- and unregisters any event handlers. This function is automatically called when all ! -- windows are closed. quit :: IO Bool quit = do --- 45,50 ---- return r ! -- | The 'quit' function sends @WindowDismiss@ event to all opened windows and if after that all windows are closed ! -- then it will close the entire process. This function is the default handler for @ProcessDismiss@ event. quit :: IO Bool quit = do *************** *** 49,55 **** return r ! -- | 'quit' exits the main event loop, closes any windows and menus, destroys all timers ! -- and unregisters any event handlers. This function is automatically called when all ! -- windows are closed. halt :: IO () halt = do --- 56,61 ---- return r ! -- | 'halt' exits the main event loop, closes any windows and menus, destroys all timers ! -- and unregisters any event handlers. halt :: IO () halt = do |
From: <kr_...@us...> - 2004-05-08 09:46:17
|
Update of /cvsroot/htoolkit/port/src/cbits/Win32 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23232/src/cbits/Win32 Modified Files: Frame.c Util.c Log Message: Change the way in which the AppName is evaluated from AppTitle Index: Frame.c =================================================================== RCS file: /cvsroot/htoolkit/port/src/cbits/Win32/Frame.c,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** Frame.c 7 May 2004 14:23:48 -0000 1.25 --- Frame.c 8 May 2004 09:46:00 -0000 1.26 *************** *** 108,113 **** case WM_CREATE: { - int nLen; - pData = (FrameData *) malloc(sizeof(FrameData)); if (!pData) return -1; --- 108,111 ---- *************** *** 119,134 **** pData->pMenuHandlesMap = newMenuHandlesMap(); - nLen = GetWindowTextLength(hWnd); - if (nLen > 0) - { - pData->lpszAppName = malloc(nLen+1); - if (!pData->lpszAppName) - { - free(pData); - return -1; - } - GetWindowText(hWnd,pData->lpszAppName,nLen+1); - } - pData->hLeftBar = CreateWindow("HDOCKBAR", NULL, --- 117,120 ---- Index: Util.c =================================================================== RCS file: /cvsroot/htoolkit/port/src/cbits/Win32/Util.c,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** Util.c 7 May 2004 14:23:48 -0000 1.30 --- Util.c 8 May 2004 09:46:00 -0000 1.31 *************** *** 45,49 **** extern WNDPROC DefCheckListBoxProc; ! void osInit(char *appName, char *appVersion, int DocumentInterface) { if (!ghModule) --- 45,86 ---- extern WNDPROC DefCheckListBoxProc; ! static void parseAppNameVersion(char *appTitle,char *appVersion) ! { ! FrameData *pFrameData = (FrameData *) GetWindowLong(ghWndFrame,GWL_USERDATA); ! int appNameLen; ! char *s; ! ! s = appVersion; ! while (*s != ' ' && *s != 0) s++; ! ! if (*s == ' ') ! { ! appNameLen = s-appVersion; ! pFrameData->lpszAppName = malloc(appNameLen+1); ! memcpy(pFrameData->lpszAppName, appVersion, appNameLen); ! pFrameData->lpszAppName[appNameLen] = 0; ! ! while (*s == ' ') s++; ! pFrameData->lpszAppVersion = strdup(s); ! } ! else ! { ! pFrameData->lpszAppName = strdup(appTitle); ! pFrameData->lpszAppVersion = strdup(appVersion); ! } ! ! s = pFrameData->lpszAppName; ! appNameLen = 0; ! while (*s) ! { ! if (isalnum(*s)) ! pFrameData->lpszAppName[appNameLen++] = *s++; ! else ! s++; ! } ! pFrameData->lpszAppName[appNameLen] = 0; ! } ! ! void osInit(char *appTitle, char *appVersion, int DocumentInterface) { if (!ghModule) *************** *** 200,204 **** { ghWndFrame = CreateWindow ( "HSDIFRAME", ! appName, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT,CW_USEDEFAULT, --- 237,241 ---- { ghWndFrame = CreateWindow ( "HSDIFRAME", ! appTitle, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT,CW_USEDEFAULT, *************** *** 213,217 **** { ghWndFrame = CreateWindow ( "HMDIFRAME", ! appName, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT,CW_USEDEFAULT, --- 250,254 ---- { ghWndFrame = CreateWindow ( "HMDIFRAME", ! appTitle, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT,CW_USEDEFAULT, *************** *** 224,231 **** } ! { // Store appVersion for future usage ! FrameData *pFrameData = (FrameData *) GetWindowLong(ghWndFrame,GWL_USERDATA); ! pFrameData->lpszAppVersion = strdup(appVersion); ! } RestoreWindowState(ghWndFrame, SW_NORMAL); --- 261,265 ---- } ! parseAppNameVersion(appTitle,appVersion); RestoreWindowState(ghWndFrame, SW_NORMAL); |
From: <kr_...@us...> - 2004-05-08 09:21:21
|
Update of /cvsroot/htoolkit/port/src/cbits/GTK In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19849/src/cbits/GTK Modified Files: Frame.c Internals.h Util.c Log Message: Change the way in which the AppName is evaluated from AppTitle Index: Frame.c =================================================================== RCS file: /cvsroot/htoolkit/port/src/cbits/GTK/Frame.c,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** Frame.c 8 May 2004 07:38:37 -0000 1.13 --- Frame.c 8 May 2004 09:21:09 -0000 1.14 *************** *** 6,9 **** --- 6,10 ---- #include <gdk/gdkkeysyms.h> + char *gAppTitle = NULL; char *gAppName = NULL; char *gAppVersion = NULL; *************** *** 217,221 **** /* Create the window. */ ! gFrameWidget = gnome_app_new(gAppName, gAppName); gtk_signal_connect (GTK_OBJECT(gFrameWidget), "delete-event", GTK_SIGNAL_FUNC(frame_delete_handler), --- 218,222 ---- /* Create the window. */ ! gFrameWidget = gnome_app_new(gAppName, gAppTitle); gtk_signal_connect (GTK_OBJECT(gFrameWidget), "delete-event", GTK_SIGNAL_FUNC(frame_delete_handler), *************** *** 319,323 **** /* Create the window. */ ! gFrameWidget = gnome_app_new(gAppName, gAppName); gtk_signal_connect (GTK_OBJECT(gFrameWidget), "delete-event", GTK_SIGNAL_FUNC(frame_delete_handler), --- 320,324 ---- /* Create the window. */ ! gFrameWidget = gnome_app_new(gAppName, gAppTitle); gtk_signal_connect (GTK_OBJECT(gFrameWidget), "delete-event", GTK_SIGNAL_FUNC(frame_delete_handler), Index: Internals.h =================================================================== RCS file: /cvsroot/htoolkit/port/src/cbits/GTK/Internals.h,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Internals.h 2 Oct 2003 22:31:39 -0000 1.6 --- Internals.h 8 May 2004 09:21:09 -0000 1.7 *************** *** 13,17 **** extern int gDocumentInterface; ! extern char *gAppName, *gAppVersion, *gWindowName; extern GtkWidget *gFrameWidget; extern GtkWidget *gClientWidget; --- 13,17 ---- extern int gDocumentInterface; ! extern char *gAppTitle, *gAppName, *gAppVersion, *gWindowName; extern GtkWidget *gFrameWidget; extern GtkWidget *gClientWidget; Index: Util.c =================================================================== RCS file: /cvsroot/htoolkit/port/src/cbits/GTK/Util.c,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** Util.c 8 May 2004 07:38:37 -0000 1.19 --- Util.c 8 May 2004 09:21:09 -0000 1.20 *************** *** 27,31 **** } ! void osInit(char *appName, char *appVersion, int DocumentInterface) { if (!gProgram) --- 27,69 ---- } ! void parseAppNameVersion(char *appTitle,char *appVersion) ! { ! int appNameLen; ! char *s; ! ! s = appVersion; ! while (*s != ' ' && *s != 0) s++; ! ! if (*s == ' ') ! { ! appNameLen = s-appVersion; ! gAppName = malloc(appNameLen+1); ! memcpy(gAppName, appVersion, appNameLen); ! gAppName[appNameLen] = 0; ! ! while (*s == ' ') s++; ! gAppVersion = strdup(s); ! } ! else ! { ! gAppName = strdup(appTitle); ! gAppVersion = strdup(appVersion); ! } ! ! s = gAppName; ! appNameLen = 0; ! while (*s) ! { ! if (isalnum(*s)) ! gAppName[appNameLen++] = *s++; ! else ! s++; ! } ! gAppName[appNameLen] = 0; ! ! gAppTitle = strdup(appTitle); ! } ! ! void osInit(char *appTitle, char *appVersion, int DocumentInterface) { if (!gProgram) *************** *** 34,44 **** char **margv; gtk_set_locale(); getProgArgv(&margc, &margv); ! gProgram = gnome_program_init(appName, appVersion, LIBGNOMEUI_MODULE, margc, margv, GNOME_PARAM_POPT_TABLE, GNOME_PARAM_NONE); - gAppName = strdup(appName); - gAppVersion = strdup(appVersion); gDocumentInterface = DocumentInterface; gFrameWidget = NULL; --- 72,82 ---- char **margv; + parseAppNameVersion(appTitle,appVersion); + gtk_set_locale(); getProgArgv(&margc, &margv); ! gProgram = gnome_program_init(gAppName, appVersion, LIBGNOMEUI_MODULE, margc, margv, GNOME_PARAM_POPT_TABLE, GNOME_PARAM_NONE); gDocumentInterface = DocumentInterface; gFrameWidget = NULL; *************** *** 62,67 **** gtk_main(); handleProcessDestroy(); ! free(gAppName); ! free(gAppVersion); } --- 100,106 ---- gtk_main(); handleProcessDestroy(); ! free(gAppTitle); gAppTitle = NULL; ! free(gAppName); gAppName = NULL; ! free(gAppVersion); gAppVersion = NULL; } |
From: <kr_...@us...> - 2004-05-08 09:21:19
|
Update of /cvsroot/htoolkit/port/src/include In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19849/src/include Modified Files: Types.h Log Message: Change the way in which the AppName is evaluated from AppTitle Index: Types.h =================================================================== RCS file: /cvsroot/htoolkit/port/src/include/Types.h,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** Types.h 24 Nov 2003 22:40:41 -0000 1.21 --- Types.h 8 May 2004 09:21:10 -0000 1.22 *************** *** 154,158 **** #endif ! extern void osInit(char *appName, char *appVersion, int DocumentInterface); extern void osStart(); extern void osQuit(); --- 154,158 ---- #endif ! extern void osInit(char *appTitle, char *appVersion, int DocumentInterface); extern void osStart(); extern void osQuit(); |
From: <kr_...@us...> - 2004-05-08 07:38:46
|
Update of /cvsroot/htoolkit/port/src/cbits/GTK In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4852/src/cbits/GTK Modified Files: Frame.c Util.c Log Message: Persist the frame state between sessions Index: Frame.c =================================================================== RCS file: /cvsroot/htoolkit/port/src/cbits/GTK/Frame.c,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** Frame.c 14 Nov 2003 22:35:20 -0000 1.12 --- Frame.c 8 May 2004 07:38:37 -0000 1.13 *************** *** 2,5 **** --- 2,6 ---- #include "Internals.h" #include "Window.h" + #include "ConfigKey.h" #include "Handlers_stub.h" #include <gdk/gdkkeysyms.h> *************** *** 50,53 **** --- 51,61 ---- static gboolean frame_delete_handler(GtkWidget *widget, GdkEvent *event, gpointer user_data) { + if (widget->window) + { + char *keyName = strdup("HToolkit.FrameState"); + osSetConfigIntKey(keyName, (int) gdk_window_get_state(widget->window)); + free(keyName); + } + handleProcessDismiss(); return gtk_true(); Index: Util.c =================================================================== RCS file: /cvsroot/htoolkit/port/src/cbits/GTK/Util.c,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** Util.c 4 Jul 2003 15:23:57 -0000 1.18 --- Util.c 8 May 2004 07:38:37 -0000 1.19 *************** *** 2,5 **** --- 2,6 ---- #include <RtsAPI.h> #include "Types.h" + #include "ConfigKey.h" #include "Internals.h" #include "Handlers_stub.h" *************** *** 49,52 **** --- 50,58 ---- else createSDIFrame(); + + char *keyName = strdup("HToolkit.FrameState"); + if (osGetConfigIntKey(keyName, 0) == GDK_WINDOW_STATE_MAXIMIZED) + gtk_window_maximize(GTK_WINDOW(gFrameWidget)); + free(keyName); } }; |
From: <kr_...@us...> - 2004-05-07 14:45:00
|
Update of /cvsroot/htoolkit/port/src/cbits/Win32 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15953/src/cbits/Win32 Modified Files: DockBar.c FileDialog.c Notebook.c ToolBar.c Window.c Log Message: use MoveWindow instead of SetWindowPos where possible Index: DockBar.c =================================================================== RCS file: /cvsroot/htoolkit/port/src/cbits/Win32/DockBar.c,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** DockBar.c 7 May 2004 14:33:04 -0000 1.9 --- DockBar.c 7 May 2004 14:44:50 -0000 1.10 *************** *** 54,58 **** pBar->nSize = sz.cy; ! SetWindowPos(pBar->hWnd,NULL,pBand->nOffset,pBar->nOffset,sz.cx,sz.cy,SWP_NOZORDER); } else --- 54,58 ---- pBar->nSize = sz.cy; ! MoveWindow(pBar->hWnd,pBand->nOffset,pBar->nOffset,sz.cx,sz.cy,TRUE); } else *************** *** 61,65 **** pBar->nSize = sz.cx; ! SetWindowPos(pBar->hWnd,NULL,pBar->nOffset,pBand->nOffset,sz.cx,sz.cy,SWP_NOZORDER); } --- 61,65 ---- pBar->nSize = sz.cx; ! MoveWindow(pBar->hWnd,pBar->nOffset,pBand->nOffset,sz.cx,sz.cy,TRUE); } *************** *** 114,125 **** nBottom = GetDockBarSize(pData->hBottomBar); ! SetWindowPos(pData->hLeftBar, NULL,0,nTop,nLeft,nHeight-(nBottom+nTop),SWP_NOZORDER); ! SetWindowPos(pData->hTopBar, NULL,0,0,nWidth,nTop,SWP_NOZORDER); ! SetWindowPos(pData->hRightBar, NULL,nWidth-nRight,nTop,nRight,nHeight-(nBottom+nTop),SWP_NOZORDER); ! SetWindowPos(pData->hBottomBar,NULL,0,nHeight-nBottom,nWidth,nBottom,SWP_NOZORDER); ! SetWindowPos(pData->hClientWnd,NULL,nLeft,nTop,nWidth-(nRight+nLeft),nHeight-(nBottom+nTop),SWP_NOZORDER); ! SetWindowPos(pData->hStatusBar,NULL,0,nHeight,nWidth,nStatusHeight,SWP_NOZORDER); } --- 114,125 ---- nBottom = GetDockBarSize(pData->hBottomBar); ! MoveWindow(pData->hLeftBar, 0,nTop,nLeft,nHeight-(nBottom+nTop),TRUE); ! MoveWindow(pData->hTopBar, 0,0,nWidth,nTop,TRUE); ! MoveWindow(pData->hRightBar, nWidth-nRight,nTop,nRight,nHeight-(nBottom+nTop),TRUE); ! MoveWindow(pData->hBottomBar,0,nHeight-nBottom,nWidth,nBottom,TRUE); ! MoveWindow(pData->hClientWnd,nLeft,nTop,nWidth-(nRight+nLeft),nHeight-(nBottom+nTop),TRUE); ! MoveWindow(pData->hStatusBar,0,nHeight,nWidth,nStatusHeight,TRUE); } *************** *** 213,217 **** int nHeight = HIWORD(lParam); ! SetWindowPos(GetWindow(hWnd, GW_CHILD),NULL,0,0,nWidth,nHeight,SWP_NOZORDER); } break; --- 213,217 ---- int nHeight = HIWORD(lParam); ! MoveWindow(GetWindow(hWnd, GW_CHILD),0,0,nWidth,nHeight,TRUE); } break; Index: FileDialog.c =================================================================== RCS file: /cvsroot/htoolkit/port/src/cbits/Win32/FileDialog.c,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** FileDialog.c 1 May 2003 20:27:38 -0000 1.6 --- FileDialog.c 7 May 2004 14:44:50 -0000 1.7 *************** *** 23,27 **** LPITEMIDLIST pidlReturn; BROWSEINFO bi; ! char *s = NULL; bi.hwndOwner = owner ? owner : ghWndFrame; --- 23,27 ---- LPITEMIDLIST pidlReturn; BROWSEINFO bi; ! char *s = NULL; bi.hwndOwner = owner ? owner : ghWndFrame; *************** *** 120,124 **** int nLen, nSize; char *s, *s2, *buffer; ! nSize = 1; s = ofn.lpstrFile+ofn.nFileOffset; --- 120,124 ---- int nLen, nSize; char *s, *s2, *buffer; ! nSize = 1; s = ofn.lpstrFile+ofn.nFileOffset; *************** *** 129,133 **** nSize += ofn.nFileOffset+nLen+1; } ! buffer = malloc(nSize); if (!buffer) --- 129,133 ---- nSize += ofn.nFileOffset+nLen+1; } ! buffer = malloc(nSize); if (!buffer) *************** *** 149,153 **** } *s2 = 0; ! free(ofn.lpstrFile); return buffer; --- 149,153 ---- } *s2 = 0; ! free(ofn.lpstrFile); return buffer; Index: Notebook.c =================================================================== RCS file: /cvsroot/htoolkit/port/src/cbits/Win32/Notebook.c,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** Notebook.c 8 Oct 2003 22:21:57 -0000 1.7 --- Notebook.c 7 May 2004 14:44:50 -0000 1.8 *************** *** 22,28 **** SendMessage(hWnd, TCM_GETITEM, i, (LPARAM) &item); ! SetWindowPos((HWND) item.lParam,NULL,rect.left,rect.top, (rect.right-rect.left), (rect.bottom-rect.top), ! SWP_NOZORDER); } } --- 22,28 ---- SendMessage(hWnd, TCM_GETITEM, i, (LPARAM) &item); ! MoveWindow((HWND) item.lParam,rect.left,rect.top, (rect.right-rect.left), (rect.bottom-rect.top), ! TRUE); } } *************** *** 139,143 **** { LONG lStyle; ! lStyle = GetWindowLong(notebook, GWL_STYLE); lStyle &= ~(TCS_VERTICAL | TCS_RIGHT | TCS_BOTTOM); --- 139,143 ---- { LONG lStyle; ! lStyle = GetWindowLong(notebook, GWL_STYLE); lStyle &= ~(TCS_VERTICAL | TCS_RIGHT | TCS_BOTTOM); *************** *** 151,158 **** } ! SendMessage(notebook, WM_SETFONT, (WPARAM)NULL, TRUE); SetWindowLong(notebook, GWL_STYLE, lStyle); SendMessage(notebook, WM_SETFONT, (WPARAM)GetStockObject(DEFAULT_GUI_FONT), MAKELPARAM (TRUE,0)); ! ResizeNotebookPages(notebook); } --- 151,158 ---- } ! SendMessage(notebook, WM_SETFONT, (WPARAM)NULL, TRUE); SetWindowLong(notebook, GWL_STYLE, lStyle); SendMessage(notebook, WM_SETFONT, (WPARAM)GetStockObject(DEFAULT_GUI_FONT), MAKELPARAM (TRUE,0)); ! ResizeNotebookPages(notebook); } *************** *** 161,165 **** { LONG lStyle = GetWindowLong(notebook, GWL_STYLE); ! if (lStyle & TCS_VERTICAL) if (lStyle & TCS_RIGHT) --- 161,165 ---- { LONG lStyle = GetWindowLong(notebook, GWL_STYLE); ! if (lStyle & TCS_VERTICAL) if (lStyle & TCS_RIGHT) *************** *** 183,195 **** TCITEM item; int nOldIndex; ! item.mask = TCIF_PARAM; ! nOldIndex = SendMessage(notebook, TCM_GETCURSEL, 0, 0); SendMessage(notebook, TCM_SETCURSEL, index, 0); ! SendMessage(notebook, TCM_GETITEM, nOldIndex, (LPARAM) &item); ShowWindow((HWND) item.lParam, SW_HIDE); ! SendMessage(notebook, TCM_GETITEM, index, (LPARAM) &item); ShowWindow((HWND) item.lParam, SW_SHOW); --- 183,195 ---- TCITEM item; int nOldIndex; ! item.mask = TCIF_PARAM; ! nOldIndex = SendMessage(notebook, TCM_GETCURSEL, 0, 0); SendMessage(notebook, TCM_SETCURSEL, index, 0); ! SendMessage(notebook, TCM_GETITEM, nOldIndex, (LPARAM) &item); ShowWindow((HWND) item.lParam, SW_HIDE); ! SendMessage(notebook, TCM_GETITEM, index, (LPARAM) &item); ShowWindow((HWND) item.lParam, SW_SHOW); *************** *** 202,212 **** TCITEM item; int nCount; ! nCount = SendMessage(notebook, TCM_GETITEMCOUNT, 0, 0); if (pos < 0) pos = nCount; ! GetWindowRect(notebook, &rect); SendMessage(notebook, TCM_ADJUSTRECT, FALSE, (LPARAM) &rect); ! hWnd = CreateWindow("HNOTEBOOKPAGE", NULL, --- 202,212 ---- TCITEM item; int nCount; ! nCount = SendMessage(notebook, TCM_GETITEMCOUNT, 0, 0); if (pos < 0) pos = nCount; ! GetWindowRect(notebook, &rect); SendMessage(notebook, TCM_ADJUSTRECT, FALSE, (LPARAM) &rect); ! hWnd = CreateWindow("HNOTEBOOKPAGE", NULL, *************** *** 249,257 **** item.mask = TCIF_PARAM; SendMessage(hNotebook, TCM_GETITEM, i, (LPARAM) &item); ! if (((HWND) item.lParam) == window) return i; } ! return -1; } --- 249,257 ---- item.mask = TCIF_PARAM; SendMessage(hNotebook, TCM_GETITEM, i, (LPARAM) &item); ! if (((HWND) item.lParam) == window) return i; } ! return -1; } *************** *** 275,279 **** int i, nPos, nImage, nCount; HWND hNotebook = GetParent(window); ! // find the page position and an index of the old bitmap nPos = -1; --- 275,279 ---- int i, nPos, nImage, nCount; HWND hNotebook = GetParent(window); ! // find the page position and an index of the old bitmap nPos = -1; *************** *** 292,304 **** } } ! // return if the page is not found if (nPos < 0) return; ! if (nImage > 0) { // remove old bitmap ! BOOL bUsed = FALSE; for (i = 0; i < nCount; i++) --- 292,304 ---- } } ! // return if the page is not found if (nPos < 0) return; ! if (nImage > 0) { // remove old bitmap ! BOOL bUsed = FALSE; for (i = 0; i < nCount; i++) *************** *** 313,321 **** } } ! if (!bUsed) SendMessage(hNotebook, TCM_REMOVEIMAGE, nImage, 0); } ! // set new bitmap if (bitmap) --- 313,321 ---- } } ! if (!bUsed) SendMessage(hNotebook, TCM_REMOVEIMAGE, nImage, 0); } ! // set new bitmap if (bitmap) *************** *** 328,332 **** item.iImage = -1; } ! SendMessage(hNotebook, TCM_SETITEM, nPos, (LPARAM) &item); } --- 328,332 ---- item.iImage = -1; } ! SendMessage(hNotebook, TCM_SETITEM, nPos, (LPARAM) &item); } Index: ToolBar.c =================================================================== RCS file: /cvsroot/htoolkit/port/src/cbits/Win32/ToolBar.c,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** ToolBar.c 7 May 2004 13:09:46 -0000 1.19 --- ToolBar.c 7 May 2004 14:44:50 -0000 1.20 *************** *** 530,534 **** NULL); SetParent(hToolBar, hDockBar); ! SetWindowPos(hDockBar, NULL, rect.left, rect.top, rect.right-rect.left, rect.bottom-rect.top, SWP_NOZORDER); free(szCaption); --- 530,534 ---- NULL); SetParent(hToolBar, hDockBar); ! MoveWindow(hDockBar, rect.left, rect.top, rect.right-rect.left, rect.bottom-rect.top, TRUE); free(szCaption); Index: Window.c =================================================================== RCS file: /cvsroot/htoolkit/port/src/cbits/Win32/Window.c,v retrieving revision 1.66 retrieving revision 1.67 diff -C2 -d -r1.66 -r1.67 *** Window.c 7 May 2004 14:33:04 -0000 1.66 --- Window.c 7 May 2004 14:44:50 -0000 1.67 *************** *** 178,182 **** } ! SetWindowPos(hWnd,NULL,pos.x,pos.y,sz.cx,sz.cy,SWP_NOZORDER); } --- 178,182 ---- } ! MoveWindow(hWnd,pos.x,pos.y,sz.cx,sz.cy,TRUE); } *************** *** 1007,1014 **** GetWindowRect(hTargetWnd,&wrect); ! SetWindowPos(hTargetWnd,NULL,wrect.left,wrect.top, (wrect.right-wrect.left) + (w - (crect.right-crect.left)), (wrect.bottom-wrect.top) + (h - (crect.bottom - crect.top)), ! SWP_NOZORDER); } --- 1007,1014 ---- GetWindowRect(hTargetWnd,&wrect); ! MoveWindow(hTargetWnd,wrect.left,wrect.top, (wrect.right-wrect.left) + (w - (crect.right-crect.left)), (wrect.bottom-wrect.top) + (h - (crect.bottom - crect.top)), ! TRUE); } *************** *** 1269,1273 **** if (_stricmp(buffer, "ComboBox") == 0) h = 150; ! SetWindowPos(ctrl,NULL,x-pData->Origin.x,y-pData->Origin.y,w,h,SWP_NOZORDER); InvalidateRect(ctrl,NULL,TRUE); } --- 1269,1273 ---- if (_stricmp(buffer, "ComboBox") == 0) h = 150; ! MoveWindow(ctrl,x-pData->Origin.x,y-pData->Origin.y,w,h,TRUE); InvalidateRect(ctrl,NULL,TRUE); } *************** *** 1479,1483 **** } ! SetWindowPos(ghWndFrame,NULL,pos.x,pos.y,sz.cx,sz.cy,SWP_NOZORDER); } else --- 1479,1483 ---- } ! MoveWindow(ghWndFrame,pos.x,pos.y,sz.cx,sz.cy,TRUE); } else |
From: <kr_...@us...> - 2004-05-07 14:33:14
|
Update of /cvsroot/htoolkit/port/src/cbits/Win32 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13023/src/cbits/Win32 Modified Files: DockBar.c StatusBar.c Window.c Log Message: Use IsWindowVisible function instead of GetWindowLong to determine whether the window is visible Index: DockBar.c =================================================================== RCS file: /cvsroot/htoolkit/port/src/cbits/Win32/DockBar.c,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** DockBar.c 14 Nov 2003 22:35:20 -0000 1.8 --- DockBar.c 7 May 2004 14:33:04 -0000 1.9 *************** *** 11,15 **** HWND hWnd; } BarData; ! typedef struct { --- 11,15 ---- HWND hWnd; } BarData; ! typedef struct { *************** *** 33,45 **** int nBarOffset, nBandOffset; SIZE sz; ! nBandOffset = 0; for (i = 0; i < pData->nBandCount; i++) { pBand = &pData->pBands[i]; ! pBand->nSize = 0; pBand->nOffset = nBandOffset; ! nBarOffset = 0; for (j = 0; j < pBand->nBarCount; j++) --- 33,45 ---- int nBarOffset, nBandOffset; SIZE sz; ! nBandOffset = 0; for (i = 0; i < pData->nBandCount; i++) { pBand = &pData->pBands[i]; ! pBand->nSize = 0; pBand->nOffset = nBandOffset; ! nBarOffset = 0; for (j = 0; j < pBand->nBarCount; j++) *************** *** 47,51 **** pBar = &pBand->pBars[j]; GetToolBarSize(pBar->hWnd, &sz); ! pBar->nOffset = max(pBar->nOffset, nBarOffset); if (bVert) --- 47,51 ---- pBar = &pBand->pBars[j]; GetToolBarSize(pBar->hWnd, &sz); ! pBar->nOffset = max(pBar->nOffset, nBarOffset); if (bVert) *************** *** 53,57 **** pBand->nSize = max(pBand->nSize, sz.cx); pBar->nSize = sz.cy; ! SetWindowPos(pBar->hWnd,NULL,pBand->nOffset,pBar->nOffset,sz.cx,sz.cy,SWP_NOZORDER); } --- 53,57 ---- pBand->nSize = max(pBand->nSize, sz.cx); pBar->nSize = sz.cy; ! SetWindowPos(pBar->hWnd,NULL,pBand->nOffset,pBar->nOffset,sz.cx,sz.cy,SWP_NOZORDER); } *************** *** 60,70 **** pBand->nSize = max(pBand->nSize, sz.cy); pBar->nSize = sz.cx; ! SetWindowPos(pBar->hWnd,NULL,pBar->nOffset,pBand->nOffset,sz.cx,sz.cy,SWP_NOZORDER); } ! nBarOffset = pBar->nOffset + pBar->nSize; } ! nBandOffset = pBand->nOffset + pBand->nSize; } --- 60,70 ---- pBand->nSize = max(pBand->nSize, sz.cy); pBar->nSize = sz.cx; ! SetWindowPos(pBar->hWnd,NULL,pBar->nOffset,pBand->nOffset,sz.cx,sz.cy,SWP_NOZORDER); } ! nBarOffset = pBar->nOffset + pBar->nSize; } ! nBandOffset = pBand->nOffset + pBand->nSize; } *************** *** 75,84 **** int i, nSize; DockBarData *pData; ! nSize = 0; pData = (DockBarData *) GetWindowLong(hDockBar, GWL_USERDATA); ! RecalcDockBarLayout(pData, GetWindowLong(hDockBar, GWL_STYLE) & CCS_VERT); ! for (i = 0; i < pData->nBandCount; i++) nSize += pData->pBands[i].nSize; --- 75,84 ---- int i, nSize; DockBarData *pData; ! nSize = 0; pData = (DockBarData *) GetWindowLong(hDockBar, GWL_USERDATA); ! RecalcDockBarLayout(pData, GetWindowLong(hDockBar, GWL_STYLE) & CCS_VERT); ! for (i = 0; i < pData->nBandCount; i++) nSize += pData->pBands[i].nSize; *************** *** 93,97 **** int nWidth, nHeight; int nLeft, nTop, nRight, nBottom; ! int nStatusHeight; if (!ghWndFrame) --- 93,97 ---- int nWidth, nHeight; int nLeft, nTop, nRight, nBottom; ! int nStatusHeight; if (!ghWndFrame) *************** *** 99,104 **** pData = (FrameData *) GetWindowLong(ghWndFrame,GWL_USERDATA); ! ! if (GetWindowLong(pData->hStatusBar, GWL_STYLE) & WS_VISIBLE) nStatusHeight = 20; else --- 99,104 ---- pData = (FrameData *) GetWindowLong(ghWndFrame,GWL_USERDATA); ! ! if (IsWindowVisible(pData->hStatusBar)) nStatusHeight = 20; else *************** *** 106,110 **** GetClientRect(ghWndFrame, &rect); ! nWidth = rect.right-rect.left; nHeight = rect.bottom-rect.top-nStatusHeight; --- 106,110 ---- GetClientRect(ghWndFrame, &rect); ! nWidth = rect.right-rect.left; nHeight = rect.bottom-rect.top-nStatusHeight; *************** *** 113,117 **** nRight = GetDockBarSize(pData->hRightBar); nBottom = GetDockBarSize(pData->hBottomBar); ! SetWindowPos(pData->hLeftBar, NULL,0,nTop,nLeft,nHeight-(nBottom+nTop),SWP_NOZORDER); SetWindowPos(pData->hTopBar, NULL,0,0,nWidth,nTop,SWP_NOZORDER); --- 113,117 ---- nRight = GetDockBarSize(pData->hRightBar); nBottom = GetDockBarSize(pData->hBottomBar); ! SetWindowPos(pData->hLeftBar, NULL,0,nTop,nLeft,nHeight-(nBottom+nTop),SWP_NOZORDER); SetWindowPos(pData->hTopBar, NULL,0,0,nWidth,nTop,SWP_NOZORDER); *************** *** 120,124 **** SetWindowPos(pData->hClientWnd,NULL,nLeft,nTop,nWidth-(nRight+nLeft),nHeight-(nBottom+nTop),SWP_NOZORDER); ! SetWindowPos(pData->hStatusBar,NULL,0,nHeight,nWidth,nStatusHeight,SWP_NOZORDER); } --- 120,124 ---- SetWindowPos(pData->hClientWnd,NULL,nLeft,nTop,nWidth-(nRight+nLeft),nHeight-(nBottom+nTop),SWP_NOZORDER); ! SetWindowPos(pData->hStatusBar,NULL,0,nHeight,nWidth,nStatusHeight,SWP_NOZORDER); } *************** *** 129,133 **** { DockBarData *pData = (DockBarData *) GetWindowLong(hWnd, GWL_USERDATA); ! switch (uMsg) { --- 129,133 ---- { DockBarData *pData = (DockBarData *) GetWindowLong(hWnd, GWL_USERDATA); ! switch (uMsg) { *************** *** 135,139 **** { HMENU hMenu; ! if (((CREATESTRUCT *) lParam)->style & WS_CHILD) { --- 135,139 ---- { HMENU hMenu; ! if (((CREATESTRUCT *) lParam)->style & WS_CHILD) { *************** *** 162,166 **** { int i; ! SetWindowLong(hWnd, GWL_USERDATA, 0); for (i = 0; i < pData->nBandCount; i++) --- 162,166 ---- { int i; ! SetWindowLong(hWnd, GWL_USERDATA, 0); for (i = 0; i < pData->nBandCount; i++) *************** *** 178,187 **** TBBUTTONINFO tbbi; HWND hToolBar = (HWND) lParam; ! tbbi.cbSize = sizeof(tbbi); tbbi.dwMask = TBIF_LPARAM; tbbi.lParam = 0; SendMessage(hToolBar, TB_GETBUTTONINFO, LOWORD(wParam), (LPARAM) &tbbi); ! handle = (ToolHandle) tbbi.lParam; if (handle) osActivateToolItem(handle); --- 178,187 ---- TBBUTTONINFO tbbi; HWND hToolBar = (HWND) lParam; ! tbbi.cbSize = sizeof(tbbi); tbbi.dwMask = TBIF_LPARAM; tbbi.lParam = 0; SendMessage(hToolBar, TB_GETBUTTONINFO, LOWORD(wParam), (LPARAM) &tbbi); ! handle = (ToolHandle) tbbi.lParam; if (handle) osActivateToolItem(handle); *************** *** 193,204 **** TBBUTTONINFO tbbi; LPNMTOOLBAR lpNMToolBar = (LPNMTOOLBAR) lParam; ! if (lpNMToolBar->hdr.code == TBN_DROPDOWN) ! { tbbi.cbSize = sizeof(tbbi); tbbi.dwMask = TBIF_LPARAM; tbbi.lParam = 0; SendMessage(lpNMToolBar->hdr.hwndFrom, TB_GETBUTTONINFO, lpNMToolBar->iItem, (LPARAM) &tbbi); ! handle = (ToolHandle) tbbi.lParam; if (handle) --- 193,204 ---- TBBUTTONINFO tbbi; LPNMTOOLBAR lpNMToolBar = (LPNMTOOLBAR) lParam; ! if (lpNMToolBar->hdr.code == TBN_DROPDOWN) ! { tbbi.cbSize = sizeof(tbbi); tbbi.dwMask = TBIF_LPARAM; tbbi.lParam = 0; SendMessage(lpNMToolBar->hdr.hwndFrom, TB_GETBUTTONINFO, lpNMToolBar->iItem, (LPARAM) &tbbi); ! handle = (ToolHandle) tbbi.lParam; if (handle) *************** *** 212,216 **** int nWidth = LOWORD(lParam); int nHeight = HIWORD(lParam); ! SetWindowPos(GetWindow(hWnd, GW_CHILD),NULL,0,0,nWidth,nHeight,SWP_NOZORDER); } --- 212,216 ---- int nWidth = LOWORD(lParam); int nHeight = HIWORD(lParam); ! SetWindowPos(GetWindow(hWnd, GW_CHILD),NULL,0,0,nWidth,nHeight,SWP_NOZORDER); } *************** *** 221,225 **** break; } ! return DefWindowProc(hWnd, uMsg, wParam, lParam); } --- 221,225 ---- break; } ! return DefWindowProc(hWnd, uMsg, wParam, lParam); } *************** *** 231,240 **** int nOffset; int nCentralOffset; ! DockBarData *pData = (DockBarData *) GetWindowLong(hDockBar, GWL_USERDATA); BOOL bVert = GetWindowLong(hDockBar, GWL_STYLE) & CCS_VERT; BandData *pBand; ! RecalcDockBarLayout(pData, bVert); ! if (bVert) { --- 231,240 ---- int nOffset; int nCentralOffset; ! DockBarData *pData = (DockBarData *) GetWindowLong(hDockBar, GWL_USERDATA); BOOL bVert = GetWindowLong(hDockBar, GWL_STYLE) & CCS_VERT; BandData *pBand; ! RecalcDockBarLayout(pData, bVert); ! if (bVert) { *************** *** 247,251 **** nCentralOffset = (rect.bottom-rect.top)/2; } ! for (nBandNum = 0; nBandNum < pData->nBandCount; nBandNum++) { --- 247,251 ---- nCentralOffset = (rect.bottom-rect.top)/2; } ! for (nBandNum = 0; nBandNum < pData->nBandCount; nBandNum++) { *************** *** 254,258 **** break; } ! if (nBandNum >= pData->nBandCount) nPosition = 0; --- 254,258 ---- break; } ! if (nBandNum >= pData->nBandCount) nPosition = 0; *************** *** 260,264 **** { pBand = &pData->pBands[nBandNum]; ! if (nOffset < pBand->pBars[0].nOffset) nPosition = 0; --- 260,264 ---- { pBand = &pData->pBands[nBandNum]; ! if (nOffset < pBand->pBars[0].nOffset) nPosition = 0; *************** *** 272,276 **** } } ! DockToolBar(hDockBar, hWnd, nBandNum, nPosition, nOffset); } --- 272,276 ---- } } ! DockToolBar(hDockBar, hWnd, nBandNum, nPosition, nOffset); } *************** *** 281,287 **** BandData *pBand; DockBarData *pData = (DockBarData *) GetWindowLong(hDockBar, GWL_USERDATA); ! SetParent(hWnd, hDockBar); ! if (pData) { --- 281,287 ---- BandData *pBand; DockBarData *pData = (DockBarData *) GetWindowLong(hDockBar, GWL_USERDATA); ! SetParent(hWnd, hDockBar); ! if (pData) { *************** *** 298,302 **** nPosition = pBand->nBarCount; pBand->pBars = realloc(pBand->pBars, (pBand->nBarCount+1)*sizeof(BarData)); ! memmove(pBand->pBars+nPosition+1, pBand->pBars+nPosition, (pBand->nBarCount-nPosition)*sizeof(BarData)); pBand->nBarCount++; --- 298,302 ---- nPosition = pBand->nBarCount; pBand->pBars = realloc(pBand->pBars, (pBand->nBarCount+1)*sizeof(BarData)); ! memmove(pBand->pBars+nPosition+1, pBand->pBars+nPosition, (pBand->nBarCount-nPosition)*sizeof(BarData)); pBand->nBarCount++; *************** *** 318,324 **** SetParent(hWnd, NULL); ! if (pData) ! { for (i = 0; i < pData->nBandCount; i++) { --- 318,324 ---- SetParent(hWnd, NULL); ! if (pData) ! { for (i = 0; i < pData->nBandCount; i++) { Index: StatusBar.c =================================================================== RCS file: /cvsroot/htoolkit/port/src/cbits/Win32/StatusBar.c,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** StatusBar.c 25 Feb 2004 12:57:11 -0000 1.6 --- StatusBar.c 7 May 2004 14:33:04 -0000 1.7 *************** *** 14,18 **** { FrameData *pData = (FrameData *) GetWindowLong(ghWndFrame,GWL_USERDATA); ! return (GetWindowLong(pData->hStatusBar, GWL_STYLE) & WS_VISIBLE) != 0; } --- 14,18 ---- { FrameData *pData = (FrameData *) GetWindowLong(ghWndFrame,GWL_USERDATA); ! return IsWindowVisible(pData->hStatusBar); } *************** *** 74,78 **** count++; } ! return count; }; --- 74,78 ---- count++; } ! return count; }; *************** *** 86,95 **** HFONT hFont; RECT rect; ! if (!pData || !pData->hStatusBar) return; GetClientRect(pData->hStatusBar, &rect); ! // get the actual count of indicators count = 0; --- 86,95 ---- HFONT hFont; RECT rect; ! if (!pData || !pData->hStatusBar) return; GetClientRect(pData->hStatusBar, &rect); ! // get the actual count of indicators count = 0; *************** *** 100,107 **** count++; } ! // allocate the "parts" buffer required from SB_SETPARTS message buffer = rmalloc((count+1)*sizeof(int)); ! // get the device context and the font for the status bar hDC = GetDC(pData->hStatusBar); --- 100,107 ---- count++; } ! // allocate the "parts" buffer required from SB_SETPARTS message buffer = rmalloc((count+1)*sizeof(int)); ! // get the device context and the font for the status bar hDC = GetDC(pData->hStatusBar); *************** *** 109,113 **** if (hFont) SelectObject(hDC, hFont); ! // populate the "parts" buffer i = count+1; --- 109,113 ---- if (hFont) SelectObject(hDC, hFont); ! // populate the "parts" buffer i = count+1; *************** *** 117,123 **** { SIZE sz; ! buffer[--i] = x; ! sz.cx = 0; sz.cy = 0; --- 117,123 ---- { SIZE sz; ! buffer[--i] = x; ! sz.cx = 0; sz.cy = 0; *************** *** 125,136 **** GetTextExtentPoint32(hDC, indicator->title, strlen(indicator->title), &sz); x -= sz.cx+5; ! indicator = indicator->prev; } buffer[0] = x; ! // set parts SendMessage(pData->hStatusBar, SB_SETPARTS, count+1, (LPARAM) buffer); ! // refresh the part titles i = 1; --- 125,136 ---- GetTextExtentPoint32(hDC, indicator->title, strlen(indicator->title), &sz); x -= sz.cx+5; ! indicator = indicator->prev; } buffer[0] = x; ! // set parts SendMessage(pData->hStatusBar, SB_SETPARTS, count+1, (LPARAM) buffer); ! // refresh the part titles i = 1; *************** *** 144,151 **** i++; } ! // release the device context ReleaseDC(pData->hStatusBar, hDC); ! // free parts buffer free(buffer); --- 144,151 ---- i++; } ! // release the device context ReleaseDC(pData->hStatusBar, hDC); ! // free parts buffer free(buffer); *************** *** 156,160 **** IndicatorHandle indicator, *link, last; FrameData *pData = (FrameData *) GetWindowLong(ghWndFrame,GWL_USERDATA); ! indicator = rmalloc(sizeof(struct IndicatorHandle)); indicator->title = NULL; --- 156,160 ---- IndicatorHandle indicator, *link, last; FrameData *pData = (FrameData *) GetWindowLong(ghWndFrame,GWL_USERDATA); ! indicator = rmalloc(sizeof(struct IndicatorHandle)); indicator->title = NULL; *************** *** 190,199 **** if (*link) (*link)->prev = indicator; *link = indicator; ! if (last == pData->last_indicator) pData->last_indicator = indicator; ! RefreshStatusBarIndicators(); ! return indicator; } --- 190,199 ---- if (*link) (*link)->prev = indicator; *link = indicator; ! if (last == pData->last_indicator) pData->last_indicator = indicator; ! RefreshStatusBarIndicators(); ! return indicator; } *************** *** 202,211 **** { FrameData *pData = (FrameData *) GetWindowLong(ghWndFrame,GWL_USERDATA); ! handleIndicatorDestroy(indicator); ! if (indicator->next) indicator->next->prev = indicator->prev; if (indicator->prev) indicator->prev->next = indicator->next; ! if (indicator == pData->first_indicator) pData->first_indicator = indicator->next; --- 202,211 ---- { FrameData *pData = (FrameData *) GetWindowLong(ghWndFrame,GWL_USERDATA); ! handleIndicatorDestroy(indicator); ! if (indicator->next) indicator->next->prev = indicator->prev; if (indicator->prev) indicator->prev->next = indicator->next; ! if (indicator == pData->first_indicator) pData->first_indicator = indicator->next; *************** *** 215,219 **** free(indicator->title); free(indicator); ! RefreshStatusBarIndicators(); } --- 215,219 ---- free(indicator->title); free(indicator); ! RefreshStatusBarIndicators(); } *************** *** 229,233 **** free(indicator->title); indicator->title = strdup(title); ! RefreshStatusBarIndicators(); } --- 229,233 ---- free(indicator->title); indicator->title = strdup(title); ! RefreshStatusBarIndicators(); } *************** *** 240,244 **** while ((indicator = indicator->prev) != NULL) pos++; ! return pos; } --- 240,244 ---- while ((indicator = indicator->prev) != NULL) pos++; ! return pos; } Index: Window.c =================================================================== RCS file: /cvsroot/htoolkit/port/src/cbits/Win32/Window.c,v retrieving revision 1.65 retrieving revision 1.66 diff -C2 -d -r1.65 -r1.66 *** Window.c 7 May 2004 13:09:46 -0000 1.65 --- Window.c 7 May 2004 14:33:04 -0000 1.66 *************** *** 20,24 **** while (hCtrl) { ! if (GetWindowLong(hCtrl,GWL_STYLE) & WS_VISIBLE) { GetWindowRect(hCtrl,&rect); --- 20,24 ---- while (hCtrl) { ! if (IsWindowVisible(hCtrl)) { GetWindowRect(hCtrl,&rect); *************** *** 39,43 **** while (hCtrl) { ! if (GetWindowLong(hCtrl,GWL_STYLE) & WS_VISIBLE) { GetWindowRect(hCtrl,&rect); --- 39,43 ---- while (hCtrl) { ! if (IsWindowVisible(hCtrl)) { GetWindowRect(hCtrl,&rect); *************** *** 1113,1117 **** BOOL osGetWindowVisible(WindowHandle window) { ! return (GetWindowLong(window, GWL_STYLE) & WS_VISIBLE) != 0; } --- 1113,1117 ---- BOOL osGetWindowVisible(WindowHandle window) { ! return IsWindowVisible(window); } *************** *** 1353,1357 **** BOOL osGetControlVisible(WindowHandle ctrl) { ! return (GetWindowLong(ctrl, GWL_STYLE) & WS_VISIBLE) != 0; } --- 1353,1357 ---- BOOL osGetControlVisible(WindowHandle ctrl) { ! return IsWindowVisible(ctrl); } *************** *** 1496,1500 **** pData->windowPosRect.bottom = y1; ! if (GetWindowLong(window,GWL_STYLE) & WS_VISIBLE) SetupWindowPosition(window); } --- 1496,1500 ---- pData->windowPosRect.bottom = y1; ! if (IsWindowVisible(window)) SetupWindowPosition(window); } |