65#define DEF_FRAME_BG_COLOR "#c0c0c0"
66#define DEF_FRAME_CURSOR ""
67#define DEF_BUTTON_FG "black"
68#define DEF_BUTTON_HIGHLIGHT_BG "#d9d9d9"
69#define DEF_BUTTON_HIGHLIGHT "black"
138 for (i = 0; i <
N_COLOR; ++i) {
228 for (i = 0; i <
N_FONT; i++) {
327 if (rc != 0)
return kFALSE;
339 if (iStart.
fP && savePtr) {
459 if (z && strcmp(z,
name) == 0) {
492 return (
const char *)obj->
GetName();
539 int clipwinH, clipwinW;
541 int redoSelection = 0;
546 fFlags &= ~REDRAW_PENDING;
565 fFlags &= ~RESIZE_ELEMENTS;
604 fFlags &= ~REDRAW_PENDING;
627 color = highlightColorPtr;
629 color = highlightBgColorPtr;
631 _DrawFocusHighlight(color);
672 if (w > 0 &&
h > 0) {
719 int top, bottom, left, right;
727 for (pElem = pImage->
fPList; pElem; pElem = pElem->
fINext) {
730 if (imageTop > bottom || imageTop + pElem->
fH < top
731 || pElem->
fX > right || pElem->
fX + pElem->
fW < left)
continue;
781 if (bottom < 0)
return;
783 if (right < 0)
return;
804 int right =
x + w + 1;
805 int bottom =
y +
h + 1;
806 if (bottom < 0)
return;
808 if (right < 0)
return;
883 if (
y < clipHeight) {
899 for (p =
fPFirst; p; p = fPNext) {
913 for (i = 0; i <
N_COLOR; ++i) {
1004 if (pImage->
fTimer == t) {
1046 if (color < 0 || color >=
N_COLOR) color = 0;
1050 if (p->
fIndex == 0)
continue;
1051 if ((font < 0 || p->fFont == font) && p->
fColor == color) {
1151 if (p->
fFrame == 0)
continue;
1152 if (p->
fY < vy + vh && p->
fY + p->
fH > vy &&
1153 p->
fX < vx + vw && p->
fX + p->
fW > vx) {
1154 if ((
x > p->
fX) && (
y > p->
fY) && (
x < (p->
fX + p->
fW)) &&
1155 (
y < (p->
fY + p->
fH)) ) {
1170 eventSt.
fType =
event->fType;
1171 eventSt.
fWindow =
event->fWindow;
1172 eventSt.
fTime =
event->fTime;
1175 eventSt.
fXRoot =
event->fXRoot;
1176 eventSt.
fYRoot =
event->fYRoot;
1177 eventSt.
fCode =
event->fCode;
1178 eventSt.
fState =
event->fState;
1179 eventSt.
fWidth =
event->fWidth;
1180 eventSt.
fHeight =
event->fHeight;
1181 eventSt.
fCount =
event->fCount;
1183 eventSt.
fHandle =
event->fHandle;
1184 eventSt.
fFormat =
event->fFormat;
1185 eventSt.
fUser[0] =
event->fUser[0];
1186 eventSt.
fUser[1] =
event->fUser[1];
1187 eventSt.
fUser[2] =
event->fUser[2];
1188 eventSt.
fUser[3] =
event->fUser[3];
1189 eventSt.
fUser[4] =
event->fUser[4];
1191 event->
fX, event->
fY, eventSt.
fX,
1192 eventSt.
fY, childdum);
1195 const char *val = pr->
MarkupArg(
"value", 0);
1201 b->HandleButton(&eventSt);
1216 if ((!was && now) || (was && !now)) {
1227 if ((!was && now) || (was && !now))
1239 eventSt.
fUser[0] = childdum;
1283 Emit(
"ButtonClicked(char*,char*)", args);
1297 Emit(
"CheckToggled(char*,Bool_t,char*)", args);
1310 Emit(
"RadioChanged(char*,char*)", args);
1323 Emit(
"InputSelected(char*,char*)", args);
1331 Emit(
"SubmitClicked(char*)", val);
1357 sprintf(ix,
"begin");
1412 if (iFont < 0) iFont = 0;
1428 if (
fAFont[iFont] == 0) {
1430 const char *familyStr =
"";
1441 case 0: familyStr =
"times -%d";
break;
1442 case 1: familyStr =
"times -%d bold";
break;
1443 case 2: familyStr =
"times -%d italic";
break;
1444 case 3: familyStr =
"times -%d bold italic";
break;
1445 case 4: familyStr =
"courier -%d";
break;
1446 case 5: familyStr =
"courier -%d bold";
break;
1447 case 6: familyStr =
"courier -%d italic";
break;
1448 case 7: familyStr =
"courier -%d bold italic";
break;
1451 case 0: familyStr =
"helvetica -%d";
break;
1452 case 1: familyStr =
"helvetica -%d bold";
break;
1453 case 2: familyStr =
"helvetica -%d italic";
break;
1454 case 3: familyStr =
"helvetica -%d bold italic";
break;
1455 case 4: familyStr =
"courier -%d";
break;
1456 case 5: familyStr =
"courier -%d bold";
break;
1457 case 6: familyStr =
"courier -%d italic";
break;
1458 case 7: familyStr =
"courier -%d bold italic";
break;
1459 default: familyStr =
"helvetica -14";
CANT_HAPPEN;
1464 case 1: size = 6+finc;
break;
1465 case 2: size = 10+finc;
break;
1466 case 3: size = 12+finc;
break;
1467 case 4: size = 14+finc;
break;
1468 case 5: size = 20+finc;
break;
1469 case 6: size = 24+finc;
break;
1470 case 7: size = 30+finc;
break;
1475 case 1: size = 8;
break;
1476 case 2: size = 10;
break;
1477 case 3: size = 12;
break;
1478 case 4: size = 14;
break;
1479 case 5: size = 16;
break;
1480 case 6: size = 18;
break;
1481 case 7: size = 24;
break;
1486 if (iFamily < 4) size += 2;
1494 if (
fAFont[iFont] == 0) {
1495 fprintf(stderr,
"TGHtml: could not get font \"%s\", trying fixed\n",
1499 if (
fAFont[iFont] == 0 ){
1500 fprintf(stderr,
"TGHtml: could not get font \"fixed\", trying "
1501 "\"helvetica -12\"\n");
1523 return ((left + ip[0]) <=
x && (left + ip[2]) >=
x &&
1524 (top + ip[1]) <=
y && (top + ip[3]) >=
y);
1526 int dx = left + ip[0] -
x;
1527 int dy = top + ip[1] -
y;
1528 return (dx * dx + dy * dy <= ip[2] * ip[2]);
1545 if (zb && *zb !=
'r')
return 0;
1546 if (z && !strcmp(z,
name))
return p;
1564 return x*
x +
y*
y + z*z;
1585 if (
n == 6 ||
n == 3 ||
n == 9 ||
n == 12) {
1586 for (i = 0; i <
n; i++) {
1587 if (!isxdigit(zColor[i]))
break;
1590 snprintf(zAltColor, 15,
"#%s", zColor);
1592 strlcpy(zAltColor, zColor,
sizeof(zAltColor));
1613#define MAX_COLOR 65535
1614#define MAX(A,B) ((A)<(B)?(B):(A))
1615#define MIN(A,B) ((A)<(B)?(A):(B))
1627 z = 0.28 * p->
fBlue;
1637 if (
fIDark[iBgColor] == 0) {
1661 return fIDark[iBgColor] - 1;
1717# define COLOR_MASK 0xf800
1723 for (i = 0; i <
N_COLOR; i++) {
1758 for (i = 1; i <
N_COLOR; i++) {
1760 if (dist < closestDist) {
1790 if (target) *target = pElem->
MarkupArg(
"target", 0);
1800 switch (pElem->
fType) {
1806 if (target) *target = pElem->
MarkupArg(
"target", 0);
1833#define HGCo(dir) (pb2 && pb2->dir) ? pBlock->dir * 100 / pb2->dir : 0
1834 coords[0] =
HGCo(fLeft);
1835 coords[1] =
HGCo(fTop);
1836 coords[3] =
HGCo(fRight);
1837 coords[4] =
HGCo(fBottom);
1839 coords[0] = pBlock->
fLeft;
1840 coords[1] = pBlock->
fTop;
1841 coords[2] = pBlock->
fRight;
1858 if (z && (strcmp(z, value) == 0))
return p;
1875 int needUpdate = forceUpdate;
1951 p->
fFlags &= ~HTML_Selected;
2003 if (!(sBegin.
fP && sEnd.
fP))
return kTRUE;
2005 if (bi < ei || (bi == ei && sBegin.
fI <= sEnd.
fI)) {
2070 <<
");"<< std::endl;
2071 if (option && strstr(option,
"keep_names"))
2072 out <<
" " <<
GetName() <<
"->SetName(\"" <<
GetName() <<
"\");" << std::endl;
2082 out <<
" " <<
"FILE *f = fopen(\"" << fn.
Data() <<
"\", \"r\");" << std::endl;
2083 out <<
" " <<
"if (f) {" << std::endl;
2084 out <<
" " <<
GetName() <<
"->Clear();" << std::endl;
2085 out <<
" " <<
GetName() <<
"->Layout();" << std::endl;
2086 out <<
" " <<
GetName() <<
"->SetBaseUri(\"\");" << std::endl;
2087 out <<
" " <<
"char *buf = (char *)calloc(4096, sizeof(char));" << std::endl;
2088 out <<
" " <<
"while (fgets(buf, 4096, f)) {" << std::endl;
2089 out <<
" " <<
GetName() <<
"->ParseText(buf);" << std::endl;
2090 out <<
" " <<
"}" << std::endl;
2091 out <<
" " <<
"free(buf);" << std::endl;
2092 out <<
" " <<
"fclose(f);" << std::endl;
2093 out <<
" " <<
"}" << std::endl;
2094 out <<
" " <<
GetName() <<
"->Layout();" << std::endl;
const Mask_t kGCForeground
const Mask_t kFocusChangeMask
const Mask_t kButtonPressMask
const Mask_t kExposureMask
Handle_t Pixmap_t
Pixmap handle.
const Mask_t kPointerMotionMask
Handle_t GContext_t
Graphics context handle.
const Mask_t kButtonReleaseMask
const Mask_t kGCGraphicsExposures
Handle_t Window_t
Window handle.
#define INPUT_TYPE_Button
#define DEF_HTML_EXPORT_SEL
#define DEF_HTML_INSERT_OFF_TIME
#define HTML_RELIEF_SUNKEN
#define INPUT_TYPE_Submit
#define HTML_RELIEF_RAISED
#define N_PREDEFINED_COLOR
#define DEF_HTML_INSERT_ON_TIME
#define DEF_HTML_SELECTION_COLOR
#define INPUT_TYPE_Password
#define DEF_HTML_UNVISITED
#define INPUT_TYPE_Checkbox
#define INPUT_TYPE_Select
char * StrDup(const char *str)
Duplicate the string str.
TGFont * GetFont(const char *font, Bool_t fixedDefault=kTRUE)
Get a font from the font pool.
Colormap_t GetDefaultColormap() const
void FreeFont(const TGFont *font)
Free a font.
FontH_t GetFontHandle() const
void AddInput(UInt_t emask)
Add events specified in the emask to the events the frame should handle.
void RemoveInput(UInt_t emask)
Remove events specified in emask from the events the frame should handle.
static Pixel_t GetWhitePixel()
Get white pixel value.
virtual Pixel_t GetBackground() const
void SetTileStipYOrigin(Int_t v)
Y offset for tile or stipple operations.
void SetTileStipXOrigin(Int_t v)
X offset for tile or stipple operations.
virtual const char * MarkupArg(const char *, const char *)
TGHtmlImageMarkup * fINext
TGHtmlImageMarkup * fPList
void Reset()
Reset the layout context.
virtual const char * MarkupArg(const char *tag, const char *zDefault)
Lookup an argument in the given markup with the name given.
int GetLightShadowColor(int iBgColor)
Given that the background color is iBgColor, figure out an appropriate color for the bright part of t...
virtual void SavePrimitive(std::ostream &out, Option_t *="")
Save a html widget as a C++ statement(s) on output stream out.
TGHtmlElement * GetMap(const char *name)
Returns html map element.
int IsDarkColor(ColorStruct_t *p)
Check to see if the given color is too dark to be easily distinguished from black.
void RedrawArea(int left, int top, int right, int bottom)
If any part of the screen needs to be redrawn, then call this routine with the values of a box (in wi...
int GotoAnchor(const char *name)
Go to anchor position.
int SetInsert(const char *insIx)
Set the position of the insertion cursor.
virtual ~TGHtml()
HTML widget destructor.
virtual void RadioChanged(const char *name, const char *val)
Emit RadioChanged() signal.
TGHtmlElement * fLoEndPtr
TGHtmlBlock * fPSelStartBlock
int IsLightColor(ColorStruct_t *p)
Check to see if the given color is too light to be easily distinguished from white.
void TokenizerAppend(const char *text)
Append text to the tokenizer engine.
void AddStyle(TGHtmlElement *p)
This routine adds information to the input texts that doesn't change when the display is resized or w...
virtual void MouseDown(const char *uri)
void ScheduleRedraw()
Make sure that a call to the Redraw() routine has been queued.
void LostSelection()
Clear selection.
const char * GetHref(int x, int y, const char **target=0)
This routine searchs for a hyperlink beneath the coordinates x,y and returns a pointer to the HREF fo...
virtual TGFont * GetFont(int iFont)
The rendering and layout routines should call this routine in order to get a font structure.
void UpdateInsert()
Recompute the position of the insertion cursor based on the position in fIns.
char fFontValid[(N_FONT+7)/8]
TGHtmlElement * fLastSized
void LayoutDoc()
Advance the layout as far as possible.
void BlockDraw(TGHtmlBlock *pBlock, Drawable_t wid, int left, int top, int width, int height, Pixmap_t pixmap)
Display a single HtmlBlock. This is where all the drawing happens.
void IndexToBlockIndex(SHtmlIndex_t sIndex, TGHtmlBlock **ppBlock, int *piIndex)
Convert an Element-based index into a Block-based index.
int GetColorByName(const char *zColor)
This routine returns an index between 0 and N_COLOR-1 which indicates which ColorStruct_t structure i...
void DrawImage(TGHtmlImageMarkup *image, Drawable_t wid, int left, int top, int right, int bottom)
Draw all or part of an image.
TGHtmlInput * fFormElemLast
void AnimateImage(TGHtmlImage *image)
TGImage *img = image->image;.
virtual void InputSelected(const char *name, const char *val)
Emit Selected() signal.
virtual void CheckToggled(const char *name, Bool_t on, const char *val)
Emit CheckToggled() signal.
int SelectionSet(const char *startIx, const char *endIx)
Set selection.
virtual void Clear(Option_t *="")
Erase all HTML from this widget and clear the screen.
void UpdateSelectionDisplay()
The fPSelStartBlock and fPSelEndBlock values have been changed.
TGHtmlBlock * fPSelEndBlock
ColorStruct_t * fSelectionColor
virtual Bool_t HandleFocusChange(Event_t *event)
Handle focus change event.
void FormBlocks()
Add additional blocks to the block list in order to cover all elements on the element list.
virtual void ButtonClicked(const char *name, const char *val)
Emit ButtonClicked() signal.
ColorStruct_t * fHighlightBgColorPtr
void SetRuleRelief(int relief)
Sets relief mode of html rule.
virtual void UpdateBackgroundStart()
Start background update.
SHtmlStyleStack_t * fStyleStack
int ParseText(char *text, const char *index=0)
Appends (or insert at the specified position) the given HTML text to the end of any HTML text that ma...
virtual Bool_t HandleTimer(TTimer *timer)
Handle timer event.
ColorStruct_t * fNewLinkColor
TGHtmlListStart * fInnerList
void RedrawText(int y)
Call this routine to cause all of the rendered HTML at the virtual canvas coordinate of Y and beyond ...
virtual Bool_t HandleButton(Event_t *event)
Handle mouse button event.
virtual void MouseOver(const char *uri)
Bool_t HandleRadioButton(TGHtmlInput *p)
Handle radio button event.
virtual Bool_t HandleMotion(Event_t *event)
handle mouse motion events
TGHtmlInput * GetInputElement(int x, int y)
This routine searchs for a hyperlink beneath the coordinates x,y and returns a pointer to the HREF fo...
void UpdateSelection(int forceUpdate)
Given the selection end-points in fSelBegin and fSelEnd, recompute pSelBeginBlock and fPSelEndBlock,...
void SetBaseUri(const char *uri)
Sets base URI.
void DeleteControls()
Delete all input controls.
ColorStruct_t * AllocColorByValue(ColorStruct_t *color)
Allocate system color by value.
virtual Bool_t HandleIdleEvent(TGIdleHandler *i)
Handles idle event.
TGHtmlInput * fFirstInput
void SetTableRelief(int relief)
Sets relief mode of html table.
ColorStruct_t * AllocColor(const char *name)
Allocate system color by name.
void HClear()
Erase all data from the HTML widget. Bring it back to an empty screen.
ColorStruct_t * fHighlightColorPtr
GContext_t GetAnyGC()
Retrieve any valid GC.
virtual Bool_t ItemLayout()
Layout html widget.
TGHtmlBlock * fFirstBlock
void RedrawBlock(TGHtmlBlock *p)
Redraw the TGHtmlBlock given.
const char * GetUid(const char *string)
Given a string, this procedure returns a unique identifier for the string.
void Redraw()
This routine is invoked in order to redraw all or part of the HTML widget.
int GetLinkColor(const char *zURL)
For the markup <a href=XXX>, find out if the URL has been visited before or not.
TGHtmlAnchor * fAnchorStart
int GetColorByValue(ColorStruct_t *pRef)
Find a color integer for the color whose color components are given by pRef.
GcCache_t fAGcCache[N_CACHE_GC]
SHtmlStyle_t PopStyleStack(int tag)
Pop a rendering style off of the stack.
void FreeColor(ColorStruct_t *color)
Free system color.
void ComputeVirtualSize()
Computes virtual size of html area.
int TokenNumber(TGHtmlElement *p)
Return the token number for the given TGHtmlElement.
TGHtmlElement * AttrElem(const char *name, char *value)
Returns html element matching attribute name and value.
GContext_t GetGC(int color, int font)
Return a GC from the cache.
virtual char * ResolveUri(const char *uri)
This function resolves the specified URI and returns the result in a newly allocated string.
int InArea(TGHtmlMapArea *p, int left, int top, int x, int y)
Only support rect and circles for now.
virtual void DrawRegion(Int_t x, Int_t y, UInt_t w, UInt_t h)
Draw region defined by [x,y] [w,h].
void PushStyleStack(int tag, SHtmlStyle_t style)
Push a new rendering style onto the stack.
TGHtmlElement * fNextPlaced
TGHtmlLayoutContext fLayoutContext
void RedrawEverything()
Call this routine to force the entire widget to be redrawn.
virtual void SubmitClicked(const char *val)
Emit SubmitClicked() signal.
void UnderlineLinks(int onoff)
Set/reset html links underline.
SHtmlStyle_t GetCurrentStyle()
Get the current rendering style.
int MapControls()
Map any control that should be visible according to the current scroll position.
const char * GetText() const
void ClearGcCache()
Clear the cache of GCs.
int GetIndex(const char *zIndex, TGHtmlElement **ppToken, int *pIndex)
This routine decodes a complete index specification.
ColorStruct_t * fOldLinkColor
TGHtmlForm * fLoFormStart
TGHtmlInput * fFormElemStart
ColorStruct_t * fApColor[N_COLOR]
int ElementCoords(TGHtmlElement *p, int i, int pct, int *coords)
Return coordinates of item.
float ColorDistance(ColorStruct_t *pA, ColorStruct_t *pB)
Compute the squared distance between two colors.
void FlashCursor()
Flash the insertion cursor.
int GetDarkShadowColor(int iBgColor)
Given that the background color is iBgColor, figure out an appropriate color for the dark part of a 3...
TGHtml(const TGWindow *p, int w, int h, int id=-1)
HTML Widget constructor.
Bool_t HandleHtmlInput(TGHtmlInput *pr, Event_t *event)
Handle html input (button, checkbox, ...) event.
SHtmlExtensions_t * fExts
void ResetLayoutContext()
Reset the main layout context in the main widget.
virtual void SetFocus()
Set focus to this text entry.
Bool_t Save(const char *fn)
Save text buffer to file fn.
virtual Bool_t HandleButton(Event_t *event)
handle button
virtual void SetBackgroundColor(Pixel_t)
Set background color of the canvas frame.
TGLongPosition fScrollVal
virtual void DrawRegion(Int_t x, Int_t y, UInt_t width, UInt_t height)
Draw region.
virtual void ScrollToPosition(TGLongPosition newPos)
Scroll the canvas to pos.
virtual void Clear(Option_t *="")
Clear view.
virtual void SetBackgroundPixmap(Pixmap_t p)
Set backgound pixmap.
virtual const char * GetName() const
Return unique name, used in SavePrimitive methods.
THashTable implements a hash table to store TObject's.
void Add(TObject *obj)
Add object to the hash table.
TObject * FindObject(const char *name) const
Find object using its name.
Collectable string class.
const char * GetName() const
Returns name of object.
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
void Emit(const char *signal, const T &arg)
Activate signal with single parameter.
const char * Data() const
void Form(const char *fmt,...)
Formats a string using a printf style format descriptor.
Handles synchronous and a-synchronous timer events.
Short_t Max(Short_t a, Short_t b)
ULong_t fPixel
color pixel value (index in color table)
UShort_t fRed
red component (0..65535)
UShort_t fGreen
green component (0..65535)
UShort_t fBlue
blue component (0..65535)
UShort_t fMask
mask telling which color components are valid
EGEventType fType
of event (see EGEventType)
Int_t fY
pointer x, y coordinates in event window
Bool_t fSendEvent
true if event came from SendEvent
Handle_t fHandle
general resource handle (used for atoms or windows)
Int_t fFormat
Next fields only used by kClientMessageEvent.
UInt_t fHeight
width and height of exposed area
Int_t fCount
if non-zero, at least this many more exposes
Window_t fWindow
window reported event is relative to
UInt_t fState
key or button mask
Int_t fYRoot
coordinates relative to root
Long_t fUser[5]
5 longs can be used by client message events NOTE: only [0], [1] and [2] may be used.
Time_t fTime
time event event occurred in ms
UInt_t fCode
key or button code
Graphics context structure.
Mask_t fMask
bit mask specifying which fields are valid
Bool_t fGraphicsExposures
boolean, should exposures be generated
ULong_t fForeground
foreground pixel
FontH_t fFont
default text font for text operations
SHtmlStyleStack_t * fPNext