blob: eba54615972b773bb115368ffb463b81074e2411 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
/****************************************************************************
**
** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved.
**
** This file is part of an example program for TQt. This example
** program may be used, distributed and modified without limitation.
**
*****************************************************************************/
#include <ntqtooltip.h>
#include <ntqtable.h>
#include "tooltip.h"
HeaderToolTip::HeaderToolTip( TQHeader *header, TQToolTipGroup *group )
: TQToolTip( header, group )
{
}
void HeaderToolTip::maybeTip ( const TQPoint& p )
{
TQHeader *header = (TQHeader*)parentWidget();
int section = 0;
if ( header->orientation() == Horizontal )
section = header->sectionAt( header->offset() + p.x() );
else
section = header->sectionAt( header->offset() + p.y() );
TQString tipString = header->label( section );
tip( header->sectionRect( section ), tipString, "This is a section in a header" );
}
TableToolTip::TableToolTip( TQTable *tipTable, TQToolTipGroup *group )
: TQToolTip( tipTable->viewport(), group ), table( tipTable )
{
}
void TableToolTip::maybeTip ( const TQPoint &p )
{
TQPoint cp = table->viewportToContents( p );
int row = table->rowAt( cp.y() );
int col = table->columnAt( cp.x() );
TQString tipString = table->text( row, col );
TQRect cr = table->cellGeometry( row, col );
cr.moveTopLeft( table->contentsToViewport( cr.topLeft() ) );
tip( cr, tipString, "This is a cell in a table" );
}
|