mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-06-02 07:10:59 +00:00
Minor tidyup.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@3836 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
3fa6c2695a
commit
ee0eb44c06
1 changed files with 196 additions and 183 deletions
|
@ -744,7 +744,7 @@ static int mouseDownFlags = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!allowsEmptySelection) // if we don't allow an
|
if (!allowsEmptySelection) // if we don't allow an
|
||||||
[self selectCellAtRow:0 column:0]; // empty selection
|
[self selectCellAtRow:0 column:0]; // empty selection
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -990,7 +990,7 @@ fprintf(stderr, " NSMatrix: selectTextAtRow --- ");
|
||||||
[cellPrototype setScrollable:flag];
|
[cellPrototype setScrollable:flag];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)drawRect:(NSRect)rect
|
- (void) drawRect: (NSRect)rect
|
||||||
{
|
{
|
||||||
int i, j;
|
int i, j;
|
||||||
int row1, col1; // The cell at the upper left corner
|
int row1, col1; // The cell at the upper left corner
|
||||||
|
@ -1003,47 +1003,56 @@ fprintf(stderr, " NSMatrix: selectTextAtRow --- ");
|
||||||
NSRectFill(rect);
|
NSRectFill(rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
[self _getRow:&row1 column:&col1
|
[self _getRow: &row1 column: &col1 forPoint: rect.origin
|
||||||
forPoint:rect.origin
|
above: NO right: NO isBetweenCells: NULL];
|
||||||
above:NO right:NO
|
[self _getRow: &row2 column: &col2
|
||||||
isBetweenCells:NULL];
|
forPoint: NSMakePoint(NSMaxX(rect), NSMaxY(rect))
|
||||||
[self _getRow:&row2 column:&col2
|
above: NO right: NO isBetweenCells: NULL];
|
||||||
forPoint:NSMakePoint(NSMaxX(rect), NSMaxY(rect))
|
|
||||||
above:NO right:NO
|
|
||||||
isBetweenCells:NULL];
|
|
||||||
|
|
||||||
if (row1 < 0)
|
if (row1 < 0)
|
||||||
row1 = 0;
|
row1 = 0;
|
||||||
if (col1 < 0)
|
if (col1 < 0)
|
||||||
col1 = 0;
|
col1 = 0;
|
||||||
|
|
||||||
//NSLog (@"display cells between (%d, %d) and (%d, %d)",row1,col1, row2, col2);
|
|
||||||
|
|
||||||
/* Draw the cells within the drawing rectangle. */
|
/* Draw the cells within the drawing rectangle. */
|
||||||
for (i = row1; i <= row2 && i < numRows; i++)
|
for (i = row1; i <= row2 && i < numRows; i++)
|
||||||
for (j = col1; j <= col2 && j < numCols; j++)
|
for (j = col1; j <= col2 && j < numCols; j++)
|
||||||
[self drawCellAtRow:i column:j];
|
[self drawCellAtRow: i column: j];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)drawCellAtRow:(int)row column:(int)column
|
- (void) drawCellAtRow: (int)row column: (int)column
|
||||||
{
|
{
|
||||||
NSCell *aCell = [self cellAtRow:row column:column];
|
NSCell *aCell = [self cellAtRow: row column: column];
|
||||||
NSRect cellFrame = [self cellFrameAtRow:row column:column];
|
|
||||||
|
|
||||||
[aCell drawWithFrame:cellFrame inView:self];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)highlightCell:(BOOL)flag
|
|
||||||
atRow:(int)row
|
|
||||||
column:(int)column
|
|
||||||
{
|
|
||||||
NSCell *aCell = [self cellAtRow:row column:column];
|
|
||||||
|
|
||||||
if (aCell)
|
if (aCell)
|
||||||
{
|
{
|
||||||
[aCell highlight:flag
|
NSRect cellFrame = [self cellFrameAtRow: row column: column];
|
||||||
withFrame:[self cellFrameAtRow:row column:column]
|
|
||||||
inView:self];
|
if (drawsCellBackground)
|
||||||
|
{
|
||||||
|
[cellBackgroundColor set];
|
||||||
|
NSRectFill(cellFrame);
|
||||||
|
}
|
||||||
|
[aCell drawWithFrame: cellFrame inView: self];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) highlightCell: (BOOL)flag atRow: (int)row column: (int)column
|
||||||
|
{
|
||||||
|
NSCell *aCell = [self cellAtRow: row column: column];
|
||||||
|
|
||||||
|
if (aCell)
|
||||||
|
{
|
||||||
|
NSRect cellFrame = [self cellFrameAtRow: row column: column];
|
||||||
|
|
||||||
|
if (drawsCellBackground)
|
||||||
|
{
|
||||||
|
[cellBackgroundColor set];
|
||||||
|
NSRectFill(cellFrame);
|
||||||
|
}
|
||||||
|
[aCell highlight: flag
|
||||||
|
withFrame: cellFrame
|
||||||
|
inView: self];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1111,7 +1120,7 @@ fprintf(stderr, " NSMatrix: selectTextAtRow --- ");
|
||||||
[self sendAction];
|
[self sendAction];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL)acceptsFirstMouse:(NSEvent*)theEvent
|
- (BOOL) acceptsFirstMouse: (NSEvent*)theEvent
|
||||||
{
|
{
|
||||||
return mode == NSListModeMatrix ? NO : YES;
|
return mode == NSListModeMatrix ? NO : YES;
|
||||||
}
|
}
|
||||||
|
@ -1303,7 +1312,7 @@ static MPoint anchor = {0, 0};
|
||||||
selectedRow = row; // until the cursor either
|
selectedRow = row; // until the cursor either
|
||||||
selectedColumn = column; // leaves the cellframe or
|
selectedColumn = column; // leaves the cellframe or
|
||||||
// NSLeftMouseUp occurs
|
// NSLeftMouseUp occurs
|
||||||
if([aCell trackMouse:lastEvent
|
if ([aCell trackMouse:lastEvent
|
||||||
inRect:rect
|
inRect:rect
|
||||||
ofView:self
|
ofView:self
|
||||||
untilMouseUp:YES]) // YES if mouse
|
untilMouseUp:YES]) // YES if mouse
|
||||||
|
@ -1318,7 +1327,7 @@ static MPoint anchor = {0, 0};
|
||||||
[aCell highlight: YES withFrame: rect inView: self];
|
[aCell highlight: YES withFrame: rect inView: self];
|
||||||
[window flushWindow];
|
[window flushWindow];
|
||||||
|
|
||||||
if([aCell trackMouse:lastEvent
|
if ([aCell trackMouse:lastEvent
|
||||||
inRect:rect
|
inRect:rect
|
||||||
ofView:self
|
ofView:self
|
||||||
untilMouseUp:YES]) // YES if mouse
|
untilMouseUp:YES]) // YES if mouse
|
||||||
|
@ -1333,7 +1342,7 @@ static MPoint anchor = {0, 0};
|
||||||
if (previousCell == aCell) // more than one cell
|
if (previousCell == aCell) // more than one cell
|
||||||
break; // to be selected
|
break; // to be selected
|
||||||
|
|
||||||
if(selectedCell)
|
if (selectedCell)
|
||||||
{
|
{
|
||||||
[selectedCell setState:0]; // deselect previously
|
[selectedCell setState:0]; // deselect previously
|
||||||
if (!previousCell) // selected cell
|
if (!previousCell) // selected cell
|
||||||
|
@ -1444,7 +1453,7 @@ static MPoint anchor = {0, 0};
|
||||||
switch (mode) // Finish the selection
|
switch (mode) // Finish the selection
|
||||||
{ // process
|
{ // process
|
||||||
case NSRadioModeMatrix:
|
case NSRadioModeMatrix:
|
||||||
if(selectedCell)
|
if (selectedCell)
|
||||||
[selectedCell highlight:NO withFrame:rect inView:self];
|
[selectedCell highlight:NO withFrame:rect inView:self];
|
||||||
case NSListModeMatrix:
|
case NSListModeMatrix:
|
||||||
[self setNeedsDisplayInRect:rect]; // not needed by XRAW
|
[self setNeedsDisplayInRect:rect]; // not needed by XRAW
|
||||||
|
@ -1454,9 +1463,9 @@ static MPoint anchor = {0, 0};
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(selectedCell)
|
if (selectedCell)
|
||||||
{ // send single click action
|
{ // send single click action
|
||||||
if(!(selectedCellTarget = [selectedCell target]))
|
if (!(selectedCellTarget = [selectedCell target]))
|
||||||
{ // selected cell has no target so send single
|
{ // selected cell has no target so send single
|
||||||
if (target) // click action to matrix's (self's) target
|
if (target) // click action to matrix's (self's) target
|
||||||
[target performSelector:action withObject:self];
|
[target performSelector:action withObject:self];
|
||||||
|
@ -1480,21 +1489,16 @@ static MPoint anchor = {0, 0};
|
||||||
[lastEvent release];
|
[lastEvent release];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)updateCell:(NSCell *)aCell
|
- (void) updateCell: (NSCell*)aCell
|
||||||
{ // attempt to update
|
{
|
||||||
int r, c; // only the cell and
|
int row, col;
|
||||||
// not the hole matrix
|
NSRect rect;
|
||||||
if([aCell isOpaque])
|
|
||||||
{
|
|
||||||
if([self getRow:&r column:&c ofCell:aCell])
|
|
||||||
{
|
|
||||||
[self setNeedsDisplayInRect:[self cellFrameAtRow:r column:c]];
|
|
||||||
|
|
||||||
return;
|
if ([self getRow: &row column: &col ofCell: aCell] == NO)
|
||||||
}
|
return; // Not a cell in this matrix - we can't update it.
|
||||||
}
|
|
||||||
// oh well, update the
|
rect = [self cellFrameAtRow: row column: col];
|
||||||
[self setNeedsDisplay:YES]; // whole matrix
|
[self setNeedsDisplayInRect: rect];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL)performKeyEquivalent:(NSEvent*)theEvent
|
- (BOOL)performKeyEquivalent:(NSEvent*)theEvent
|
||||||
|
@ -1674,12 +1678,12 @@ fprintf(stderr, " NSMatrix: keyDown --- ");
|
||||||
|
|
||||||
Note that the cell numbering is flipped relative to the coordinate system.
|
Note that the cell numbering is flipped relative to the coordinate system.
|
||||||
*/
|
*/
|
||||||
- (BOOL)_getRow:(int*)row
|
- (BOOL) _getRow: (int*)row
|
||||||
column:(int*)column
|
column: (int*)column
|
||||||
forPoint:(NSPoint)point
|
forPoint: (NSPoint)point
|
||||||
above:(BOOL)aboveRequired
|
above: (BOOL)aboveRequired
|
||||||
right:(BOOL)rightRequired
|
right: (BOOL)rightRequired
|
||||||
isBetweenCells:(BOOL*)isBetweenCells
|
isBetweenCells: (BOOL*)isBetweenCells
|
||||||
{
|
{
|
||||||
BOOL rowReady = NO, colReady = NO;
|
BOOL rowReady = NO, colReady = NO;
|
||||||
BOOL betweenRows = NO, betweenCols = NO;
|
BOOL betweenRows = NO, betweenCols = NO;
|
||||||
|
@ -1688,20 +1692,24 @@ fprintf(stderr, " NSMatrix: keyDown --- ");
|
||||||
SET_POINTER_VALUE(isBetweenCells, NO);
|
SET_POINTER_VALUE(isBetweenCells, NO);
|
||||||
|
|
||||||
/* First check the limit cases */
|
/* First check the limit cases */
|
||||||
if (point.x > theBounds.size.width) {
|
if (point.x > theBounds.size.width)
|
||||||
|
{
|
||||||
SET_POINTER_VALUE(column, numCols - 1);
|
SET_POINTER_VALUE(column, numCols - 1);
|
||||||
colReady = YES;
|
colReady = YES;
|
||||||
}
|
}
|
||||||
else if (point.x < 0) {
|
else if (point.x < 0)
|
||||||
|
{
|
||||||
SET_POINTER_VALUE(column, 0);
|
SET_POINTER_VALUE(column, 0);
|
||||||
colReady = YES;
|
colReady = YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (point.y > theBounds.size.height) {
|
if (point.y > theBounds.size.height)
|
||||||
|
{
|
||||||
SET_POINTER_VALUE(row, numRows - 1);
|
SET_POINTER_VALUE(row, numRows - 1);
|
||||||
rowReady = YES;
|
rowReady = YES;
|
||||||
}
|
}
|
||||||
else if (point.y < 0) {
|
else if (point.y < 0)
|
||||||
|
{
|
||||||
SET_POINTER_VALUE(row, 0);
|
SET_POINTER_VALUE(row, 0);
|
||||||
rowReady = YES;
|
rowReady = YES;
|
||||||
}
|
}
|
||||||
|
@ -1709,7 +1717,8 @@ fprintf(stderr, " NSMatrix: keyDown --- ");
|
||||||
if (rowReady && colReady)
|
if (rowReady && colReady)
|
||||||
return NO;
|
return NO;
|
||||||
|
|
||||||
if (!rowReady) {
|
if (!rowReady)
|
||||||
|
{
|
||||||
int approxRow = point.y / (cellSize.height + intercell.height);
|
int approxRow = point.y / (cellSize.height + intercell.height);
|
||||||
float approxRowsHeight = approxRow * (cellSize.height + intercell.height);
|
float approxRowsHeight = approxRow * (cellSize.height + intercell.height);
|
||||||
|
|
||||||
|
@ -1722,22 +1731,24 @@ fprintf(stderr, " NSMatrix: keyDown --- ");
|
||||||
if (aboveRequired && betweenRows)
|
if (aboveRequired && betweenRows)
|
||||||
approxRow++;
|
approxRow++;
|
||||||
|
|
||||||
#if HAS_FLIPPED_VIEWS
|
#if HAS_FLIPPED_VIEWS == 0
|
||||||
SET_POINTER_VALUE(row, approxRow);
|
approxRow = numRows - approxRow - 1;
|
||||||
#else
|
|
||||||
SET_POINTER_VALUE(row, numRows - approxRow - 1);
|
|
||||||
#endif
|
#endif
|
||||||
if (*row < 0) {
|
if (approxRow < 0)
|
||||||
*row = -1;
|
{
|
||||||
|
approxRow = -1;
|
||||||
rowReady = YES;
|
rowReady = YES;
|
||||||
}
|
}
|
||||||
else if (*row >= numRows) {
|
else if (approxRow >= numRows)
|
||||||
*row = numRows - 1;
|
{
|
||||||
|
approxRow = numRows - 1;
|
||||||
rowReady = YES;
|
rowReady = YES;
|
||||||
}
|
}
|
||||||
|
SET_POINTER_VALUE(row, approxRow);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!colReady) {
|
if (!colReady)
|
||||||
|
{
|
||||||
int approxCol = point.x / (cellSize.width + intercell.width);
|
int approxCol = point.x / (cellSize.width + intercell.width);
|
||||||
float approxColsWidth = approxCol * (cellSize.width + intercell.width);
|
float approxColsWidth = approxCol * (cellSize.width + intercell.width);
|
||||||
|
|
||||||
|
@ -1750,15 +1761,17 @@ fprintf(stderr, " NSMatrix: keyDown --- ");
|
||||||
if (rightRequired && betweenCols)
|
if (rightRequired && betweenCols)
|
||||||
approxCol++;
|
approxCol++;
|
||||||
|
|
||||||
|
if (approxCol < 0)
|
||||||
|
{
|
||||||
|
approxCol = -1;
|
||||||
|
colReady = YES;
|
||||||
|
}
|
||||||
|
else if (approxCol >= numCols)
|
||||||
|
{
|
||||||
|
approxCol = numCols - 1;
|
||||||
|
colReady = YES;
|
||||||
|
}
|
||||||
SET_POINTER_VALUE(column, approxCol);
|
SET_POINTER_VALUE(column, approxCol);
|
||||||
if (*column < 0) {
|
|
||||||
*column = -1;
|
|
||||||
colReady = YES;
|
|
||||||
}
|
|
||||||
else if (*column >= numCols) {
|
|
||||||
*column = numCols - 1;
|
|
||||||
colReady = YES;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If the point is outside the matrix bounds return NO */
|
/* If the point is outside the matrix bounds return NO */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue