Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Jessica Hawkwell
/
nitrogen
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
2
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit bbbd4222
authored
Mar 17, 2020
by
Jessica Hawkwell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
trying to make things work
1 parent
317c307b
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
24 additions
and
32 deletions
src/ntk/nitrogen/nwt/Component.h
src/ntk/nitrogen/nwt/NativeGraphics.cpp
src/ntk/nitrogen/nwt/NativeGraphics.h
src/ntk/nitrogen/util/ComponentRenderer.cpp
src/ntk/nitrogen/util/ComponentRenderer.h
src/ntk/nitrogen/nwt/Component.h
View file @
bbbd422
...
...
@@ -52,10 +52,10 @@
namespace
nitrogen
{
namespace
util
{
class
ComponentRenderer
;
}
namespace
nwt
{
class
Border
;
//class nitrogen::util::ComponentRenderer;
class
Graphics
;
class
NWTEvent
;
class
MouseEvent
;
...
...
src/ntk/nitrogen/nwt/NativeGraphics.cpp
View file @
bbbd422
...
...
@@ -37,8 +37,13 @@
namespace
nitrogen
{
namespace
nwt
{
// Xorg stuffies
Display
*
xdisp
;
GC
*
xgc
;
Drawable
*
xdraw
;
NativeGraphics
::
NativeGraphics
()
{
xdisp
=
XOpenDisplay
(
nullptr
);
}
NativeGraphics
::
NativeGraphics
(
NativeGraphics
&
)
{
...
...
@@ -46,22 +51,23 @@ namespace nitrogen {
}
Graphics
*
NativeGraphics
::
create
()
{
Graphics
*
rt
=
new
NativeGraphics
(
this
);
}
void
NativeGraphics
::
drawPoint
(
int
x
,
int
y
)
{
XDrawPoint
(
xdisp
,(
*
xdraw
),
(
*
xgc
),
x
,
y
);
}
void
NativeGraphics
::
drawLine
(
int
sx
,
int
x
y
,
int
dx
,
int
dy
)
{
void
NativeGraphics
::
drawLine
(
int
sx
,
int
s
y
,
int
dx
,
int
dy
)
{
XDrawLine
(
xdisp
,
(
*
xdraw
),
(
*
xgc
),
sx
,
sy
,
dx
,
dy
);
}
void
NativeGraphics
::
drawRect
(
int
x
,
int
y
,
unsigned
int
width
,
unsigned
int
height
)
{
XDrawRectangle
(
xdisp
,
(
*
xdraw
),
(
*
xgc
),
x
,
y
,
width
,
height
);
}
void
NativeGraphics
::
fillRect
(
int
x
,
int
y
,
unsigned
int
width
,
unsigned
int
height
)
{
XFillRectangle
(
xdisp
,
(
*
xdraw
),
(
*
xgc
),
x
,
y
,
width
,
height
);
}
void
NativeGraphics
::
draw3DRect
(
int
x
,
int
y
,
unsigned
int
width
,
unsigned
int
height
,
bool
)
{
...
...
@@ -73,11 +79,13 @@ namespace nitrogen {
}
void
NativeGraphics
::
drawString
(
std
::
string
*
str
,
int
x
,
int
y
)
{
//char * cstr = new char [str->length()+1];
//char * basic = str->c_str();
XDrawString
(
xdisp
,
(
*
xdraw
),
(
*
xgc
),
x
,
y
,
str
->
c_str
(),
font
->
getSize
());
}
void
NativeGraphics
::
drawString
(
std
::
string
&
str
,
int
x
,
int
y
)
{
XDrawString
(
xdisp
,
(
*
xdraw
),
(
*
xgc
),
x
,
y
,
str
.
c_str
(),
font
->
getSize
());
}
void
NativeGraphics
::
setClip
(
int
x
,
int
y
,
unsigned
int
width
,
unsigned
int
height
)
{
...
...
@@ -89,15 +97,15 @@ namespace nitrogen {
}
void
NativeGraphics
::
setFont
(
nitrogen
::
nwt
::
Font
*
f
)
{
font
=
f
;
}
Color
*
NativeGraphics
::
getColor
()
{
return
color
;
}
nitrogen
::
nwt
::
Font
*
NativeGraphics
::
getFont
()
{
return
font
;
}
FontMetrics
*
NativeGraphics
::
getFontMetrics
()
{
...
...
@@ -112,12 +120,6 @@ namespace nitrogen {
}
void
NativeGraphics
::
pDrawLine
(
int
x1
,
int
y1
,
int
x2
,
int
y2
)
{
}
void
NativeGraphics
::
pDrawPoint
(
int
,
int
)
{
}
void
NativeGraphics
::
initGC
()
{
}
...
...
src/ntk/nitrogen/nwt/NativeGraphics.h
View file @
bbbd422
...
...
@@ -51,7 +51,7 @@ namespace nitrogen {
NativeGraphics
(
NativeGraphics
&
);
Graphics
*
create
()
override
;
void
drawPoint
(
int
x
,
int
y
)
override
;
void
drawLine
(
int
sx
,
int
x
y
,
int
dx
,
int
dy
)
override
;
void
drawLine
(
int
sx
,
int
s
y
,
int
dx
,
int
dy
)
override
;
void
drawRect
(
int
x
,
int
y
,
unsigned
int
width
,
unsigned
int
height
)
override
;
void
fillRect
(
int
x
,
int
y
,
unsigned
int
width
,
unsigned
int
height
)
override
;
void
draw3DRect
(
int
x
,
int
y
,
unsigned
int
width
,
unsigned
int
height
,
bool
)
override
;
...
...
@@ -78,9 +78,10 @@ namespace nitrogen {
unsigned
int
width
;
unsigned
int
height
;
nitrogen
::
nwt
::
Font
*
font
;
nitrogen
::
nwt
::
Color
*
color
;
NativeGraphics
();
virtual
void
pDrawLine
(
int
,
int
,
int
,
int
);
virtual
void
pDrawPoint
(
int
,
int
);
virtual
void
initGC
();
virtual
void
updateGC
();
virtual
void
createClip
();
...
...
src/ntk/nitrogen/util/ComponentRenderer.cpp
View file @
bbbd422
...
...
@@ -78,8 +78,6 @@ namespace nitrogen {
XRenderPictFormat
*
pf
=
XRenderFindVisualFormat
(
nitrogen
::
disp
,
attrs
.
visual
);
surface
=
cairo_xlib_surface_create_with_xrender_format
(
nitrogen
::
disp
,
window
,
attrs
.
screen
,
pf
,
width
,
height
);
cairo
=
cairo_create
(
surface
);
/*svg_handle = */
resvg_init
();
}
std
::
string
*
ComponentRenderer
::
getName
()
{
...
...
@@ -95,16 +93,6 @@ namespace nitrogen {
}
void
ComponentRenderer
::
renderComponent
()
{
//void resvg_cairo_render_to_canvas(const resvg_render_tree* rtree, const resvg_options* opt, resvg_size size, cairo_t* cr)
resvg_options
ro
;
ro
.
dpi
=
96
;
ro
.
draw_background
=
false
;
ro
.
fit_to
.
type
=
resvg_fit_to_type
::
RESVG_FIT_TO_ZOOM
;
resvg_size
rs
;
rs
.
width
=
comp
->
getSize
()
->
getWidth
();
rs
.
height
=
comp
->
getSize
()
->
getWidth
();
resvg_cairo_render_to_canvas
(
svg_tree
,
&
ro
,
rs
,
cairo
);
}
}
}
src/ntk/nitrogen/util/ComponentRenderer.h
View file @
bbbd422
...
...
@@ -49,6 +49,7 @@ namespace nitrogen {
namespace
util
{
class
ComponentRenderer
:
public
Object
{
friend
class
nitrogen
::
nwt
::
Component
;
public
:
ComponentRenderer
(
std
::
string
*
componentName
,
nwt
::
Component
*
component
);
ComponentRenderer
(
std
::
string
&
componentName
,
nwt
::
Component
*
component
);
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment