Dillo
v3.1.1-98-g318d1f14
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
32
using namespace
dw
;
33
using namespace
dw::core
;
34
using namespace
dw::core::style
;
35
using namespace
dw::core::ui
;
36
using namespace
dw::fltk
;
37
38
int
main
(
int
argc,
char
**argv)
39
{
40
FltkPlatform
*
platform
=
new
FltkPlatform
();
41
Layout
*
layout
=
new
Layout
(
platform
);
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);
48
layout
->
attachView
(
viewport
);
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;
60
fontAttrs.
fontVariant
=
FONT_VARIANT_NORMAL
;
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
72
widgetStyle
->
unref
();
73
74
styleAttrs.
margin
.
setVal
(0);
75
styleAttrs.
backgroundColor
= NULL;
76
77
widgetStyle
=
Style::create
(&styleAttrs);
78
79
SelectionResource
*res =
layout
->
getResourceFactory
()->
createListResource
80
(
ListResource::SELECTION_AT_MOST_ONE
, 4);
81
//SelectionResource *res =
82
// layout->getResourceFactory()->createOptionMenuResource ();
83
84
Embed
*embed =
new
Embed
(res);
85
textblock->
addWidget
(embed,
widgetStyle
);
86
textblock->
addSpace
(
widgetStyle
);
87
88
widgetStyle
->
unref
();
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
}
main
int main(void)
Definition
bookmarks.c:1613
dw::Textblock
A Widget for rendering text blocks, i.e.
Definition
textblock.hh:206
dw::Textblock::addWidget
void addWidget(core::Widget *widget, core::style::Style *style)
Add a widget (word type) to the page.
Definition
textblock.cc:2480
dw::Textblock::addSpace
void addSpace(core::style::Style *style)
?
Definition
textblock.cc:2605
dw::Textblock::flush
void flush()
Definition
textblock.cc:2976
dw::core::Layout
The central class for managing and drawing a widget tree.
Definition
layout.hh:17
dw::core::Layout::attachView
void attachView(View *view)
Attach a view to the layout.
Definition
layout.cc:459
dw::core::Layout::setWidget
void setWidget(Widget *widget)
Definition
layout.cc:433
dw::core::Layout::getResourceFactory
ui::ResourceFactory * getResourceFactory()
Definition
layout.hh:421
dw::core::Widget::setStyle
virtual void setStyle(style::Style *style)
Change the style of a widget.
Definition
widget.cc:1316
dw::core::style::Box::setVal
void setVal(int val)
Definition
style.hh:510
dw::core::style::Color::create
static Color * create(Layout *layout, int color)
Definition
style.cc:529
dw::core::style::FontAttrs
Definition
style.hh:682
dw::core::style::FontAttrs::fontVariant
FontVariant fontVariant
Definition
style.hh:688
dw::core::style::FontAttrs::size
int size
Definition
style.hh:685
dw::core::style::FontAttrs::style
FontStyle style
Definition
style.hh:689
dw::core::style::FontAttrs::weight
int weight
Definition
style.hh:686
dw::core::style::FontAttrs::name
const char * name
Definition
style.hh:684
dw::core::style::FontAttrs::letterSpacing
int letterSpacing
Definition
style.hh:687
dw::core::style::Font::create
static Font * create(Layout *layout, FontAttrs *attrs)
Definition
style.cc:444
dw::core::style::StyleAttrs
Definition
style.hh:531
dw::core::style::StyleAttrs::color
Color * color
Definition
style.hh:536
dw::core::style::StyleAttrs::margin
Box margin
Definition
style.hh:560
dw::core::style::StyleAttrs::font
Font * font
Definition
style.hh:533
dw::core::style::StyleAttrs::initValues
void initValues()
Definition
style.cc:57
dw::core::style::StyleAttrs::backgroundColor
Color * backgroundColor
Definition
style.hh:536
dw::core::style::Style
Definition
style.hh:615
dw::core::style::Style::unref
void unref()
Definition
style.hh:642
dw::core::style::Style::create
static Style * create(StyleAttrs *attrs)
Definition
style.hh:629
dw::core::ui::Embed
A widget for embedding UI widgets.
Definition
ui.hh:224
dw::core::ui::ListResource::SELECTION_AT_MOST_ONE
@ SELECTION_AT_MOST_ONE
At most one item is selected.
Definition
ui.hh:503
dw::core::ui::ResourceFactory::createListResource
virtual ListResource * createListResource(ListResource::SelectionMode selectionMode, int rows)=0
dw::core::ui::SelectionResource
Base interface for dw::core::ui::ListResource and dw::core::ui::OptionMenuResource.
Definition
ui.hh:467
dw::core::ui::SelectionResource::addItem
virtual void addItem(const char *str, bool enabled, bool selected)=0
dw::fltk::FltkPlatform
Definition
fltkplatform.hh:93
dw::fltk::FltkViewport
Definition
fltkviewport.hh:35
core.hh
ui.hh
widgetStyle
static Style * widgetStyle
Definition
dw_anchors_test.cc:43
window
static Fl_Window * window
Definition
dw_anchors_test.cc:41
layout
static Layout * layout
Definition
dw_anchors_test.cc:40
platform
static FltkPlatform * platform
Definition
dw_anchors_test.cc:39
viewport
static FltkViewport * viewport
Definition
dw_anchors_test.cc:42
fltkcore.hh
fltkviewport.hh
dw::core::style
Anything related to Dillo Widget styles is defined here.
Definition
style.cc:34
dw::core::style::FONT_STYLE_NORMAL
@ FONT_STYLE_NORMAL
Definition
style.hh:327
dw::core::style::FONT_VARIANT_NORMAL
@ FONT_VARIANT_NORMAL
Definition
style.hh:333
dw::core::ui
Anything related to embedded UI widgets is defined here.
Definition
core.hh:36
dw::core
The core of Dw is defined in this namespace.
Definition
core.hh:23
dw::fltk
This namespace contains FLTK implementations of Dw interfaces.
Definition
fltkcomplexbutton.hh:27
dw
Dw is in this namespace, or sub namespaces of this one.
Definition
alignedtablecell.cc:28
textblock.hh
test
dw
dw_resource_test.cc
Generated on Sun Nov 17 2024 01:31:45 for Dillo by
1.9.8