63 #define DEF_FRAME_BG_COLOR "#c0c0c0" 64 #define DEF_FRAME_CURSOR "" 65 #define DEF_BUTTON_FG "black" 66 #define DEF_BUTTON_HIGHLIGHT_BG "#d9d9d9" 67 #define DEF_BUTTON_HIGHLIGHT "black" 136 for (i = 0; i <
N_COLOR; ++i) {
226 for (i = 0; i <
N_FONT; i++) {
325 if (rc != 0)
return kFALSE;
337 if (iStart.
fP && savePtr) {
457 if (z && strcmp(z, name) == 0) {
490 return (
const char *)obj->
GetName();
537 int clipwinH, clipwinW;
539 int redoSelection = 0;
563 fFlags &= ~RESIZE_ELEMENTS;
578 && (
fFlags & STYLER_RUNNING) == 0) {
625 color = highlightColorPtr;
627 color = highlightBgColorPtr;
629 _DrawFocusHighlight(color);
638 if (
fFlags & STYLER_RUNNING) {
670 if (w > 0 && h > 0) {
698 if (pBlock->
fTop <= y+h && pBlock->
fBottom >= y-10 &&
700 BlockDraw(pBlock, pixmap, x, y, w, h, pixmap);
717 int top, bottom, left, right;
725 for (pElem = pImage->
fPList; pElem; pElem = pElem->
fINext) {
728 if (imageTop > bottom || imageTop + pElem->
fH < top
729 || pElem->
fX > right || pElem->
fX + pElem->
fW < left)
continue;
779 if (bottom < 0)
return;
781 if (right < 0)
return;
802 int right = x + w + 1;
803 int bottom = y + h + 1;
804 if (bottom < 0)
return;
806 if (right < 0)
return;
881 if (y < clipHeight) {
897 for (p =
fPFirst; p; p = fPNext) {
911 for (i = 0; i <
N_COLOR; ++i) {
973 #if 0 // in OXView::Clear() 1002 if (pImage->
fTimer == t) {
1044 if (color < 0 || color >=
N_COLOR) color = 0;
1048 if (p->
fIndex == 0)
continue;
1049 if ((font < 0 || p->fFont == font) && p->
fColor == color) {
1068 if (i >= N_CACHE_GC) {
1070 for (i = 0; i < N_CACHE_GC && i <
fGcNextToFree; ++i, ++p) {}
1071 fGcNextToFree = (fGcNextToFree + 1) % N_CACHE_GC;
1149 if (p->
fFrame == 0)
continue;
1150 if (p->
fY < vy + vh && p->
fY + p->
fH > vy &&
1151 p->
fX < vx + vw && p->
fX + p->
fW > vx) {
1152 if ((x > p->
fX) && (y > p->
fY) && (x < (p->
fX + p->
fW)) &&
1153 (y < (p->
fY + p->
fH)) ) {
1168 eventSt.
fType =
event->fType;
1169 eventSt.
fWindow =
event->fWindow;
1170 eventSt.
fTime =
event->fTime;
1173 eventSt.
fXRoot =
event->fXRoot;
1174 eventSt.
fYRoot =
event->fYRoot;
1175 eventSt.
fCode =
event->fCode;
1176 eventSt.
fState =
event->fState;
1177 eventSt.
fWidth =
event->fWidth;
1178 eventSt.
fHeight =
event->fHeight;
1179 eventSt.
fCount =
event->fCount;
1181 eventSt.
fHandle =
event->fHandle;
1182 eventSt.
fFormat =
event->fFormat;
1183 eventSt.
fUser[0] =
event->fUser[0];
1184 eventSt.
fUser[1] =
event->fUser[1];
1185 eventSt.
fUser[2] =
event->fUser[2];
1186 eventSt.
fUser[3] =
event->fUser[3];
1187 eventSt.
fUser[4] =
event->fUser[4];
1189 event->fX,
event->fY, eventSt.
fX,
1190 eventSt.
fY, childdum);
1193 const char *val = pr->
MarkupArg(
"value", 0);
1214 if ((!was && now) || (was && !now)) {
1225 if ((!was && now) || (was && !now))
1237 eventSt.
fUser[0] = childdum;
1281 Emit(
"ButtonClicked(char*,char*)", args);
1295 Emit(
"CheckToggled(char*,Bool_t,char*)", args);
1308 Emit(
"RadioChanged(char*,char*)", args);
1321 Emit(
"InputSelected(char*,char*)", args);
1329 Emit(
"SubmitClicked(char*)", val);
1351 const char *uri =
GetHref(x, y);
1353 #if 0 // insertion cursor test 1355 sprintf(ix,
"begin");
1383 const char *uri =
GetHref(x, y);
1410 if (iFont < 0) iFont = 0;
1426 if (
fAFont[iFont] == 0) {
1428 const char *familyStr =
"";
1439 case 0: familyStr =
"times -%d";
break;
1440 case 1: familyStr =
"times -%d bold";
break;
1441 case 2: familyStr =
"times -%d italic";
break;
1442 case 3: familyStr =
"times -%d bold italic";
break;
1443 case 4: familyStr =
"courier -%d";
break;
1444 case 5: familyStr =
"courier -%d bold";
break;
1445 case 6: familyStr =
"courier -%d italic";
break;
1446 case 7: familyStr =
"courier -%d bold italic";
break;
1449 case 0: familyStr =
"helvetica -%d";
break;
1450 case 1: familyStr =
"helvetica -%d bold";
break;
1451 case 2: familyStr =
"helvetica -%d italic";
break;
1452 case 3: familyStr =
"helvetica -%d bold italic";
break;
1453 case 4: familyStr =
"courier -%d";
break;
1454 case 5: familyStr =
"courier -%d bold";
break;
1455 case 6: familyStr =
"courier -%d italic";
break;
1456 case 7: familyStr =
"courier -%d bold italic";
break;
1457 default: familyStr =
"helvetica -14";
CANT_HAPPEN;
1462 case 1: size = 6+finc;
break;
1463 case 2: size = 10+finc;
break;
1464 case 3: size = 12+finc;
break;
1465 case 4: size = 14+finc;
break;
1466 case 5: size = 20+finc;
break;
1467 case 6: size = 24+finc;
break;
1468 case 7: size = 30+finc;
break;
1473 case 1: size = 8;
break;
1474 case 2: size = 10;
break;
1475 case 3: size = 12;
break;
1476 case 4: size = 14;
break;
1477 case 5: size = 16;
break;
1478 case 6: size = 18;
break;
1479 case 7: size = 24;
break;
1484 if (iFamily < 4) size += 2;
1487 snprintf(name, 199, familyStr, size);
1492 if (
fAFont[iFont] == 0) {
1493 fprintf(stderr,
"TGHtml: could not get font \"%s\", trying fixed\n",
1497 if (
fAFont[iFont] == 0 ){
1498 fprintf(stderr,
"TGHtml: could not get font \"fixed\", trying " 1499 "\"helvetica -12\"\n");
1521 return ((left + ip[0]) <= x && (left + ip[2]) >= x &&
1522 (top + ip[1]) <= y && (top + ip[3]) >= y);
1524 int dx = left + ip[0] -
x;
1525 int dy = top + ip[1] -
y;
1526 return (dx * dx + dy * dy <= ip[2] * ip[2]);
1543 if (zb && *zb !=
'r')
return 0;
1544 if (z && !strcmp(z, name))
return p;
1562 return x*x + y*y + z*
z;
1583 if (n == 6 || n == 3 || n == 9 || n == 12) {
1584 for (i = 0; i <
n; i++) {
1585 if (!isxdigit(zColor[i]))
break;
1588 snprintf(zAltColor, 15,
"#%s", zColor);
1590 strlcpy(zAltColor, zColor,
sizeof(zAltColor));
1592 name =
GetUid(zAltColor);
1611 #define MAX_COLOR 65535 1612 #define MAX(A,B) ((A)<(B)?(B):(A)) 1613 #define MIN(A,B) ((A)<(B)?(A):(B)) 1625 z = 0.28 * p->
fBlue;
1635 if (
fIDark[iBgColor] == 0) {
1652 val.
fRed = (
unsigned short) (pRef->
fRed * 0.6);
1654 val.
fBlue = (
unsigned short) (pRef->
fBlue * 0.6);
1659 return fIDark[iBgColor] - 1;
1683 val.
fRed = (
unsigned short) (pRef->
fRed * 0.9);
1685 val.
fBlue = (
unsigned short) (pRef->
fBlue * 0.9);
1715 # define COLOR_MASK 0xf800 1721 for (i = 0; i <
N_COLOR; i++) {
1756 for (i = 1; i <
N_COLOR; i++) {
1758 if (dist < closestDist) {
1779 pBlock->
fLeft > x || pBlock->
fRight < x)
continue;
1788 if (target) *target = pElem->
MarkupArg(
"target", 0);
1798 switch (pElem->
fType) {
1804 if (target) *target = pElem->
MarkupArg(
"target", 0);
1831 #define HGCo(dir) (pb2 && pb2->dir) ? pBlock->dir * 100 / pb2->dir : 0 1832 coords[0] =
HGCo(fLeft);
1833 coords[1] =
HGCo(fTop);
1834 coords[3] =
HGCo(fRight);
1835 coords[4] =
HGCo(fBottom);
1837 coords[0] = pBlock->
fLeft;
1838 coords[1] = pBlock->
fTop;
1839 coords[2] = pBlock->
fRight;
1856 if (z && (strcmp(z, value) == 0))
return p;
1873 int needUpdate = forceUpdate;
2001 if (!(sBegin.
fP && sEnd.
fP))
return kTRUE;
2003 if (bi < ei || (bi == ei && sBegin.
fI <= sEnd.
fI)) {
2068 <<
");"<< std::endl;
2069 if (option && strstr(option,
"keep_names"))
2070 out <<
" " <<
GetName() <<
"->SetName(\"" <<
GetName() <<
"\");" << std::endl;
2080 out <<
" " <<
"FILE *f = fopen(\"" << fn.
Data() <<
"\", \"r\");" << std::endl;
2081 out <<
" " <<
"if (f) {" << std::endl;
2082 out <<
" " <<
GetName() <<
"->Clear();" << std::endl;
2083 out <<
" " <<
GetName() <<
"->Layout();" << std::endl;
2084 out <<
" " <<
GetName() <<
"->SetBaseUri(\"\");" << std::endl;
2085 out <<
" " <<
"char *buf = (char *)calloc(4096, sizeof(char));" << std::endl;
2086 out <<
" " <<
"while (fgets(buf, 4096, f)) {" << std::endl;
2087 out <<
" " <<
GetName() <<
"->ParseText(buf);" << std::endl;
2088 out <<
" " <<
"}" << std::endl;
2089 out <<
" " <<
"free(buf);" << std::endl;
2090 out <<
" " <<
"fclose(f);" << std::endl;
2091 out <<
" " <<
"}" << std::endl;
2092 out <<
" " <<
GetName() <<
"->Layout();" << std::endl;
TGHtmlBlock * fPSelStartBlock
#define DEF_HTML_SELECTION_COLOR
virtual void InputSelected(const char *name, const char *val)
Emit Selected() signal.
double dist(Rotation3D const &r1, Rotation3D const &r2)
void UpdateInsert()
Recompute the position of the insertion cursor based on the position in fIns.
void TokenizerAppend(const char *text)
Append text to the tokenizer engine.
void SetTileStipYOrigin(Int_t v)
Y offset for tile or stipple operations.
void RedrawBlock(TGHtmlBlock *p)
Redraw the TGHtmlBlock given.
TGHtmlElement * fLoEndPtr
SHtmlStyleStack_t * fStyleStack
virtual void SavePrimitive(std::ostream &out, Option_t *="")
Save a html widget as a C++ statement(s) on output stream out.
TGHtmlImageMarkup * fINext
int GotoAnchor(const char *name)
Go to anchor position.
TGHtmlElement * AttrElem(const char *name, char *value)
Returns html element matching attribute name and value.
TGHtmlElement * fNextPlaced
virtual void DrawRegion(Int_t x, Int_t y, UInt_t w, UInt_t h)
Draw region defined by [x,y] [w,h].
#define INPUT_TYPE_Checkbox
Collectable string class.
void AddInput(UInt_t emask)
Add events specified in the emask to the events the frame should handle.
TGHtmlBlock * fPSelEndBlock
void UpdateSelectionDisplay()
The fPSelStartBlock and fPSelEndBlock values have been changed.
virtual void DrawRegion(Int_t x, Int_t y, UInt_t width, UInt_t height)
Draw region.
void ResetLayoutContext()
Reset the main layout context in the main widget.
virtual void Clear(Option_t *="")
Erase all HTML from this widget and clear the screen.
static Pixel_t GetWhitePixel()
Get white pixel value.
virtual void SubmitClicked(const char *val)
Emit SubmitClicked() signal.
TGHtmlBlock * fFirstBlock
void LostSelection()
Clear selection.
void DeleteControls()
Delete all input controls.
virtual Bool_t HandleButton(Event_t *event)
handle button
virtual TGFont * GetFont(int iFont)
The rendering and layout routines should call this routine in order to get a font structure...
virtual void MouseDown(const char *uri)
Bool_t HandleRadioButton(TGHtmlInput *p)
Handle radio button event.
char fFontValid[(N_FONT+7)/8]
void ScheduleRedraw()
Make sure that a call to the Redraw() routine has been queued.
void UnderlineLinks(int onoff)
Set/reset html links underline.
void RedrawEverything()
Call this routine to force the entire widget to be redrawn.
GcCache_t fAGcCache[N_CACHE_GC]
int SelectionSet(const char *startIx, const char *endIx)
Set selection.
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
TGHtmlAnchor * fAnchorStart
#define INPUT_TYPE_Button
const Mask_t kPointerMotionMask
virtual Bool_t HandleFocusChange(Event_t *event)
Handle focus change event.
virtual ~TGHtml()
HTML widget destructor.
THashTable implements a hash table to store TObject's.
void PushStyleStack(int tag, SHtmlStyle_t style)
Push a new rendering style onto the stack.
virtual const char * MarkupArg(const char *, const char *)
ColorStruct_t * AllocColor(const char *name)
Allocate system color by name.
void UpdateSelection(int forceUpdate)
Given the selection end-points in fSelBegin and fSelEnd, recompute pSelBeginBlock and fPSelEndBlock...
const char * GetUid(const char *string)
Given a string, this procedure returns a unique identifier for the string.
int MapControls()
Map any control that should be visible according to the current scroll position.
void LayoutDoc()
Advance the layout as far as possible.
ColorStruct_t * fSelectionColor
static double p2(double t, double a, double b, double c)
ColorStruct_t * AllocColorByValue(ColorStruct_t *color)
Allocate system color by value.
virtual void SetFocus()
Set focus to this text entry.
TGHtml(const TGWindow *p, int w, int h, int id=-1)
HTML Widget constructor.
GContext_t GetAnyGC()
Retrieve any valid GC.
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...
virtual void ButtonClicked(const char *name, const char *val)
Emit ButtonClicked() signal.
const Mask_t kGCGraphicsExposures
virtual Bool_t HandleMotion(Event_t *event)
handle mouse motion events
TGHtmlListStart * fInnerList
ColorStruct_t * fApColor[N_COLOR]
TGHtmlInput * fFirstInput
void IndexToBlockIndex(SHtmlIndex_t sIndex, TGHtmlBlock **ppBlock, int *piIndex)
Convert an Element-based index into a Block-based index.
SHtmlStyle_t PopStyleStack(int tag)
Pop a rendering style off of the stack.
void DrawImage(TGHtmlImageMarkup *image, Drawable_t wid, int left, int top, int right, int bottom)
Draw all or part of an image.
void HClear()
Erase all data from the HTML widget. Bring it back to an empty screen.
virtual char * ResolveUri(const char *uri)
This function resolves the specified URI and returns the result in a newly allocated string...
#define INPUT_TYPE_Select
TGHtmlForm * fLoFormStart
void SetTableRelief(int relief)
Sets relief mode of html table.
const char * GetName() const
Returns name of object.
const Mask_t kButtonPressMask
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.
int GetIndex(const char *zIndex, TGHtmlElement **ppToken, int *pIndex)
This routine decodes a complete index specification.
Bool_t fGraphicsExposures
void RedrawText(int y)
Call this routine to cause all of the rendered HTML at the virtual canvas coordinate of Y and beyond ...
void SetTileStipXOrigin(Int_t v)
X offset for tile or stipple operations.
ColorStruct_t * fNewLinkColor
void AddStyle(TGHtmlElement *p)
This routine adds information to the input texts that doesn't change when the display is resized or w...
void FreeFont(const TGFont *font)
Free a font.
#define HTML_RELIEF_SUNKEN
TGHtmlInput * fFormElemLast
#define DEF_HTML_UNVISITED
void RemoveInput(UInt_t emask)
Remove events specified in emask from the events the frame should handle.
virtual Bool_t HandleIdleEvent(TGIdleHandler *i)
Handles idle event.
int GetDarkShadowColor(int iBgColor)
Given that the background color is iBgColor, figure out an appropriate color for the dark part of a 3...
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
virtual const char * GetName() const
Return unique name, used in SavePrimitive methods.
const Mask_t kExposureMask
void Redraw()
This routine is invoked in order to redraw all or part of the HTML widget.
virtual void CheckToggled(const char *name, Bool_t on, const char *val)
Emit CheckToggled() signal.
int GetColorByValue(ColorStruct_t *pRef)
Find a color integer for the color whose color components are given by pRef.
void Form(const char *fmt,...)
Formats a string using a printf style format descriptor.
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...
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...
void AnimateImage(TGHtmlImage *image)
TGImage *img = image->image;.
virtual void MouseOver(const char *uri)
Handles synchronous and a-synchronous timer events.
virtual Bool_t HandleTimer(TTimer *timer)
Handle timer event.
virtual Pixel_t GetBackground() const
int IsDarkColor(ColorStruct_t *p)
Check to see if the given color is too dark to be easily distinguished from black.
#define N_PREDEFINED_COLOR
Bool_t Save(const char *fn)
Save text buffer to file fn.
virtual void SetBackgroundColor(Pixel_t)
Set background color of the canvas frame.
char * StrDup(const char *str)
Duplicate the string str.
int InArea(TGHtmlMapArea *p, int left, int top, int x, int y)
Only support rect and circles for now.
Bool_t HandleHtmlInput(TGHtmlInput *pr, Event_t *event)
Handle html input (button, checkbox, ...) event.
virtual void RadioChanged(const char *name, const char *val)
Emit RadioChanged() signal.
TGLongPosition fScrollVal
int SetInsert(const char *insIx)
Set the position of the insertion cursor.
TObject * FindObject(const char *name) const
Find object using its name.
SHtmlStyle_t GetCurrentStyle()
Get the current rendering style.
virtual void UpdateBackgroundStart()
Start background update.
virtual void SetBackgroundPixmap(Pixmap_t p)
Set backgound pixmap.
const char * GetText() const
GContext_t GetGC(int color, int font)
Return a GC from the cache.
ColorStruct_t * fHighlightColorPtr
int ElementCoords(TGHtmlElement *p, int i, int pct, int *coords)
Return coordinates of item.
SHtmlStyleStack_t * fPNext
const Mask_t kButtonReleaseMask
#define DEF_HTML_EXPORT_SEL
void Add(TObject *obj)
Add object to the hash table.
#define DEF_HTML_INSERT_ON_TIME
const Mask_t kGCForeground
int GetLightShadowColor(int iBgColor)
Given that the background color is iBgColor, figure out an appropriate color for the bright part of t...
virtual void ScrollToPosition(TGLongPosition newPos)
Scroll the canvas to pos.
you should not use this method at all Int_t Int_t z
#define HTML_RELIEF_RAISED
Colormap_t GetDefaultColormap() const
TGHtmlInput * fFormElemStart
int TokenNumber(TGHtmlElement *p)
Return the token number for the given TGHtmlElement.
#define INPUT_TYPE_Submit
float ColorDistance(ColorStruct_t *pA, ColorStruct_t *pB)
Compute the squared distance between two colors.
void SetRuleRelief(int relief)
Sets relief mode of html rule.
int IsLightColor(ColorStruct_t *p)
Check to see if the given color is too light to be easily distinguished from white.
Short_t Max(Short_t a, Short_t b)
SHtmlExtensions_t * fExts
const Mask_t kFocusChangeMask
int GetLinkColor(const char *zURL)
For the markup , find out if the URL has been visited before or not.
you should not use this method at all Int_t Int_t Double_t Double_t Double_t Int_t Double_t Double_t Double_t Double_t b
TGHtmlElement * fLastSized
void SetBaseUri(const char *uri)
Sets base URI.
int GetColorByName(const char *zColor)
This routine returns an index between 0 and N_COLOR-1 which indicates which ColorStruct_t structure i...
void FormBlocks()
Add additional blocks to the block list in order to cover all elements on the element list...
TGHtmlElement * GetMap(const char *name)
Returns html map element.
void Emit(const char *signal, const T &arg)
Activate signal with single parameter.
virtual Bool_t HandleButton(Event_t *event)
Handle mouse button event.
virtual void Clear(Option_t *="")
Clear view.
ColorStruct_t * fOldLinkColor
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 const char * MarkupArg(const char *tag, const char *zDefault)
Lookup an argument in the given markup with the name given.
#define DEF_HTML_INSERT_OFF_TIME
void ClearGcCache()
Clear the cache of GCs.
void FlashCursor()
Flash the insertion cursor.
TGHtmlImageMarkup * fPList
void ComputeVirtualSize()
Computes virtual size of html area.
ColorStruct_t * fHighlightBgColorPtr
void FreeColor(ColorStruct_t *color)
Free system color.
TGHtmlLayoutContext fLayoutContext
TGFont * GetFont(const char *font, Bool_t fixedDefault=kTRUE)
Get a font from the font pool.
void Reset()
Reset the layout context.
#define INPUT_TYPE_Password
const char * Data() const
FontH_t GetFontHandle() const
virtual Bool_t ItemLayout()
Layout html widget.
static constexpr double g