Beispiel #1
0
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);
}
Beispiel #2
0
extern pascal void 		LSelectAll(ListHandle listH)
{
	Cell listCell;
	SInt16 row;
	ListBounds bounds;

	(void) GetListDataBounds(listH, &bounds);
	for (row = 0; row < bounds.bottom; row++) {
		listCell.v = row;
		listCell.h = 0;
		LSetSelectWhite(true, listCell, listH);
	}
}
Beispiel #3
0
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);
}
Beispiel #4
0
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);
}
Beispiel #5
0
static Boolean LSelectFirstCommon(ListHandle listH, ConstStr255Param markerText, GetListCellTextProcType getCellText,
												Boolean before, Boolean orEqual)
	/*	This function selects the first cell alphabetically before (or after, depending
		on the value of "before") the markerText.  If returns true if it managed to do this,
		false otherwise.  The orEqual value determines whether an
		equal value is considered to be before the otherwise best value.
	*/
{
	Boolean result;
	SInt16 	row;
	SInt16 	indexOfBestText;
	Cell 	listCell;
	Str255 	bestText;
	Str255 	cellText;
	SInt16 	comp1;
	SInt16 	comp2;
	ListBounds bounds;

	assert(getCellText != NULL);

	// Establish some pre-conditions.
	result = false;
	indexOfBestText = 0;
	if (before) {
		bestText[0] = 0;
	} else {
		bestText[0] = 0;
		bestText[1] = 255;
		bestText[2] = 255;
	}
	
	/*	Iterate through all the cells, looking for best text.  Best is defined
		as the phone thatÕs alphabetically before (or after, depending on
		the value of before) the markerText.
	*/
	(void) GetListDataBounds(listH, &bounds);
	for (row = 0; row < bounds.bottom; row++) {
		listCell.h = 0;
		listCell.v = row;
		getCellText(listH, &listCell, cellText);

		/*	OK, so this needs some explaining (-:
			comp1 and comp2 just cache the value of the comparisons between
			markerText, cellText and bestText.
			
			If before is true, weÕre looking for the cell immediately before
			the markerText.  This means that the markerText must be
			greater than (ie "comp1 > 0") or equal to (ie "| (comp1 == 0)")
			the cellText, and the cellText must be greater than (ie "comp2 > 0")
			the bestText weÕve found so far.
			
			If before is false, weÕre looking for the cell immediately after
			the markerText.  This means that the markerText must be
			less than (ie "comp1 < 0") or equal to (ie "| (comp1 == 0)")
			the cellText, and the cellText must be less than (ie "comp2 < 0")
			the bestText weÕve found so far.
			
			*phew*
		*/
		comp1 = CompareString(markerText, cellText, NULL);
		comp2 = CompareString(cellText,   bestText, NULL);
		if ((		before && (((comp1 > 0) || ((comp1 == 0) && orEqual)) && (comp2 > 0))) ||
			(!before & (((comp1 < 0) || ((comp1 == 0) && orEqual)) && (comp2 < 0))) ) {
			BlockMoveData(cellText, bestText, cellText[0] + 1);
			indexOfBestText = listCell.v;
			result = true;
		}
	}
	
	// Now set the selection to the cell we found.
	if (result) {
		LSetSingleSelection(listH, indexOfBestText);
	}
	return result;
}
// --------------------------------------------------------------------------------------
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