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 46910efe
authored
Mar 20, 2020
by
Jessica Hawkwell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rawr
1 parent
6af7bd56
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
50 additions
and
10 deletions
CMakeLists.txt
src/ntk/nitrogen/nwt/NativeGraphics.cpp
src/ntk/nitrogen/nwt/NativeGraphics.h
CMakeLists.txt
View file @
46910ef
...
...
@@ -35,5 +35,5 @@ find_package(X11)
#add_subdirectory(deps)
add_subdirectory
(
src/nde
)
#
add_subdirectory(src/ntk)
add_subdirectory
(
src/ntk
)
add_subdirectory
(
src/NitroWin
)
src/ntk/nitrogen/nwt/NativeGraphics.cpp
View file @
46910ef
...
...
@@ -38,20 +38,50 @@
namespace
nitrogen
{
namespace
nwt
{
// Xorg stuffies
Display
*
xdisp
;
GC
*
xgc
;
Drawable
*
xdraw
;
Display
*
NativeGraphics
::
xdisp
;
Drawable
*
NativeGraphics
::
xdraw
;
GC
*
NativeGraphics
::
xgc
;
NativeGraphics
::
NativeGraphics
()
{
mask
=
0L
;
cx
=
0
;
cy
=
0
;
tx
=
0
;
ty
=
0
;
width
=
32
;
height
=
32
;
std
::
string
*
fnt
=
std
::
string
(
"serif"
);
font
=
new
Font
(
fnt
,
12
,
12
);
color
=
new
Color
(
0
,
0
,
0
);
xdisp
=
XOpenDisplay
(
nullptr
);
xdraw
=
XCreateSimpleWindow
(
xdisp
,
DefaultRootWindow
(
xdisp
),
tx
,
ty
,
width
,
height
,
0
,
0
,
0
);
xgc
=
XCreateGC
(
xdisp
,
0
,
0
,
nullptr
);
}
NativeGraphics
::
NativeGraphics
(
NativeGraphics
&
)
{
NativeGraphics
::
NativeGraphics
(
NativeGraphics
&
ng
)
{
mask
=
ng
.
mask
;
cx
=
ng
.
cx
;
cy
=
ng
.
cy
;
tx
=
ng
.
tx
;
ty
=
ng
.
ty
;
width
=
ng
.
width
;
height
=
ng
.
height
;
font
=
ng
.
font
;
color
=
ng
.
color
;
xdisp
=
ng
.
xdisp
;
xgc
=
ng
.
xgc
;
xdraw
=
ng
.
xdraw
;
}
Graphics
*
NativeGraphics
::
create
()
{
Graphics
*
rt
=
new
NativeGraphics
(
this
);
Graphics
*
rt
=
new
NativeGraphics
();
return
rt
;
}
void
NativeGraphics
::
drawPoint
(
int
x
,
int
y
)
{
...
...
@@ -79,13 +109,13 @@ namespace nitrogen {
}
void
NativeGraphics
::
drawString
(
std
::
string
*
str
,
int
x
,
int
y
)
{
//
char * cstr = new char [str->length()+1];
char
*
cstr
=
new
char
[
str
->
length
()
+
1
];
//char * basic = str->c_str();
XDrawString
(
xdisp
,
(
*
xdraw
),
(
*
xgc
)
,
x
,
y
,
str
->
c_str
(),
font
->
getSize
());
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
()
);
this
->
drawString
(
str
,
x
,
y
);
}
void
NativeGraphics
::
setClip
(
int
x
,
int
y
,
unsigned
int
width
,
unsigned
int
height
)
{
...
...
@@ -108,8 +138,13 @@ namespace nitrogen {
return
font
;
}
FontMetrics
*
NativeGraphics
::
getFontMetrics
()
{
FontMetrics
*
NativeGraphics
::
getFontMetrics
(
nitrogen
::
nwt
::
Font
*
f
)
{
FontMetrics
*
fm
=
new
FontMetrics
(
f
);
return
fm
;
}
FontMetrics
*
NativeGraphics
::
getFontMetrics
()
{
return
this
->
getFontMetrics
(
font
);
}
void
NativeGraphics
::
translate
(
int
x
,
int
y
)
{
...
...
src/ntk/nitrogen/nwt/NativeGraphics.h
View file @
46910ef
...
...
@@ -65,6 +65,7 @@ namespace nitrogen {
void
setFont
(
nitrogen
::
nwt
::
Font
*
f
)
override
;
Color
*
getColor
()
override
;
nitrogen
::
nwt
::
Font
*
getFont
()
override
;
FontMetrics
*
getFontMetrics
(
nitrogen
::
nwt
::
Font
*
f
)
override
;
FontMetrics
*
getFontMetrics
()
override
;
void
translate
(
int
x
,
int
y
)
override
;
void
dispose
()
override
;
...
...
@@ -81,6 +82,10 @@ namespace nitrogen {
nitrogen
::
nwt
::
Font
*
font
;
nitrogen
::
nwt
::
Color
*
color
;
Display
*
xdisp
;
Drawable
*
xdraw
;
GC
*
xgc
;
NativeGraphics
();
virtual
void
initGC
();
virtual
void
updateGC
();
...
...
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