Dillo
v3.1.1-99-gf3103cc4
Loading...
Searching...
No Matches
dw_table.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/table.hh
"
30
31
using namespace
dw
;
32
using namespace
dw::core
;
33
using namespace
dw::core::style
;
34
using namespace
dw::fltk
;
35
36
int
main
(
int
argc,
char
**argv)
37
{
38
FltkPlatform
*
platform
=
new
FltkPlatform
();
39
Layout
*
layout
=
new
Layout
(
platform
);
40
41
Fl_Window *
window
=
new
Fl_Window(300, 300,
"Dw Table"
);
42
window
->box(FL_NO_BOX);
43
window
->begin();
44
45
FltkViewport
*
viewport
=
new
FltkViewport
(0, 0, 300, 300);
46
layout
->
attachView
(
viewport
);
47
48
StyleAttrs
styleAttrs;
49
styleAttrs.
initValues
();
50
styleAttrs.
margin
.
setVal
(5);
51
styleAttrs.
padding
.
setVal
(0);
52
styleAttrs.
borderWidth
.
setVal
(1);
53
styleAttrs.
setBorderStyle
(
BORDER_OUTSET
);
54
styleAttrs.
setBorderColor
(
Color::create
(
layout
, 0xffffff));
55
styleAttrs.
color
=
Color::create
(
layout
, 0x000000);
56
styleAttrs.
backgroundColor
=
Color::create
(
layout
, 0xffffff);
57
styleAttrs.
hBorderSpacing
= 5;
58
styleAttrs.
vBorderSpacing
= 5;
59
60
FontAttrs
fontAttrs;
61
fontAttrs.
name
=
"Bitstream Charter"
;
62
fontAttrs.
size
= 14;
63
fontAttrs.
weight
= 400;
64
fontAttrs.
style
=
FONT_STYLE_NORMAL
;
65
fontAttrs.
letterSpacing
= 0;
66
fontAttrs.
fontVariant
=
FONT_VARIANT_NORMAL
;
67
styleAttrs.
font
=
dw::core::style::Font::create
(
layout
, &fontAttrs);
68
69
Style
*tableStyle =
Style::create
(&styleAttrs);
70
71
Table
*table =
new
Table
(
false
);
72
table->
setStyle
(tableStyle);
73
layout
->
setWidget
(table);
74
75
tableStyle->
unref
();
76
77
styleAttrs.
setBorderStyle
(
BORDER_INSET
);
78
styleAttrs.
backgroundColor
= NULL;
79
styleAttrs.
margin
.
setVal
(0);
80
styleAttrs.
padding
.
setVal
(5);
81
82
Style
*cellStyle =
Style::create
(&styleAttrs);
83
84
styleAttrs.
borderWidth
.
setVal
(0);
85
styleAttrs.
margin
.
setVal
(0);
86
styleAttrs.
cursor
=
CURSOR_TEXT
;
87
styleAttrs.
textAlignChar
=
'.'
;
88
89
Style
*
wordStyle
=
Style::create
(&styleAttrs);
90
91
for
(
int
i = 0; i < 4; i++) {
92
table->
addRow
(
wordStyle
);
93
94
for
(
int
j = 0; j < 4; j++) {
95
Textblock
*cell =
new
Textblock
(
false
);
96
cell->
setStyle
(cellStyle);
97
table->
addCell
(cell, 1, 1);
98
99
char
buf[10];
100
sprintf (buf,
"cell %c"
,
'A'
+ 4 * i + j);
101
102
cell->
addText
(buf,
wordStyle
);
103
cell->
flush
();
104
}
105
}
106
107
wordStyle
->
unref
();
108
cellStyle->
unref
();
109
110
window
->resizable(
viewport
);
111
window
->show();
112
int
errorCode = Fl::run();
113
114
delete
layout
;
115
116
return
errorCode;
117
}
main
int main(void)
Definition
bookmarks.c:1613
dw::Table
A Widget for rendering tables.
Definition
table.hh:326
dw::Table::addCell
void addCell(Widget *widget, int colspan, int rowspan)
Definition
table.cc:468
dw::Table::addRow
void addRow(core::style::Style *style)
Definition
table.cc:584
dw::Textblock
A Widget for rendering text blocks, i.e.
Definition
textblock.hh:206
dw::Textblock::addText
void addText(const char *text, size_t len, core::style::Style *style)
Add a word to the page structure.
Definition
textblock.cc:2024
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::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::vBorderSpacing
int vBorderSpacing
Definition
style.hh:556
dw::core::style::StyleAttrs::margin
Box margin
Definition
style.hh:560
dw::core::style::StyleAttrs::hBorderSpacing
int hBorderSpacing
Definition
style.hh:556
dw::core::style::StyleAttrs::setBorderStyle
void setBorderStyle(BorderStyle val)
Definition
style.hh:588
dw::core::style::StyleAttrs::borderWidth
Box borderWidth
Definition
style.hh:560
dw::core::style::StyleAttrs::font
Font * font
Definition
style.hh:533
dw::core::style::StyleAttrs::setBorderColor
void setBorderColor(Color *val)
Definition
style.hh:585
dw::core::style::StyleAttrs::initValues
void initValues()
Definition
style.cc:57
dw::core::style::StyleAttrs::textAlignChar
char textAlignChar
Definition
style.hh:545
dw::core::style::StyleAttrs::padding
Box padding
Definition
style.hh:560
dw::core::style::StyleAttrs::backgroundColor
Color * backgroundColor
Definition
style.hh:536
dw::core::style::StyleAttrs::cursor
Cursor cursor
Definition
style.hh:569
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::fltk::FltkPlatform
Definition
fltkplatform.hh:93
dw::fltk::FltkViewport
Definition
fltkviewport.hh:35
core.hh
table.hh
wordStyle
static Style * wordStyle
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::CURSOR_TEXT
@ CURSOR_TEXT
Definition
style.hh:214
dw::core::style::FONT_VARIANT_NORMAL
@ FONT_VARIANT_NORMAL
Definition
style.hh:333
dw::core::style::BORDER_OUTSET
@ BORDER_OUTSET
Definition
style.hh:234
dw::core::style::BORDER_INSET
@ BORDER_INSET
Definition
style.hh:233
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
test
dw
dw_table.cc
Generated on Sun Nov 24 2024 01:38:42 for Dillo by
1.9.8