void DocInfoWindow::MessageReceived(BMessage *msg) { switch (msg->what) { case OK_MSG: { BMessage doc_info; _ReadFieldsFromTable(doc_info); _DocInfo()->RemoveName("doc_info"); _DocInfo()->AddMessage("doc_info", &doc_info); #if HAVE_FULLVERSION_PDF_LIB _ReadPasswords(); _ReadPermissions(); #endif Quit(); } break; case CANCEL_MSG: { Quit(); } break; case ADD_KEY_MSG: { case DEFAULT_KEY_MSG: _AddKey(msg, msg->what == ADD_KEY_MSG); } break; case REMOVE_KEY_MSG: { _RemoveKey(msg); } break; default: { inherited::MessageReceived(msg); } break; } }
/********************************************************************* * * LISTBOX_AddKey * * Returns: 1 if Key has been consumed * 0 else */ int LISTBOX_AddKey(LISTBOX_Handle hObj, int Key) { int r = 0; if (hObj) { WM_LOCK(); r = _AddKey(hObj, Key); WM_UNLOCK(); } return r; }
/********************************************************************* * * _LISTVIEW_Callback */ static void _LISTVIEW_Callback (WM_MESSAGE *pMsg) { LISTVIEW_Handle hObj; LISTVIEW_Obj* pObj; WM_SCROLL_STATE ScrollState; hObj = pMsg->hWin; /* Let widget handle the standard messages */ if (WIDGET_HandleActive(hObj, pMsg) == 0) { return; } pObj = LISTVIEW_H2P(hObj); switch (pMsg->MsgId) { case WM_NOTIFY_CLIENTCHANGE: case WM_SIZE: LISTVIEW__UpdateScrollParas(hObj, pObj); return; case WM_NOTIFY_PARENT: switch (pMsg->Data.v) { case WM_NOTIFICATION_CHILD_DELETED: /* make sure we do not send any messages to the header child once it has been deleted */ if (pMsg->hWinSrc == pObj->hHeader) { pObj->hHeader = 0; } break; case WM_NOTIFICATION_VALUE_CHANGED: if (pMsg->hWinSrc == WM_GetScrollbarV(hObj)) { WM_GetScrollState(pMsg->hWinSrc, &ScrollState); pObj->ScrollStateV.v = ScrollState.v; LISTVIEW__InvalidateInsideArea(hObj, pObj); _NotifyOwner(hObj, WM_NOTIFICATION_SCROLL_CHANGED); } else if (pMsg->hWinSrc == WM_GetScrollbarH(hObj)) { WM_GetScrollState(pMsg->hWinSrc, &ScrollState); pObj->ScrollStateH.v = ScrollState.v; LISTVIEW__UpdateScrollParas(hObj, pObj); HEADER_SetScrollPos(pObj->hHeader, pObj->ScrollStateH.v); _NotifyOwner(hObj, WM_NOTIFICATION_SCROLL_CHANGED); } break; case WM_NOTIFICATION_SCROLLBAR_ADDED: LISTVIEW__UpdateScrollParas(hObj, pObj); break; } return; case WM_PAINT: _Paint(hObj, pObj, pMsg); return; case WM_TOUCH: _OnTouch(hObj, pObj, pMsg); return; /* Important: message handled ! */ case WM_KEY: if (((const WM_KEY_INFO*)(pMsg->Data.p))->PressedCnt > 0) { int Key; Key = ((const WM_KEY_INFO*)(pMsg->Data.p))->Key; if (_AddKey(hObj, Key)) { return; } } break; /* No return here ... WM_DefaultProc needs to be called */ case WM_DELETE: _FreeAttached(pObj); break; /* No return here ... WM_DefaultProc needs to be called */ } WM_DefaultProc(pMsg); }
/********************************************************************* * * LISTVIEW_Callback */ void LISTVIEW_Callback (WM_MESSAGE *pMsg) { LISTVIEW_Handle hObj; LISTVIEW_Obj* pObj; WM_SCROLL_STATE ScrollState; hObj = pMsg->hWin; /* Let widget handle the standard messages */ if (WIDGET_HandleActive(hObj, pMsg) == 0) { return; } pObj = (LISTVIEW_Obj *)GUI_ALLOC_h2p(hObj); /* Don't use use WIDGET_H2P because WIDGET_INIT_ID() has not be called at this point */ switch (pMsg->MsgId) { case WM_NOTIFY_CLIENTCHANGE: case WM_SIZE: if (pMsg->hWinSrc && (pMsg->hWinSrc == pObj->hHeader)) { LISTVIEW__UpdateScrollParas(hObj, pObj); } return; case WM_NOTIFY_PARENT: switch (pMsg->Data.v) { case WM_NOTIFICATION_CHILD_DELETED: /* make sure we do not send any messages to the header child once it has been deleted */ if (pMsg->hWinSrc == pObj->hHeader) { pObj->hHeader = 0; } break; case WM_NOTIFICATION_VALUE_CHANGED: if (pMsg->hWinSrc == WM_GetScrollbarV(hObj)) { WM_GetScrollState(pMsg->hWinSrc, &ScrollState); pObj->ScrollStateV.v = ScrollState.v; LISTVIEW__InvalidateInsideArea(hObj, pObj); _NotifyOwner(hObj, WM_NOTIFICATION_SCROLL_CHANGED); } else if (pMsg->hWinSrc == WM_GetScrollbarH(hObj)) { WM_GetScrollState(pMsg->hWinSrc, &ScrollState); pObj->ScrollStateH.v = ScrollState.v; LISTVIEW__UpdateScrollParas(hObj, pObj); HEADER_SetScrollPos(pObj->hHeader, pObj->ScrollStateH.v); _NotifyOwner(hObj, WM_NOTIFICATION_SCROLL_CHANGED); } break; case WM_NOTIFICATION_SCROLLBAR_ADDED: #if WIDGET_USE_PARENT_EFFECT WIDGET_SetEffect(pMsg->hWinSrc, pObj->Widget.pEffect); #endif LISTVIEW__UpdateScrollParas(hObj, pObj); break; case WM_NOTIFICATION_RELEASED: if ((pMsg->hWinSrc == pObj->hHeader) && (pObj->hSort)) { int Column; LISTVIEW_SORT * pSort; LISTVIEW_COLUMN * pColumn; WM_SetFocus(hObj); Column = HEADER_GetSel(pObj->hHeader); if (Column >= 0) { pColumn = (LISTVIEW_COLUMN *)GUI_ARRAY_GetpItem(&pObj->ColumnArray, Column); if (pColumn->fpCompare) { pSort = (LISTVIEW_SORT *)GUI_ALLOC_h2p(pObj->hSort); if (pSort) { // ReverseSort if (pObj->SortIndex == Column) { pSort->Reverse ^= 1; pObj->ReverseSort = 1; pObj->IsSorted = 0; } else { pSort->Reverse = 0; pObj->SortIndex = Column; pObj->IsPresorted = 0; } /* if (pObj->SortIndex == Column) { pSort->Reverse ^= 1; } else { pSort->Reverse = 0; pObj->SortIndex = Column; } pObj->IsPresorted = 0; */ LISTVIEW__InvalidateInsideArea(hObj, pObj); } } } } break; } return; case WM_PAINT: _Paint(hObj, pObj, pMsg); return; case WM_TOUCH: _OnTouch(hObj, pObj, pMsg); return; /* Important: message handled ! */ case WM_KEY: if (((const WM_KEY_INFO*)(pMsg->Data.p))->PressedCnt > 0) { int Key; Key = ((const WM_KEY_INFO*)(pMsg->Data.p))->Key; if (_AddKey(hObj, pObj, Key)) { return; } } break; /* No return here ... WM_DefaultProc needs to be called */ case WM_DELETE: _FreeAttached(pObj); break; /* No return here ... WM_DefaultProc needs to be called */ } WM_DefaultProc(pMsg); }
bool KeyboardLayout::_AddKeyCodes(const parse_state& state, BPoint& rowLeftTop, Key& key, const char* data, int32& lastCount) { if (data[0] == '-') { // no key, just free space int32 num = strtoul(data + 1, NULL, 0); if (num < 1) num = 1; else if (num > 32) { _Error(state, "empty key count too large"); return false; } key.frame.OffsetTo(rowLeftTop); rowLeftTop.x = key.frame.left + key.frame.Width() * num; return true; } int32 modifier = 0; if (isalpha(data[0])) { bool led = false; if (!strcmp("led-caps", data)) { modifier = B_CAPS_LOCK; led = true; } else if (!strcmp("led-num", data)) { modifier = B_NUM_LOCK; led = true; } else if (!strcmp("led-scroll", data)) { modifier = B_SCROLL_LOCK; led = true; } else { // TODO: get modifier (ie. "num") } if (led) { key.frame.OffsetTo(rowLeftTop); rowLeftTop.x = key.frame.right; fBounds = key.frame | fBounds; Indicator* indicator = new(std::nothrow) Indicator; if (indicator != NULL) { indicator->modifier = modifier; indicator->frame = key.frame; fIndicators.AddItem(indicator); } return true; } } int32 first; int32 last; int32 num = 1; if (data[0] == '+') { num = strtoul(data + 1, NULL, 0); if (num < 1) num = 1; else if (num > 32) { _Error(state, "key count too large"); return false; } if (fKeyCount > 0) first = fKeys[fKeyCount - 1].code + 1; else first = 1; last = first + num - 1; } else { char* end; first = strtoul(data, &end, 0); last = first; if (end[0] == '-') { last = strtoul(end + 1, NULL, 0); if (first > last) { _Error(state, "invalid key code specifier"); return false; } num = last - first; } else if (end[0] == '+') { num = strtoul(end + 1, NULL, 0) + 1; last = first + num - 1; } else if (end[0] != '\0') { _Error(state, "invalid key range"); return false; } } if (lastCount != 0) { // update existing keys if (lastCount != num) { _Error(state, "modifier key mismatch"); return false; } for (int32 i = fKeyCount - num; i < fKeyCount; i++, first++) { Key* key = KeyAt(i); _AddAlternateKeyCode(key, modifier, first); } } else { // add new keys for (int32 i = first; i <= last; i++) { key.code = i; // "layout" key.frame.OffsetTo(rowLeftTop); rowLeftTop.x = key.frame.right; _AddKey(key); } lastCount = num; } return true; }