• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • superkaramba
 

superkaramba

  • superkaramba
  • src
clickmap.cpp
1 /***************************************************************************
2  * Copyright (C) 2003 by Ralph M. Churchill *
3  * mrchucho@yahoo.com *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 2 of the License, or *
8  * (at your option) any later version. *
9  ***************************************************************************/
10 
11 #include "clickmap.h"
12 #include <tqregexp.h>
13 #include <krun.h>
14 
15 ClickMap::ClickMap(karamba* k, int x, int y, int w, int h )
16  :Meter(k, x, y, w, h )
17 {
18 /*
19  if( h != 0 || w != 0)
20  clip = 0;
21  else
22  clip = TQt::DontClip;
23 */
24 
25  if( h == 0 || w == 0)
26  {
27  setWidth(-1);
28  setHeight(-1);
29  }
30 }
31 
32 ClickMap::~ClickMap()
33 {
34 }
35 
36 void ClickMap::setTextProps( TextField *t )
37 {
38  text = *t;
39 }
40 
41 bool ClickMap::click( TQMouseEvent *e ) {
42 
43  //Don't load the web page if the click isn't for us
44  if (boundingBox.contains(e->x(), e->y())) {
45 
46  int index = ((e -> y() - getY()) / text.getLineHeight()) + 1;
47  if (index >= 1 && index <= (int)displays.count()) {
48  // tqDebug( "You clicked item " + TQString::number( index ) + ", " +
49  // displays[index - 1] + " " + links[index - 1] );
50  KRun::runCommand("konqueror " + links[index - 1]);
51  }
52  }
53  return false;
54 }
55 
56 void ClickMap::mUpdate( TQPainter *p )
57 {
58  int i = 0; //text.getLineHeight();
59  int row = 1;
60 
61  p->setFont(text.getFont());
62  TQStringList::Iterator it = displays.begin();
63  while( it != displays.end() && (row <= getHeight() || getHeight() == -1 ) )
64  {
65  p->setPen( text.getColor() );
66  // p->drawText(x,y+i,width,height, TQt::AlignCenter | TQt::ExpandTabs, *it);
67  p->drawText(getX(), getY() + i + text.getLineHeight(), *it);
68  i += text.getLineHeight();
69  it++;
70  row++;
71  }
72 }
73 
74 void ClickMap::setValue( TQString v )
75 {
76  TQRegExp rx("^http://", false );
77  if ( rx.search( v ) == -1 )
78  {
79  displays.append( v );
80  }
81  else
82  {
83  links.append( v );
84  }
85 }
86 
87 void ClickMap::setValue( long v )
88 {
89  if ( v == 0 )
90  {
91  links.clear();
92  displays.clear();
93  }
94 }
95 
96 #include "clickmap.moc"
TextField
Ralph M.
Definition: textfield.h:21

superkaramba

Skip menu "superkaramba"
  • Main Page
  • Alphabetical List
  • Class List
  • File List
  • Class Members

superkaramba

Skip menu "superkaramba"
  • kcalc
  •   knumber
  • superkaramba
Generated for superkaramba by doxygen 1.8.13
This website is maintained by Timothy Pearson.