'+
66 | '
'+
67 | '
%s - %s
'+
68 | '
'+
69 | '
'+
70 | ' %s
'+
71 | '
',
72 | [t, from, time, t, time, ava, msg]);
73 | AppendHtmlElement(root, html);
74 | end;
75 |
76 | function TForm1.OnBehaviorDraw(he: HtmlElement; params: pBehaviorDrawParams): Boolean;
77 | var
78 | cnv: TCanvas;
79 | begin
80 | Result := False;
81 | if he <> area1 then Exit;
82 |
83 | cnv := TCanvas.Create;
84 |
85 | cnv.Handle := params^.dc;
86 | cnv.Brush.Color := RGB(Random(255),Random(255),Random(255));
87 | cnv.FillRect(params^.area);
88 |
89 | cnv.TextOut(params^.area.Left + Random(10), params^.area.Top + Random(10) + 20, 'Some text!');
90 |
91 | cnv.Free;
92 |
93 | Result := True;
94 | end;
95 |
96 | function TForm1.OnBehaviorEvent(he: HtmlElement; params: pBehaviorEventParams): Boolean;
97 | begin
98 | if (he = btn1) and (params^.Cmd = BUTTON_CLICK) then
99 | MessageBox(0, 'event!', nil, 0);
100 | Result := False;
101 | end;
102 |
103 | procedure TForm1.OnHtmlDocumentComplete(Sender: THtmlControl);
104 | var
105 | root: HtmlELement;
106 | i: integer;
107 | begin
108 | root := sender.GetRootElement();
109 | root := root.FindFirst('#chat');
110 |
111 | AppendHtmlElement(root, '
');
112 | btn1 := root.FindFirst('#du1');
113 | btn1.SetBehaviorHandler(self);
114 |
115 | AppendHtmlElement(root,'
');
116 | area1 := root.FindFirst('#du2');
117 | area1.SetBehaviorHandler(self);
118 |
119 | for i := 1 to 100 do
120 | AddMessage(root, 'username', WideFormat('ava%d.jpg', [Random(5)+1]), '12:12', IntToStr(i) + ', Ho-ho-hoooly shit!', Random(2) = 1);
121 | end;
122 |
123 | function TForm1.OnHtmlLoadData(Sender: THtmlControl; Uri: PWideChar; element: HtmlElement): LRESULT;
124 | var
125 | s: TStream;
126 | filename: WideString;
127 | buf: Pointer;
128 | size: DWORD;
129 | i: Integer;
130 | begin
131 | Result := LOAD_OK;
132 | if Pos('skin://', Uri) <> 1 then
133 | Exit;
134 | I := Length(Uri);
135 | if( Uri[I-1] = '/' ) then
136 | filename := Copy(Uri, 8, I-1-7)
137 | else
138 | filename := Uri+7;
139 | try
140 | s := TFileStream.Create(filename, fmOpenRead);
141 | except
142 | Result := LOAD_DISCARD;
143 | Exit;
144 | end;
145 | buf := nil;
146 | try
147 | size := s.Size;
148 | GetMem(buf, size);
149 | s.Read(buf^, size);
150 | s.Free;
151 | Sender.OnDataReady(Uri, buf, size);
152 | FreeMem(buf);
153 | Result := LOAD_DISCARD;
154 | except
155 | end;
156 | end;
157 |
158 | end.
159 |
--------------------------------------------------------------------------------
/index.htm:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/readme:
--------------------------------------------------------------------------------
1 |
2 | Delphi binding for HTMLayout
3 | ============================
4 |
5 | Simple wrappers made for demonstration of piece of HTMLayout to antiquated Delphi developers.
6 |
7 | Implemented a tiny piece of DOM-manipulation methods and behavior event handling.
8 |
--------------------------------------------------------------------------------
/style/conv.css:
--------------------------------------------------------------------------------
1 | /* This Source Code Form is subject to the terms of the Mozilla Public
2 | * License, v. 2.0. If a copy of the MPL was not distributed with this
3 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4 |
5 | .ib-msg-txt {
6 | white-space: pre-wrap;
7 | word-wrap: break-word;
8 | }
9 |
10 | .ib-img-smile {
11 | vertical-align: text-bottom;
12 | }
13 |
14 | *:-moz-any-link .ib-img-smile {
15 | border: none;
16 | border-bottom: solid 1px;
17 | margin-bottom: 1px;
18 | }
19 |
20 | .moz-txt-underscore {
21 | text-decoration: underline;
22 | }
23 |
24 | /* disable overflow in themes until bug 42676 is fixed in Mozilla */
25 | #Chat {
26 | overflow: hidden !important;
27 | }
28 |
29 | #Chat * {
30 | overflow: visible !important;
31 | }
32 |
33 | #unread-ruler {
34 | margin: 0;
35 | width: 100%;
36 | border: none;
37 | border-top: 1px dashed red;
38 | }
39 |
40 | .ib-nick {
41 | font-weight: bold;
42 | }
43 |
44 | .ib-nick[left] {
45 | color: grey;
46 | }
47 |
--------------------------------------------------------------------------------
/style/main.css:
--------------------------------------------------------------------------------
1 | /* This Source Code Form is subject to the terms of the Mozilla Public
2 | * License, v. 2.0. If a copy of the MPL was not distributed with this
3 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4 |
5 | body {
6 | margin: 0;
7 | padding: 0;
8 | background: -moz-linear-gradient(top, -moz-dialog, -moz-default-background-color) fixed;
9 | behavior: htmlarea;
10 | }
11 |
12 | p {
13 | font-family: sans-serif;
14 | margin: 0;
15 | padding: 0;
16 | }
17 |
18 | div.bubble {
19 | margin: 20px 20px 3px 20px;
20 | padding: 0;
21 | border-width: 2px;
22 | border-style: solid;
23 | border-radius: 10px;
24 | box-shadow: rgba(0, 0, 0, 0.3) 1px 1px 3px;
25 | }
26 |
27 | div.bubble:not(.context):not(.event) {
28 | -moz-animation-duration: 0.5s;
29 | -moz-animation-name: fadein;
30 | -moz-animation-iteration-count: 1;
31 | }
32 |
33 | @-moz-keyframes fadein {
34 | from {
35 | opacity: 0;
36 | }
37 |
38 | to {
39 | opacity: 1.0;
40 | }
41 | }
42 | /*
43 | div.bubble.context:not(:hover) {
44 | filter: url("bubbles.svg#desaturate");
45 | }
46 | */
47 |
48 | div.bubble>div.indicator {
49 | margin: 0;
50 | padding: 9px 15px 10px 15px;
51 | }
52 |
53 | div.bubble.event {
54 | padding: 4px 15px 4px 15px;
55 | background-color: hsl(0, 0%, 99%);
56 | border-color: hsl(0, 0%, 85%);
57 | box-shadow: rgba(0, 0, 0, 0.1) 1px 1px 3px;
58 | }
59 |
60 | div.bubble p.pseudo {
61 | font-size: smaller;
62 | font-weight: bold;
63 | margin: -9px 0px 3px -15px;
64 | }
65 |
66 | div.bubble p.pseudo>span {
67 | padding: 0px 15px 1px 15px;
68 | /* border-top-left-radius = (border-radius - border-width) of div.bubble,
69 | see bug 1775 for an explanation */
70 | border-top-left-radius: 8px;
71 | border-bottom-right-radius: 10px;
72 | }
73 | /*
74 | div.bubble p.pseudo>span>span.time {
75 | display: none;
76 | }
77 |
78 | div.bubble:hover p.pseudo>span>span.time {
79 | display: inline;
80 | }
81 | */
82 | div.bubble hr {
83 | margin: 3px 0px 1px 0px;
84 | height: 2px;
85 | border-style: none;
86 | border-top: 1px solid rgba(0, 0, 0, 0.07);
87 | border-bottom: 1px solid rgba(255, 255, 255, 0.5);
88 | }
89 |
90 | p.interval {
91 | text-align: center;
92 | color: hsl(0, 0%, 60%);
93 | }
94 |
95 | #lastMessage {
96 | line-height: 20px;
97 | text-align: center;
98 | color: hsl(0, 0%, 60%);
99 | }
100 |
101 | p.nick {
102 | font-weight: bold;
103 | }
104 |
105 | p.action {
106 | font-style: italic;
107 | }
108 |
109 | p.action:before {
110 | content: "*** ";
111 | }
112 |
113 | p.event {
114 | color: hsl(0, 0%, 60%);
115 | }
116 | /*
117 | p.event *:-moz-any-link:not(:hover) {
118 | color: hsl(0, 0%, 60%);
119 | text-decoration: none;
120 | }
121 |
122 | p.event *:-moz-any-link:hover {
123 | color: hsl(0, 0%, 25%);
124 | }
125 | */
126 |
127 | #Chat {
128 | white-space: normal;
129 | }
130 |
131 | p *:-moz-any-link img {
132 | margin-bottom: 1px;
133 | border-bottom: solid 1px;
134 | }
135 |
136 | #unread-ruler {
137 | border-top: 1px solid rgba(0, 0, 0, 0.16) !important;
138 | border-bottom: 1px solid rgb(255,255,255) !important;
139 | }
140 |
141 |
142 | /* used by javascript */
143 | p.button {
144 | cursor: pointer;
145 | min-height: 20px;
146 | margin-left: -24px;
147 | margin-bottom: -3px;
148 | padding-left: 24px;
149 | }
150 | /*
151 | p.hide {
152 | background: url('Bitmaps/plus.png') no-repeat left top;
153 | }
154 |
155 | p.hide:hover {
156 | background: url('Bitmaps/plus-hover.png') no-repeat left top;
157 | }
158 |
159 | p.hide:after {
160 | content: "...";
161 | color: hsl(0, 0%, 60%);
162 | }
163 |
164 | p.show {
165 | background: url('Bitmaps/minus.png') no-repeat left top;
166 | margin-bottom: -20px;
167 | width: 0;
168 | }
169 |
170 | p.show:hover {
171 | background: url('Bitmaps/minus-hover.png') no-repeat left top;
172 | }
173 | */
174 | .ib-nick {
175 | font-size: smaller;
176 | border: 1px solid;
177 | border-radius: 6px;
178 | padding: 0 0.3em;
179 | }
180 |
181 | .ib-nick[left] {
182 | color: hsl(0, 0%, 60%);
183 | background-color: hsl(0, 0%, 99%);
184 | border-color: hsl(0, 0%, 85%);
185 | }
186 |
--------------------------------------------------------------------------------
/style/tail_l.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dstd/HtmlayoutDelphi/e358195654e4c2c79e0bfe5866f1a02df4a36dac/style/tail_l.png
--------------------------------------------------------------------------------
/style/tail_r.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dstd/HtmlayoutDelphi/e358195654e4c2c79e0bfe5866f1a02df4a36dac/style/tail_r.png
--------------------------------------------------------------------------------
/style/theme.css:
--------------------------------------------------------------------------------
1 | /* This Source Code Form is subject to the terms of the Mozilla Public
2 | * License, v. 2.0. If a copy of the MPL was not distributed with this
3 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4 |
5 | div.bubble.outgoing {
6 | background-color: hsl(240, 100%, 97%);
7 | border-color: hsl(240, 100%, 80%);
8 | }
9 |
10 | div.bubble.outgoing p.pseudo>span {
11 | color: hsl(240, 100%, 75%);
12 | background-color: hsl(240, 100%, 94%);
13 | }
14 |
15 | div.bubble.outgoing>div.indicator {
16 | margin-left: -17px;
17 | padding-left: 32px;
18 | background: url('tail_l.png') no-repeat center left;
19 | }
20 |
21 |
22 | div.bubble.incoming {
23 | background-color: hsl(0, 100%, 97%);
24 | border-color: hsl(0, 100%, 80%);
25 | }
26 |
27 | div.bubble.incoming p.pseudo>span {
28 | color: hsl(0, 100%, 75%);
29 | background-color: hsl(0, 100%, 94%);
30 | }
31 |
32 | div.bubble.incoming>div.indicator {
33 | margin-right: -19px;
34 | padding-right: 34px;
35 | background: url('tail_r.png') no-repeat center right;
36 | }
37 |
--------------------------------------------------------------------------------