void wxCheckListBox::OnLeftClick(wxMouseEvent& event) { // clicking on the item selects it, clicking on the checkmark toggles if ( event.GetX() <= 20 /*check width*/ ) { int lineheight ; int topcell ; #if TARGET_CARBON Point pt ; GetListCellSize( (ListHandle)m_macList , &pt ) ; lineheight = pt.v ; ListBounds visible ; GetListVisibleCells( (ListHandle)m_macList , &visible ) ; topcell = visible.top ; #else lineheight = (**(ListHandle)m_macList).cellSize.v ; topcell = (**(ListHandle)m_macList).visible.top ; #endif size_t nItem = ((size_t)event.GetY()) / lineheight + topcell ; if ( nItem < (size_t)m_noItems ) { Check(nItem, !IsChecked(nItem) ) ; wxCommandEvent event(wxEVT_COMMAND_CHECKLISTBOX_TOGGLED, GetId()); event.SetInt(nItem); event.SetEventObject(this); GetEventHandler()->ProcessEvent(event); } //else: it's not an error, just click outside of client zone } else { // implement default behaviour: clicking on the item selects it event.Skip(); } }
void logevent(void *frontend, const char *str) { Session *s = frontend; ListBounds bounds, visible; Cell cell = { 0, 0 }; if (s->eventlog == NULL) mac_createeventlog(s); if (s->eventlog == NULL) return; #if TARGET_API_MAC_CARBON GetListDataBounds(s->eventlog, &bounds); GetListVisibleCells(s->eventlog, &visible); #else bounds = (*s->eventlog)->dataBounds; visible = (*s->eventlog)->visible; #endif cell.v = bounds.bottom; LAddRow(1, cell.v, s->eventlog); LSetCell(str, strlen(str), cell, s->eventlog); /* ">=" and "2" because there can be a blank cell below the last one. */ if (visible.bottom >= bounds.bottom) LScroll(0, 2, s->eventlog); }
// -------------------------------------------------------------------------------------- void RedrawPrefsWindowList(WindowRef prefsWindow) { ListHandle iconList; ListBounds visibleCells; SInt16 pixelDepth; Boolean isColorDevice; short row; Cell theCell; GetWindowProperty(prefsWindow, kAppSignature, kIconListTag, sizeof(ListHandle), NULL, &iconList); GetListVisibleCells(iconList, &visibleCells); GetWindowDeviceDepthAndColor(prefsWindow, &pixelDepth, &isColorDevice); SetThemeBackground(kThemeBrushWhite, pixelDepth, isColorDevice); for (row = visibleCells.top; row < visibleCells.bottom; row++) // redraw just the { // visible cells SetPt(&theCell, 0, row); LDraw(theCell, iconList); } }
// -------------------------------------------------------------------------------------- void HandleKeyDown(char keyCode, WindowRef prefsWindow) { /* Why use the virtual key code instead of the character code? When the control key is held down it often masks out bit 7 of the character code, thus making it impossible to distinguish between some key presses such as page down (0x0C) and control-L (0x4C & ~bit7 = 0x0C). The virtual key codes, on the other hand, are unaffected by modifier keys. */ if ( (keyCode == kUpArrowKeyCode) || (keyCode == kDownArrowKeyCode) ) { ListHandle iconList; ListBounds bounds; short lastRow; Cell selectedCell; GetWindowProperty(prefsWindow, kAppSignature, kIconListTag, sizeof(ListHandle), NULL, &iconList); GetListDataBounds(iconList, &bounds); lastRow = bounds.bottom - bounds.top - 1; SetPt(&selectedCell, 0, 0); LGetSelect(true, &selectedCell, iconList); if ( (keyCode == kUpArrowKeyCode) && (selectedCell.v > 0) ) { SInt16 pixelDepth; Boolean isColorDevice; GetWindowDeviceDepthAndColor(prefsWindow, &pixelDepth, &isColorDevice); SetThemeBackground(kThemeBrushWhite, pixelDepth, isColorDevice); LSetSelect(false, selectedCell, iconList); // LSetSelect causes the indicated selectedCell.v--; // cell to be highlighted immediately (no update event) LSetSelect(true, selectedCell, iconList); LAutoScroll(iconList); // scroll the list in case the selected cell isn't in view changePanel(prefsWindow, selectedCell.v + 1); } else if ( (keyCode == kDownArrowKeyCode) && (selectedCell.v < lastRow) ) { SInt16 pixelDepth; Boolean isColorDevice; GetWindowDeviceDepthAndColor(prefsWindow, &pixelDepth, &isColorDevice); SetThemeBackground(kThemeBrushWhite, pixelDepth, isColorDevice); LSetSelect(false, selectedCell, iconList); selectedCell.v++; LSetSelect(true, selectedCell, iconList); LAutoScroll(iconList); // scroll the list in case the selected cell isn't in view changePanel(prefsWindow, selectedCell.v + 1); } } else if ( (keyCode == kPageUpKeyCode) || (keyCode == kPageDownKeyCode) ) { ListHandle iconList; ListBounds visibleCells; SInt16 pixelDepth; Boolean isColorDevice; GetWindowProperty(prefsWindow, kAppSignature, kIconListTag, sizeof(ListHandle), NULL, &iconList); GetListVisibleCells(iconList, &visibleCells); GetWindowDeviceDepthAndColor(prefsWindow, &pixelDepth, &isColorDevice); SetThemeBackground(kThemeBrushWhite, pixelDepth, isColorDevice); // LScroll causes the affected cells to be drawn immediately if (keyCode == kPageUpKeyCode) // (no update event) LScroll(0, -(visibleCells.bottom - 1 - visibleCells.top), iconList); else // keyCode == kPageDownKeyCode LScroll(0, (visibleCells.bottom - 1 - visibleCells.top), iconList); } } // HandleKeyDown