Dillo
v3.1.1-98-g318d1f14
Loading...
Searching...
No Matches
dw_table_aligned.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
#include "
dw/alignedtablecell.hh
"
31
32
using namespace
dw
;
33
using namespace
dw::core
;
34
using namespace
dw::core::style
;
35
using namespace
dw::fltk
;
36
37
int
main
(
int
argc,
char
**argv)
38
{
39
FltkPlatform
*
platform
=
new
FltkPlatform
();
40
Layout
*
layout
=
new
Layout
(
platform
);
41
42
Fl_Window *
window
=
new
Fl_Window(200, 300,
"Dw Table Aligned"
);
43
window
->box(FL_NO_BOX);
44
window
->begin();
45
46
FltkViewport
*
viewport
=
new
FltkViewport
(0, 0, 200, 300);
47
layout
->
attachView
(
viewport
);
48
49
StyleAttrs
styleAttrs;
50
styleAttrs.
initValues
();
51
styleAttrs.
margin
.
setVal
(5);
52
styleAttrs.
borderWidth
.
setVal
(1);
53
styleAttrs.
setBorderStyle
(
BORDER_OUTSET
);
54
styleAttrs.
setBorderColor
(
Color::create
(
layout
, 0x808080));
55
56
FontAttrs
fontAttrs;
57
fontAttrs.
name
=
"Bitstream Charter"
;
58
fontAttrs.
size
= 14;
59
fontAttrs.
weight
= 400;
60
fontAttrs.
style
=
FONT_STYLE_NORMAL
;
61
fontAttrs.
letterSpacing
= 0;
62
fontAttrs.
fontVariant
=
FONT_VARIANT_NORMAL
;
63
styleAttrs.
font
=
dw::core::style::Font::create
(
layout
, &fontAttrs);
64
65
styleAttrs.
color
=
Color::create
(
layout
, 0x000000);
66
styleAttrs.
backgroundColor
=
Color::create
(
layout
, 0xa0a0a0);
67
styleAttrs.
hBorderSpacing
= 5;
68
styleAttrs.
vBorderSpacing
= 5;
69
70
Style
*tableStyle =
Style::create
(&styleAttrs);
71
72
Table
*table =
new
Table
(
false
);
73
table->
setStyle
(tableStyle);
74
layout
->
setWidget
(table);
75
76
tableStyle->
unref
();
77
78
styleAttrs.
borderWidth
.
setVal
(1);
79
styleAttrs.
setBorderStyle
(
BORDER_INSET
);
80
81
Style
*cellStyle =
Style::create
(&styleAttrs);
82
83
styleAttrs.
borderWidth
.
setVal
(0);
84
styleAttrs.
margin
.
setVal
(0);
85
styleAttrs.
backgroundColor
= NULL;
86
styleAttrs.
cursor
=
CURSOR_TEXT
;
87
styleAttrs.
textAlignChar
=
'.'
;
88
89
Style
*
wordStyle
=
Style::create
(&styleAttrs);
90
91
AlignedTableCell
*ref = NULL;
92
for
(
int
i = 0; i < 10; i++) {
93
//for(int i = 0; i < 1; i++) {
94
AlignedTableCell
*cell =
new
AlignedTableCell
(ref,
false
);
95
cell->
setStyle
(cellStyle);
96
ref = cell;
97
table->
addRow
(
wordStyle
);
98
table->
addCell
(cell, 1, 1);
99
100
char
buf[16];
101
for
(
int
j = 0; j < i; j++)
102
buf[j] =
'0'
+ j;
103
buf[i] =
'.'
;
104
for
(
int
j = i + 1; j < 11; j++)
105
buf[j] =
'0'
+ (j - 1);
106
buf[11] = 0;
107
108
cell->
addText
(buf,
wordStyle
);
109
cell->
flush
();
110
}
111
112
wordStyle
->
unref
();
113
cellStyle->
unref
();
114
115
window
->resizable(
viewport
);
116
window
->show();
117
int
errorCode = Fl::run();
118
119
delete
layout
;
120
121
return
errorCode;
122
}
alignedtablecell.hh
main
int main(void)
Definition
bookmarks.c:1613
dw::AlignedTableCell
Definition
alignedtablecell.hh:10
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::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::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_aligned.cc
Generated on Sun Nov 17 2024 01:31:45 for Dillo by
1.9.8