Dillo v3.1.1-98-g318d1f14
Loading...
Searching...
No Matches
dw_example.cc
Go to the documentation of this file.
1/*
2 * Dillo Widget
3 *
4 * Copyright 2005-2007 Sebastian Geerken <sgeerken@dillo.org>
5 * Copyright 2023 Rodrigo Arias Mallo <rodarima@gmail.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21
22
23#include <FL/Fl_Window.H>
24#include <FL/Fl.H>
25
26#include "dw/core.hh"
27#include "dw/fltkcore.hh"
28#include "dw/fltkviewport.hh"
29#include "dw/textblock.hh"
30
31
32int main(int argc, char **argv)
33{
36
37 Fl_Window *window = new Fl_Window(200, 300, "Dw Example");
38 window->box(FL_NO_BOX);
39 window->begin();
40
42 new dw::fltk::FltkViewport (0, 0, 200, 300);
43 layout->attachView (viewport);
44
46 styleAttrs.initValues ();
47 styleAttrs.margin.setVal (5);
48
50 fontAttrs.name = "Bitstream Charter";
51 fontAttrs.size = 14;
52 fontAttrs.weight = 400;
54 fontAttrs.letterSpacing = 0;
56 styleAttrs.font = dw::core::style::Font::create (layout, &fontAttrs);
57
58 styleAttrs.color =
60 styleAttrs.backgroundColor =
62
65
66 dw::Textblock *textblock = new dw::Textblock (false);
67 textblock->setStyle (widgetStyle);
68 layout->setWidget (textblock);
69
70 widgetStyle->unref();
71
72 styleAttrs.margin.setVal (0);
73 styleAttrs.backgroundColor = NULL;
74
77
78 for(int i = 1; i <= 10; i++) {
79 char buf[4];
80 sprintf(buf, "%d.", i);
81
82 const char *words[] = { "This", "is", "the", buf, "paragraph.",
83 "Here", "comes", "some", "more", "text",
84 "to", "demonstrate", "word", "wrapping.",
85 NULL };
86
87 for(int j = 0; words[j]; j++) {
88 textblock->addText(words[j], wordStyle);
89 textblock->addSpace(wordStyle);
90 }
91
92 textblock->addParbreak(10, wordStyle);
93 }
94
95 wordStyle->unref();
96
97 textblock->flush ();
98
99 window->resizable(viewport);
100 window->show();
101 int errorCode = Fl::run();
102
103 delete layout;
104
105 return errorCode;
106}
int main(void)
Definition bookmarks.c:1613
A Widget for rendering text blocks, i.e.
Definition textblock.hh:206
void addSpace(core::style::Style *style)
?
void addText(const char *text, size_t len, core::style::Style *style)
Add a word to the page structure.
void addParbreak(int space, core::style::Style *style)
Cause a paragraph break.
The central class for managing and drawing a widget tree.
Definition layout.hh:17
virtual void setStyle(style::Style *style)
Change the style of a widget.
Definition widget.cc:1316
void setVal(int val)
Definition style.hh:510
static Color * create(Layout *layout, int color)
Definition style.cc:529
FontVariant fontVariant
Definition style.hh:688
static Font * create(Layout *layout, FontAttrs *attrs)
Definition style.cc:444
static Style * create(StyleAttrs *attrs)
Definition style.hh:629
static Style * wordStyle
static Style * widgetStyle
static Fl_Window * window
static Layout * layout
static FltkPlatform * platform
static FltkViewport * viewport
@ FONT_VARIANT_NORMAL
Definition style.hh:333