Dillo v3.1.1-119-g140d9ebd
Loading...
Searching...
No Matches
dw_resource_test.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.H>
24#include <FL/Fl_Window.H>
25
26#include "dw/core.hh"
27#include "dw/fltkcore.hh"
28#include "dw/fltkviewport.hh"
29#include "dw/textblock.hh"
30#include "dw/ui.hh"
31
32using namespace dw;
33using namespace dw::core;
34using namespace dw::core::style;
35using namespace dw::core::ui;
36using namespace dw::fltk;
37
38int main(int argc, char **argv)
39{
42
43 Fl_Window *window = new Fl_Window(410, 210, "Dw Resource test");
44 window->box(FL_NO_BOX);
45 window->begin();
46
47 FltkViewport *viewport = new FltkViewport (0, 0, 410, 210);
49
50 StyleAttrs styleAttrs;
51 styleAttrs.initValues ();
52 styleAttrs.margin.setVal (5);
53
54 FontAttrs fontAttrs;
55 fontAttrs.name = "Bitstream Charter";
56 fontAttrs.size = 14;
57 fontAttrs.weight = 400;
58 fontAttrs.style = FONT_STYLE_NORMAL;
59 fontAttrs.letterSpacing = 0;
61 styleAttrs.font = dw::core::style::Font::create (layout, &fontAttrs);
62
63 styleAttrs.color = Color::create (layout, 0x000000);
64 styleAttrs.backgroundColor = Color::create (layout, 0xffffff);
65
66 Style *widgetStyle = Style::create (&styleAttrs);
67
68 Textblock *textblock = new Textblock (false);
69 textblock->setStyle (widgetStyle);
70 layout->setWidget (textblock);
71
73
74 styleAttrs.margin.setVal (0);
75 styleAttrs.backgroundColor = NULL;
76
77 widgetStyle = Style::create (&styleAttrs);
78
81 //SelectionResource *res =
82 // layout->getResourceFactory()->createOptionMenuResource ();
83
84 Embed *embed = new Embed (res);
85 textblock->addWidget (embed, widgetStyle);
86 textblock->addSpace (widgetStyle);
87
89
90 for(int i = 0; i < 50; i++)
91 res->addItem ("Hello, world!", true, i == 0 ? true : false);
92
93 textblock->flush ();
94
95 window->resizable(viewport);
96 window->show();
97
98 int errorCode = Fl::run();
99
100 delete layout;
101
102 return errorCode;
103}
int main(void)
Definition bookmarks.c:1613
A Widget for rendering text blocks, i.e.
Definition textblock.hh:206
void addWidget(core::Widget *widget, core::style::Style *style)
Add a widget (word type) to the page.
void addSpace(core::style::Style *style)
?
The central class for managing and drawing a widget tree.
Definition layout.hh:17
void attachView(View *view)
Attach a view to the layout.
Definition layout.cc:459
void setWidget(Widget *widget)
Definition layout.cc:433
ui::ResourceFactory * getResourceFactory()
Definition layout.hh:421
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
A widget for embedding UI widgets.
Definition ui.hh:224
@ SELECTION_AT_MOST_ONE
At most one item is selected.
Definition ui.hh:503
virtual ListResource * createListResource(ListResource::SelectionMode selectionMode, int rows)=0
Base interface for dw::core::ui::ListResource and dw::core::ui::OptionMenuResource.
Definition ui.hh:467
virtual void addItem(const char *str, bool enabled, bool selected)=0
static Style * widgetStyle
static Fl_Window * window
static Layout * layout
static FltkPlatform * platform
static FltkViewport * viewport
Anything related to Dillo Widget styles is defined here.
Definition style.cc:34
@ FONT_VARIANT_NORMAL
Definition style.hh:333
Anything related to embedded UI widgets is defined here.
Definition core.hh:36
The core of Dw is defined in this namespace.
Definition core.hh:23
This namespace contains FLTK implementations of Dw interfaces.
Dw is in this namespace, or sub namespaces of this one.