/* -----------------------------------------------------------------------------*/ static ListHandle GetSelectedSlot (Cell *c) { c->h = c->v = 0; if (LGetSelect (true, c, theList[SrcL])) return theList[SrcL]; c->h = c->v = 0; if (LGetSelect (true, c, theList[DstL])) return theList[DstL]; return 0; }
// -------------------------------------------------------------------------------------- void HandleContentClick(WindowRef window, Point mouseLocation, EventModifiers modifiers) { ListHandle iconList; Rect iconListRect; Boolean isDoubleClick; Cell theCell; GetWindowProperty(window, kAppSignature, kIconListTag, sizeof(ListHandle), NULL, &iconList); GetListViewBounds(iconList, &iconListRect); iconListRect.right += kScrollBarWidth; SetPortWindowPort(window); GlobalToLocal(&mouseLocation); if (PtInRect(mouseLocation, &iconListRect)) { SInt16 pixelDepth; Boolean isColorDevice; GetWindowDeviceDepthAndColor(window, &pixelDepth, &isColorDevice); SetThemeBackground(kThemeBrushWhite, pixelDepth, isColorDevice); // if LClick causes the list selection to change, or the isDoubleClick = LClick(mouseLocation, modifiers, iconList); // scroll bar SetPt(&theCell, 0, 0); // to change, the affected cells are LGetSelect(true, &theCell, iconList); // immediately drawn (no update event) if ((theCell.v + 1) != gPanelNumber) changePanel(window, theCell.v + 1); } }
int wxListBox::MacGetSelection() const { Cell cell = { 0 , 0 } ; if ( LGetSelect( true , &cell , (ListHandle)m_macList ) ) return cell.v ; else return -1 ; }
/* -----------------------------------------------------------------------------*/ static void ClearSelectInList (ListHandle list) { Cell cell; cell.h = cell.v = 0; while (LGetSelect (true, &cell, list)) { LSetSelect (false, cell, list); } }
/* -----------------------------------------------------------------------------*/ static SlotRefNum LastSelectedSlot (ListHandle list, Cell * c) { SlotRefNum sref; sref.slotRef = -1; c->h = c->v = 0; if (LGetSelect (true, c, list)) Cell2Slot (list, c, &sref); return sref; }
void UpdateAdditionsWin(void) { Rect r; Cell c; int i; GrafPtr oldPort; GetPort(&oldPort); SetPort(gWPtr); MoveTo( gControls->aw->compListBox.left, gControls->aw->compListBox.top - kInterWidgetPad + 1); HLock(gControls->cfg->selAddMsg); DrawString( CToPascal(*gControls->cfg->selAddMsg)); HUnlock(gControls->cfg->selAddMsg); #if 0 RGBColor backColorOld; Rect adjustedRect, *clRect = &gControls->aw->compListBox; SetRect(&adjustedRect, clRect->left, clRect->top+1, clRect->right, clRect->bottom-1); GetBackColor(&backColorOld); BackColor(whiteColor); EraseRect(&adjustedRect); RGBBackColor(&backColorOld); #endif LUpdate( (*gControls->aw->compList)->port->visRgn, gControls->aw->compList); SetRect(&r, gControls->aw->compListBox.left, gControls->aw->compListBox.top, gControls->aw->compListBox.right + 1, gControls->aw->compListBox.bottom); FrameRect(&r); SetPt(&c, 0, 0); if (LGetSelect(true, &c, gControls->aw->compList)) { HLock((Handle)gControls->aw->compDescTxt); SetRect(&r, (*gControls->aw->compDescTxt)->viewRect.left, (*gControls->aw->compDescTxt)->viewRect.top, (*gControls->aw->compDescTxt)->viewRect.right, (*gControls->aw->compDescTxt)->viewRect.bottom); HUnlock((Handle)gControls->aw->compDescTxt); TEUpdate(&r, gControls->aw->compDescTxt); } DrawDiskSpaceMsgs( gControls->opt->vRefNum ); for (i = 0; i < numRows; i++) { if (gControls->cfg->comp[rowToComp[i]].highlighted) { AddInitRowHighlight(i); break; } } SetPort(oldPort); }
/* -----------------------------------------------------------------------------*/ Boolean ChangeConnect (ListHandle list) { Cell c; SlotRefNum sref = LastClickedSlot (list, &c); if (portSelected < 0) return false; if (sref.slotRef < 0) return false; MidiConnectSlot (portSelected, sref, LGetSelect (false, &c, list)); RefreshPortMap (); return true; }
extern pascal void LSetNoSelection(ListHandle listH) // See comment in interface part. { Cell listCell; listCell.v = 0; listCell.h = 0; while ( LGetSelect(true, &listCell, listH) ) { LSetSelectWhite(false, listCell, listH); listCell.v = listCell.v + 1; listCell.h = 0; } }
void wxListBox::MacSetSelection( int n , bool select ) { Cell cell = { 0 , 0 } ; if ( ! (m_windowStyle & wxLB_MULTIPLE) ) { if ( LGetSelect( true , &cell , (ListHandle)m_macList ) ) { LSetSelect( false , cell , (ListHandle)m_macList ) ; } } cell.v = n ; LSetSelect( select , cell , (ListHandle)m_macList ) ; LAutoScroll( (ListHandle)m_macList ) ; Refresh(); }
static Boolean LGetSelectedCellCommon(ListHandle listH, Cell *listCell, GetListCellTextProcType getCellText, Boolean first) /* This function finds the alphabetically first or last cell (depending on the value of first) in the currently selected cells of the list. It returns false if there are no selected cells. */ { Boolean result; Str255 cellText; Str255 bestText; SInt16 indexOfBestText; assert(getCellText != NULL); // Establish some pre-conditions. result = false; listCell->h = 0; listCell->v = 0; indexOfBestText = 0; if (first) { bestText[0] = 0; bestText[1] = 255; bestText[2] = 255; } else { bestText[0] = 0; } // Loop through the selected cells, looking for the best text (ie the // alphabetically first or last). while ( LGetSelect(true, listCell, listH) ) { result = true; getCellText(listH, listCell, cellText); if ( (first && (CompareString(cellText, bestText, NULL) < 0)) || (!first && (CompareString(cellText, bestText, NULL) > 0)) ) { indexOfBestText = listCell->v; BlockMoveData(cellText, bestText, cellText[0] + 1); } listCell->v += 1; } // Finish up. listCell->h = 0; listCell->v = indexOfBestText; return result; }
int wxListBox::MacGetSelections( wxArrayInt& aSelections ) const { int no_sel = 0 ; aSelections.Empty(); Cell cell = { 0 , 0 } ; cell.v = 0 ; while ( LGetSelect( true , &cell ,(ListHandle) m_macList ) ) { aSelections.Add( cell.v ) ; no_sel++ ; cell.v++ ; } return no_sel ; }
static void LUpArrow(ListHandle listH) /* Find the first selected cell and select the cell before it. */ { Cell listCell; ListBounds bounds; listCell.h = 0; listCell.v = 0; (void) GetListDataBounds(listH, &bounds); if ( !LGetSelect(true, &listCell, listH) ) { listCell.v = bounds.bottom; } if (listCell.v > 0) { listCell.v = listCell.v - 1; } LSetSingleSelection(listH, listCell.v); LAutoScrollWhite(listH); }
extern pascal void LSetSingleSelection(ListHandle listH, SInt16 row) // See comment in interface part. { Cell listCell; listCell.h = 0; listCell.v = row; LSetSelectWhite(true, listCell, listH); listCell.v = 0; listCell.h = 0; while ( LGetSelect(true, &listCell, listH) ) { if (listCell.v != row) { LSetSelectWhite(false, listCell, listH); } listCell.v = listCell.v + 1; listCell.h = 0; } LAutoScrollWhite(listH); }
static void LDownArrow(ListHandle listH) /* Find the last selected cell and select the cell after it. */ { Cell listCell; SInt16 indexOfCellToSelect; ListBounds bounds; listCell.h = 0; listCell.v = 0; indexOfCellToSelect = 0; while ( LGetSelect(true, &listCell, listH) ) { listCell.v = listCell.v + 1; indexOfCellToSelect = listCell.v; } (void) GetListDataBounds(listH, &bounds); if (indexOfCellToSelect >= bounds.bottom) { indexOfCellToSelect = bounds.bottom - 1; } LSetSingleSelection(listH, indexOfCellToSelect); LAutoScrollWhite(listH); }
// -------------------------------------------------------------------------------------- static void handleDialogItemHit(DialogRef prefsDialog, DialogItemIndex itemHit) { if (itemHit == iIconList) { ControlRef listBoxControl; ListHandle iconList; Cell theCell; GetDialogItemAsControl(prefsDialog, iIconList, &listBoxControl); GetControlData(listBoxControl, kControlEntireControl, kControlListBoxListHandleTag, sizeof(ListHandle), &iconList, NULL); SetPt(&theCell, 0, 0); LGetSelect(true, &theCell, iconList); if ((theCell.v) != gPanelNumber) changePanel(prefsDialog, theCell.v); } else if ( (itemHit == kStdOkItemIndex) || (itemHit == kStdCancelItemIndex) ) ClosePrefsDialog(prefsDialog); }
/* -----------------------------------------------------------------------------*/ Boolean ListPorts (ListHandle list, Boolean fromClick) { TSlotInfos slotInfo; short i; Cell c; ListHandle alt = (list == theList[SrcL]) ? theList[DstL] : theList[SrcL]; SlotRefNum sref = fromClick ? LastClickedSlot (list, &c) : LastSelectedSlot(list, &c); if (sref.slotRef < 0) goto reset; if (LGetSelect (false, &c, list)) { if (MidiGetSlotInfos (sref, &slotInfo)) { for (i = 0; i < 32; i++) { SelectedSlotMap[i] = slotInfo.cnx[i]; } } ClearSelectInList (alt); InvalPortArea (); return true; } reset: ClearSelectInList (alt); ResetSlotsMap (); InvalPortArea (); return false; }
bool wxListBox::MacIsSelected( int n ) const { Cell cell = { 0 , 0 } ; cell.v = n ; return LGetSelect( false , &cell , (ListHandle)m_macList ) ; }
// -------------------------------------------------------------------------------------- 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