GUIGLObjectToolTip.cpp
Go to the documentation of this file.00001
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifdef _MSC_VER
00025 #include <windows_config.h>
00026 #else
00027 #include <config.h>
00028 #endif
00029
00030 #include <iostream>
00031 #include <string>
00032 #include "GUIGlObjectStorage.h"
00033 #include "GUIGlObject.h"
00034 #include "GUIGLObjectToolTip.h"
00035
00036 #ifdef CHECK_MEMORY_LEAKS
00037 #include <foreign/nvwa/debug_new.h>
00038 #endif // CHECK_MEMORY_LEAKS
00039
00040
00041
00042
00043
00044 FXDEFMAP(GUIGLObjectToolTip) GUIGLObjectToolTipMap[]={
00045 FXMAPFUNC(SEL_PAINT, 0, GUIGLObjectToolTip::onPaint),
00046 };
00047
00048 FXIMPLEMENT(GUIGLObjectToolTip,FXToolTip,GUIGLObjectToolTipMap,ARRAYNUMBER(GUIGLObjectToolTipMap))
00049
00050
00051
00052
00053
00054 GUIGLObjectToolTip::GUIGLObjectToolTip(FXWindow *a)
00055 : FXToolTip(a->getApp(), TOOLTIP_PERMANENT, 0, 0, 200, 200),
00056 myFont(a->getApp()->getNormalFont()),
00057 myObject(0) {
00058 setBackColor((255)|(204<<8)|(0<<16));
00059 myTextHeight = myFont->getFontHeight();
00060 create();
00061 hide();
00062 }
00063
00064
00065 GUIGLObjectToolTip::~GUIGLObjectToolTip() {}
00066
00067 void
00068 GUIGLObjectToolTip::setObjectTip(GUIGlObject *object,
00069 FXint x, FXint y) {
00070
00071 bool objectChanged = (myObject!=object);
00072
00073 myObject = object;
00074 if (object==0) {
00075
00076 hide();
00077 return;
00078 }
00079
00080 if (objectChanged) {
00081
00082 myObjectName = object->getFullName();
00083 label = myObjectName.c_str();
00084 myWidth = myFont->getTextWidth(myObjectName.c_str(), (FXuint) myObjectName.length())+6;
00085 }
00086 myHeight = myTextHeight+6;
00087 position(x+15, y-20, 1, 1);
00088 position(x+15, y-20, myWidth, myHeight);
00089 if (!shown()) {
00090 show();
00091 } else {
00092 if (objectChanged) {
00093 recalc();
00094 }
00095 update();
00096 }
00097 myLastXPos = x;
00098 myLastYPos = y;
00099 }
00100
00101
00102 long
00103 GUIGLObjectToolTip::onPaint(FXObject*,FXSelector,void*) {
00104 if (myObject==0) {
00105 return 1;
00106 }
00107
00108 FXDCWindow dc(this);
00109 dc.setForeground(backColor);
00110 dc.fillRectangle(1, 1,
00111 myFont->getTextWidth(myObjectName.c_str(), (FXuint) myObjectName.length())+4, myTextHeight+4);
00112 dc.setFont(myFont);
00113 dc.setForeground(0);
00114 dc.drawText(3, myTextHeight,
00115 myObjectName.c_str(), (FXuint) myObject->getFullName().length());
00116 dc.drawRectangle(0, 0, myFont->getTextWidth(myObjectName.c_str(), (FXuint) myObjectName.length())+5, myTextHeight+5);
00117 return 1;
00118 }
00119
00120
00121 FXint
00122 GUIGLObjectToolTip::getDefaultWidth() {
00123 return myWidth;
00124 }
00125
00126
00127 FXint
00128 GUIGLObjectToolTip::getDefaultHeight() {
00129 return myHeight;
00130 }
00131
00132
00133 long
00134 GUIGLObjectToolTip::onTipShow(FXObject*,FXSelector,void*) {
00135 return 1;
00136 }
00137
00138
00139 long
00140 GUIGLObjectToolTip::onTipHide(FXObject*,FXSelector,void*) {
00141 return 1;
00142 }
00143
00144
00145
00146
00147