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 b2184285
authored
Mar 24, 2018
by
Jessica Hawkwell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fleshed out empty methods
1 parent
6b1be3ff
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
151 additions
and
18 deletions
src/libntk/nitrogen/nwt/Component.cpp
src/libntk/nitrogen/nwt/Component.h
src/libntk/nitrogen/nwt/Container.cpp
src/libntk/nitrogen/nwt/Dimension.h
src/libntk/nitrogen/nwt/Graphics.h
src/libntk/nitrogen/nwt/MouseEvent.h
src/libntk/nitrogen/nwt/Component.cpp
View file @
b218428
...
...
@@ -46,7 +46,7 @@ namespace nitrogen {
cy
=
0
;
cw
=
0
;
ch
=
0
;
//me_list = new std::list<MouseEvent
>();
me_list
=
new
std
::
vector
<
MouseEvent
*
>
();
parent
=
nullptr
;
preferredSize
=
new
Rectangle
(
0
,
0
);
}
...
...
@@ -140,43 +140,101 @@ namespace nitrogen {
}
void
Component
::
paint
(
Graphics
*
g
)
{
if
(
border
!=
nullptr
)
{
border
->
paintBorder
(
*
this
,
g
,
cx
,
cy
,
cw
,
ch
);
}
}
void
Component
::
repaint
()
{
if
(
graphics
!=
nullptr
)
{
paint
(
graphics
);
}
}
void
Component
::
paintAll
(
Graphics
*
g
)
{
if
(
g
!=
nullptr
)
{
paint
(
g
);
}
}
void
Component
::
update
(
Graphics
*
g
)
{
if
(
g
)
{
if
(
graphics
!=
g
)
{
if
(
graphics
)
{
graphics
->
dispose
();
graphics
=
g
->
create
();
}
}
graphics
->
setColor
(
background
);
graphics
->
fillRect
(
0
,
0
,
cw
,
ch
);
graphics
->
setColor
(
foreground
);
paint
(
graphics
);
}
}
void
Component
::
validate
()
{
Dimension
*
d
;
d
=
getPreferredSize
();
std
::
cout
<<
"d: "
<<
*
d
<<
std
::
endl
;
}
void
Component
::
removeNotify
()
{
if
(
graphics
)
{
graphics
->
dispose
();
}
graphics
=
nullptr
;
}
void
Component
::
addMouseListener
(
MouseListener
*
m
)
{
me_list
->
insert
(
me_list
->
end
(),
m
);
}
void
Component
::
dispatchEvent
(
NWTEvent
*
e
)
{
processEvent
(
e
);
}
void
Component
::
processEvent
(
NWTEvent
*
e
)
{
if
(
parent
)
{
parent
->
processEvent
(
e
);
}
unsigned
int
size
=
me_list
->
size
();
if
(
size
)
{
MouseEvent
*
me
=
(
MouseEvent
*
)
e
;
if
(
me
)
{
processMouseEvent
(
me
);
}
}
}
void
Component
::
processMouseEvent
(
MouseEvent
*
e
)
{
MouseListener
*
l
;
unsigned
int
count
=
me_list
->
size
();
for
(
int
a
=
0
;
a
<
count
;
a
++
)
{
l
=
(
*
me_list
)[
a
];
switch
(
e
->
getId
())
{
case
MouseEvent
:
:
MOUSE_CLICKED
:
l
->
mouseClicked
(
e
);
break
;
case
MouseEvent
:
:
MOUSE_ENTERED
:
l
->
mouseEntered
(
e
);
break
;
case
MouseEvent
:
:
MOUSE_EXITED
:
l
->
mouseExited
(
e
);
break
;
case
MouseEvent
:
:
MOUSE_PRESSED
:
l
->
mousePressed
(
e
);
break
;
case
MouseEvent
:
:
MOUSE_RELEASED
:
l
->
mouseReleased
(
e
);
break
;
}
}
}
}
}
src/libntk/nitrogen/nwt/Component.h
View file @
b218428
...
...
@@ -47,7 +47,7 @@
#include <nitrogen/nwt/NWTEvent.h>
#include <nitrogen/nwt/Rectangle.h>
#include <
list
>
#include <
vector
>
namespace
nitrogen
{
namespace
nwt
{
...
...
@@ -58,6 +58,7 @@ namespace nitrogen {
class
MouseListener
;
class
Component
:
public
Object
{
friend
class
Container
;
public
:
virtual
Border
*
getBorder
();
virtual
Dimension
*
getSize
();
...
...
@@ -101,7 +102,7 @@ namespace nitrogen {
nitrogen
::
nwt
::
Font
*
font
;
Color
*
foreground
;
Color
*
background
;
std
::
list
<
MouseEvent
>*
me_list
;
std
::
vector
<
MouseEvent
*
>*
me_list
;
Rectangle
*
preferredSize
;
Component
();
...
...
src/libntk/nitrogen/nwt/Container.cpp
View file @
b218428
...
...
@@ -32,15 +32,14 @@
*/
#include "Container.h"
#include "Insets.h"
namespace
nitrogen
{
namespace
nwt
{
Component
*
Container
::
add
(
Component
*
comp
)
{
std
::
vector
<
Component
*>::
iterator
it
;
it
=
lst
->
end
();
lst
->
insert
(
it
,
comp
);
comp
->
parent
=
this
;
lst
->
insert
(
lst
->
end
(),
comp
);
return
comp
;
}
...
...
@@ -83,23 +82,85 @@ namespace nitrogen {
}
void
Container
::
paintAll
(
Graphics
*
g
)
{
this
->
Component
.
paintAll
(
g
);
Dimension
*
size
=
getSize
();
unsigned
int
count
=
lst
->
size
();
Component
*
c
;
Rectangle
*
bounds
;
for
(
int
a
=
0
;
a
<
count
;
a
++
)
{
c
=
getComponent
(
a
);
bounds
=
c
->
getBounds
();
g
->
translate
(
bounds
->
getX
(),
bounds
->
getY
());
g
->
setClip
(
bounds
->
getX
(),
bounds
->
getY
(),
bounds
->
getWidth
(),
bounds
->
getHeight
());
c
->
paint
(
g
);
g
->
setClip
(
-
bounds
->
getX
(),
-
bounds
->
getY
(),
bounds
->
getWidth
(),
bounds
->
getHeight
());
g
->
translate
(
-
bounds
->
getX
(),
-
bounds
->
getY
());
}
}
void
Container
::
paintComponents
(
Graphics
*
g
)
{
paintAll
(
g
);
}
void
Container
::
update
(
Graphics
*
g
)
{
this
->
Component
::
update
(
g
);
unsigned
int
count
=
lst
->
size
();
if
(
count
)
{
Dimension
*
s
=
getSize
();
Insets
*
i
;
if
(
border
)
{
i
=
border
->
getBorderInsets
(
this
);
}
else
{
i
=
new
Insets
(
0
,
0
,
0
,
0
);
}
s
->
w
-=
(
i
->
getLeft
()
+
i
->
getRight
());
s
->
h
-=
(
i
->
getTop
()
+
i
->
getBottom
());
Component
*
c
;
Rectangle
*
bounds
;
for
(
int
a
=
0
;
a
<
count
;
a
++
)
{
c
=
getComponent
(
a
);
bounds
=
c
->
getBounds
();
g
->
translate
(
bounds
->
getX
(),
bounds
->
getY
());
g
->
setClip
(
bounds
->
getX
(),
bounds
->
getY
(),
bounds
->
getWidth
(),
bounds
->
getHeight
());
c
->
update
(
g
);
g
->
setClip
(
-
bounds
->
getX
(),
-
bounds
->
getY
(),
-
bounds
->
getWidth
(),
-
bounds
->
getHeight
());
g
->
translate
(
-
bounds
->
getX
(),
-
bounds
->
getY
());
}
}
}
void
Container
::
validate
()
{
this
->
Component
::
validate
();
unsigned
int
count
=
lst
->
size
();
for
(
int
a
=
0
;
a
<
count
;
a
++
)
{
(
*
lst
)[
a
]
->
validate
();
}
lm
->
layoutContainer
(
this
);
}
void
Container
::
removeNotify
()
{
this
->
Component
->
removeNotify
();
unsigned
int
count
=
lst
->
size
();
for
(
int
a
=
0
;
a
<
count
;
a
++
)
{
(
*
lst
)[
a
]
->
removeNotify
();
}
}
Container
::
Container
()
{
...
...
src/libntk/nitrogen/nwt/Dimension.h
View file @
b218428
...
...
@@ -41,6 +41,9 @@ namespace nitrogen {
class
Dimension
:
public
Object
{
public
:
unsigned
int
w
;
unsigned
int
h
;
Dimension
();
Dimension
(
unsigned
int
width
,
unsigned
int
height
);
virtual
unsigned
int
getHeight
();
...
...
@@ -56,8 +59,6 @@ namespace nitrogen {
virtual
bool
operator
==
(
Dimension
&
right
);
protected
:
unsigned
int
w
;
unsigned
int
h
;
private
:
};
...
...
src/libntk/nitrogen/nwt/Graphics.h
View file @
b218428
...
...
@@ -44,6 +44,7 @@ namespace nitrogen {
class
Graphics
:
public
Object
{
public
:
virtual
Graphics
*
create
()
=
0
;
virtual
void
drawPoint
(
int
x
,
int
y
)
=
0
;
virtual
void
drawLine
(
int
sx
,
int
xy
,
int
dx
,
int
dy
)
=
0
;
virtual
void
drawRect
(
int
x
,
int
y
,
unsigned
int
width
,
unsigned
int
height
)
=
0
;
...
...
@@ -64,6 +65,7 @@ namespace nitrogen {
virtual
void
setFont
(
nitrogen
::
nwt
::
Font
*
f
)
=
0
;
virtual
void
translate
(
int
x
,
int
y
)
=
0
;
virtual
void
dispose
()
=
0
;
virtual
std
::
string
*
toString
()
const
=
0
;
virtual
Graphics
&
operator
()()
const
=
0
;
...
...
src/libntk/nitrogen/nwt/MouseEvent.h
View file @
b218428
...
...
@@ -46,6 +46,16 @@ namespace nitrogen {
class
MouseEvent
:
public
InputEvent
{
public
:
static
const
int
MOUSE_CLICKED
=
0
;
static
const
int
MOUSE_DRAGGED
=
1
;
static
const
int
MOUSE_ENTERED
=
3
;
static
const
int
MOUSE_EXITED
=
4
;
static
const
int
MOUSE_FIRST
=
5
;
static
const
int
MOUSE_LAST
=
6
;
static
const
int
MOUSE_MOVED
=
7
;
static
const
int
MOUSE_PRESSED
=
8
;
static
const
int
MOUSE_RELEASED
=
9
;
MouseEvent
(
Component
*
comp
,
int
i
,
long
when
,
int
mods
,
int
x
,
int
y
,
int
clicks
,
bool
popupTrigger
=
false
);
virtual
int
getModifiers
();
virtual
int
getX
();
...
...
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