summaryrefslogtreecommitdiffstats
path: root/khexedit/lib/kbordercolumn.cpp
blob: c5902468ed93a1f66c50446b68b479ae0e2c85ff (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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/***************************************************************************
                          kbordercolumn.cpp  -  description
                             -------------------
    begin                : Mit Mai 21 2003
    copyright            : (C) 2003 by Friedrich W. H. Kossebau
    email                : Friedrich.W.H@Kossebau.de
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This library is free software; you can redistribute it and/or         *
 *   modify it under the terms of the GNU Library General Public           *
 *   License version 2 as published by the Free Software Foundation.       *
 *                                                                         *
 ***************************************************************************/


// qt specific
#include <qpainter.h>
#include <qstyle.h>
// lib specific
#include "kcolumnsview.h"
#include "kbordercolumn.h"


using namespace KHE;

static const KPixelX DefaultWidth = 9;
static const KPixelX LineX = DefaultWidth / 2;


KBorderColumn::KBorderColumn( KColumnsView *V, bool M )
 : KColumn( V ),
   Middle( M )
{
  setWidth( M?DefaultWidth:LineX-1 );
}

KBorderColumn::~KBorderColumn()
{
}


void KBorderColumn::paintLine( QPainter *P )
{
  if( LineHeight > 0 )
  {
    KColumn::paintBlankLine( P );

    if( Middle )
    {
      int GridColor = View->style().styleHint( QStyle::SH_Table_GridLineColor, View );
      P->setPen( GridColor != -1 ? (QRgb)GridColor : View->colorGroup().mid() );
      P->drawLine( LineX, 0, LineX, LineHeight-1 ) ;
    }
  }
}


void KBorderColumn::paintFirstLine( QPainter *P, KPixelXs , int )
{
  paintLine( P );
}


void KBorderColumn::paintNextLine( QPainter *P )
{
  paintLine( P );
}

void KBorderColumn::paintEmptyColumn( QPainter *P, KPixelXs Xs, KPixelYs Ys )
{
  KColumn::paintEmptyColumn( P,Xs,Ys );

  KPixelX LX = x() + LineX;
  if( Middle && Xs.includes(LX) )
  {
    int GridColor = View->style().styleHint( QStyle::SH_Table_GridLineColor, View );
    P->setPen( GridColor != -1 ? (QRgb)GridColor : View->colorGroup().mid() );
    P->drawLine( LX, Ys.start(), LX, Ys.end() ) ;
  }
}