/* -----------------------------------------------------------------------------*/ static void ShowSrcDestProc (SlotRefNum sref, TSlotInfos * slotInfo, long refcon) { SlotsProcInfo * info = (SlotsProcInfo *)refcon; Boolean cnx = IsAcceptedBit(slotInfo->cnx, info->port); if (slotInfo->direction & MidiInputSlot) { LSetSelect (cnx, info->src, theList[SrcL]); info->src.v++; } if (slotInfo->direction & MidiOutputSlot) { LSetSelect (cnx, info->dst, theList[DstL]); info->dst.v++; } }
// -------------------------------------------------------------------------------------- void OpenPrefsDialog(void) { DialogRef dialog; WindowRef dialogWindow; ControlRef control; ListHandle iconList; Cell theCell; dialog = GetNewDialog(rPrefsDialogPlatinum, NULL, kFirstWindowOfClass); if (dialog == NULL) ExitToShell(); SetPortDialogPort(dialog); dialogWindow = GetDialogWindow(dialog); SetDialogDefaultItem(dialog, kStdOkItemIndex); SetDialogCancelItem(dialog, kStdCancelItemIndex); GetDialogItemAsControl(dialog, iIconList, &control); GetControlData(control, kControlEntireControl, kControlListBoxListHandleTag, sizeof(ListHandle), &iconList, NULL); AddRowsAndDataToIconList(iconList, rIconListIconBaseID); (*iconList)->selFlags = lOnlyOne; SetPt(&theCell, 0, 0); LSetSelect(true, theCell, iconList); SetKeyboardFocus(dialogWindow, control, kControlFocusNextPart); gPanelNumber = 0; DisableMenuItem(GetMenuRef(mDemonstration), iPrefsDialog); ShowWindow(dialogWindow); } // OpenPrefsDialog
Boolean AddPopulateCompInfo() { int i; char *currDesc; Point currCell; Boolean bCellSelected = false; int nextRow = 0; for (i=0; i<gControls->cfg->numComps; i++) { if (!gControls->cfg->comp[i].invisible && gControls->cfg->comp[i].additional) { HLock(gControls->cfg->comp[i].shortDesc); currDesc = *gControls->cfg->comp[i].shortDesc; SetPt(&currCell, 0, nextRow); rowToComp[nextRow++] = i; LSetCell( currDesc, strlen(currDesc), currCell, gControls->aw->compList); HUnlock(gControls->cfg->comp[i].shortDesc); if (gControls->cfg->comp[i].selected == true) { LSetSelect(true, currCell, gControls->aw->compList); bCellSelected = true; } } } numRows = nextRow; return bCellSelected; }
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 void ClearSelectInList (ListHandle list) { Cell cell; cell.h = cell.v = 0; while (LGetSelect (true, &cell, list)) { LSetSelect (false, cell, list); } }
/* -----------------------------------------------------------------------------*/ static void ListMove (char direction) { Cell c, next; ListHandle list = GetSelectedSlot (&c); if (!list) return; next = c; switch (direction) { case kUpArrowCharCode: next.v -= 1; break; case kDownArrowCharCode: if (!LNextCell(false, true, &next, list)) next.v = -1; break; } if (next.v >= 0) { LSetSelect (false, c, list); LSetSelect (true, next, list); LAutoScroll (list); ListPorts (list, false); } }
extern pascal void LSetSelectWhite(Boolean setIt, Cell theCell, ListHandle lHandle) { OSStatus err; MoreThemeDrawingState state; err = MoreGetThemeDrawingState(&state); if (err == noErr) { err = MoreNormalizeThemeDrawingState(); assert(err == noErr); LSetSelect(setIt, theCell, lHandle); err = MoreSetThemeDrawingState(state, true); assert(err == noErr); } assert(err == noErr); }
// -------------------------------------------------------------------------------------- static ListHandle createIconList(WindowRef window, Rect listRect) { ListBounds dataBounds; Point cellSize; ListHandle iconList; Cell theCell; ListDefSpec listSpec; OSStatus error; SetRect(&dataBounds, 0, 0, 1, 0); // initially there are no rows SetPt(&cellSize, kListWidth, kCellHeight); #if TARGET_API_MAC_OS8 #pragma unused (listSpec, error) iconList = LNew(&listRect, &dataBounds, cellSize, kIconListLDEF, window, true, false, false, true); #else // we could use RegisterListDefinition and LNew in Carbon instead // but we already show how to do that in PrefsDialog.c gIconListDef = NewListDefUPP(IconListDef); listSpec.defType = kListDefUserProcType; listSpec.u.userProc = gIconListDef; error = CreateCustomList(&listRect, &dataBounds, cellSize, &listSpec, window, true, false, false, true, &iconList); if (error && (iconList != NULL)) { LDispose(iconList); DisposeListDefUPP(gIconListDef); iconList = NULL; } #endif if (iconList != NULL) { SetListSelectionFlags(iconList, lOnlyOne); AddRowsAndDataToIconList(iconList, rIconListIconBaseID); SetPt(&theCell, 0, 0); LSetSelect(true, theCell, iconList); // select the first Cell drawFrameAndFocus(iconList, true, window); } return iconList; }
static int message_ListWin(int message, long param) { Cell cell; Rect rect; switch(message){ case MW_GROW: rect=win.ref->portRect; LSize(rect.right-14, rect.bottom-14, gPlaylist); return 0; case MW_LIST_SELECT: LDeselectAll(gPlaylist); cell.h=0; cell.v=param; LSetSelect(true, cell, gPlaylist); LAutoScroll(gPlaylist); return 0; } return -1; //not supported }
void AddSetOptInfo(Boolean bDrawingWindow) { Cell currCell; int row, beingSelected; Boolean setSelected; // so we must determine the row clicked and resolve its dependees // bumping up their ref counts if this row is selected // and down if this row is unselected if (!bDrawingWindow) { currCell = LLastClick(gControls->aw->compList); row = currCell.v; // toggle from on to off or vice versa if (gControls->cfg->comp[rowToComp[row]].selected) beingSelected = kNotSelected; else beingSelected = kSelected; ResolveDependees(rowToComp[row], beingSelected); } // then update the UI for (row = 0; row < numRows; row++) { SetPt(&currCell, 0, row); if (gControls->cfg->comp[rowToComp[row]].selected == kSelected) setSelected = true; else setSelected = false; LSetSelect(setSelected, currCell, gControls->aw->compList); } ClearDiskSpaceMsgs(); DrawDiskSpaceMsgs( gControls->opt->vRefNum ); }
// -------------------------------------------------------------------------------------- void OpenPrefsDialog(void) { ListDefSpec listSpec; DialogRef dialog; WindowRef dialogWindow; EventTypeSpec dialogEvents[] = { {kEventClassControl, kEventControlHit} }; ControlID controlID = {kAppSignature, 0}; ControlRef control; EventTypeSpec listBoxControlEvents[] = { {kEventClassTextInput, kEventTextInputUnicodeForKeyEvent} }; ListHandle iconList; Cell theCell; listSpec.defType = kListDefUserProcType; listSpec.u.userProc = NewListDefUPP(IconListDef); // this is automatically disposed // when the program exits RegisterListDefinition(kIconListLDEF, &listSpec); dialog = GetNewDialog(rPrefsDialog, NULL, kFirstWindowOfClass); if (dialog == NULL) ExitToShell(); SetPortDialogPort(dialog); dialogWindow = GetDialogWindow(dialog); // install window handlers ChangeWindowAttributes(dialogWindow, kWindowStandardHandlerAttribute, kWindowNoAttributes); gDialogEventHandler = NewEventHandlerUPP(dialogEventHandler); InstallWindowEventHandler(dialogWindow, gDialogEventHandler, GetEventTypeCount(dialogEvents), dialogEvents, (void *)dialog, NULL); GetDialogItemAsControl(dialog, kStdOkItemIndex, &control); // set control IDs to controlID.id = kStdOkItemIndex; // match dialog item SetControlID(control, &controlID); // indices which are SetWindowDefaultButton(dialogWindow, control); // not tracked by any // standard handlers GetDialogItemAsControl(dialog, kStdCancelItemIndex, &control); // also set the default controlID.id = kStdCancelItemIndex; // and cancel buttons (because Mac OS 8/9 SetControlID(control, &controlID); // under CarbonLib doesn't respect the SetWindowCancelButton(dialogWindow, control); // dialog's default and cancel buttons) GetDialogItemAsControl(dialog, iIconList, &control); controlID.id = iIconList; SetControlID(control, &controlID); /* We need to postprocess keyboard events on the icon list so that we can change panels after the user changes the selected cell by using the keyboard. */ gListBoxControlEventHandler = NewEventHandlerUPP(listBoxControlEventHandler); InstallControlEventHandler(control, gListBoxControlEventHandler, GetEventTypeCount(listBoxControlEvents), listBoxControlEvents, (void *)dialog, NULL); GetControlData(control, kControlEntireControl, kControlListBoxListHandleTag, sizeof(ListHandle), &iconList, NULL); AddRowsAndDataToIconList(iconList, rIconListIconBaseID); SetListSelectionFlags(iconList, lOnlyOne); SetPt(&theCell, 0, 0); LSetSelect(true, theCell, iconList); SetKeyboardFocus(dialogWindow, control, kControlFocusNextPart); gPanelNumber = 0; SetPrefsDialogHelpTags(dialog); DisableMenuItem(GetMenuRef(mDemonstration), iPrefsDialog); ShowWindow(dialogWindow); } // OpenPrefsDialog
// -------------------------------------------------------------------------------------- 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