Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
adam.huang
htop
Commits
c2cdcd0c
Commit
c2cdcd0c
authored
May 30, 2006
by
Hisham Muhammad
Browse files
Rename ListBox to Panel, matching dit.
parent
a853faaa
Changes
26
Show whitespace changes
Inline
Side-by-side
AvailableColumnsListBox.c
View file @
c2cdcd0c
#include "AvailableColumns
ListBox
.h"
#include "AvailableColumns
Panel
.h"
#include "Settings.h"
#include "Header.h"
#include "ScreenManager.h"
#include "Columns
ListBox
.h"
#include "Columns
Panel
.h"
#include "
ListBox
.h"
#include "
Panel
.h"
#include "debug.h"
#include <assert.h>
/*{
typedef struct AvailableColumns
ListBox
_ {
ListBox
super;
ListBox
* columns;
typedef struct AvailableColumns
Panel
_ {
Panel
super;
Panel
* columns;
Settings* settings;
ScreenManager* scr;
} AvailableColumns
ListBox
;
} AvailableColumns
Panel
;
}*/
AvailableColumns
ListBox
*
AvailableColumns
ListBox
_new
(
Settings
*
settings
,
ListBox
*
columns
,
ScreenManager
*
scr
)
{
AvailableColumns
ListBox
*
this
=
(
AvailableColumns
ListBox
*
)
malloc
(
sizeof
(
AvailableColumns
ListBox
));
ListBox
*
super
=
(
ListBox
*
)
this
;
ListBox
_init
(
super
,
1
,
1
,
1
,
1
,
LISTITEM_CLASS
,
true
);
((
Object
*
)
this
)
->
delete
=
AvailableColumns
ListBox
_delete
;
AvailableColumns
Panel
*
AvailableColumns
Panel
_new
(
Settings
*
settings
,
Panel
*
columns
,
ScreenManager
*
scr
)
{
AvailableColumns
Panel
*
this
=
(
AvailableColumns
Panel
*
)
malloc
(
sizeof
(
AvailableColumns
Panel
));
Panel
*
super
=
(
Panel
*
)
this
;
Panel
_init
(
super
,
1
,
1
,
1
,
1
,
LISTITEM_CLASS
,
true
);
((
Object
*
)
this
)
->
delete
=
AvailableColumns
Panel
_delete
;
this
->
settings
=
settings
;
this
->
scr
=
scr
;
super
->
eventHandler
=
AvailableColumns
ListBox
_eventHandler
;
super
->
eventHandler
=
AvailableColumns
Panel
_eventHandler
;
ListBox
_setHeader
(
super
,
"Available Columns"
);
Panel
_setHeader
(
super
,
"Available Columns"
);
for
(
int
i
=
1
;
i
<
LAST_PROCESSFIELD
;
i
++
)
{
if
(
i
!=
COMM
)
ListBox
_add
(
super
,
(
Object
*
)
ListItem_new
(
Process_fieldNames
[
i
],
0
));
Panel
_add
(
super
,
(
Object
*
)
ListItem_new
(
Process_fieldNames
[
i
],
0
));
}
this
->
columns
=
columns
;
return
this
;
}
void
AvailableColumns
ListBox
_delete
(
Object
*
object
)
{
ListBox
*
super
=
(
ListBox
*
)
object
;
AvailableColumns
ListBox
*
this
=
(
AvailableColumns
ListBox
*
)
object
;
ListBox
_done
(
super
);
void
AvailableColumns
Panel
_delete
(
Object
*
object
)
{
Panel
*
super
=
(
Panel
*
)
object
;
AvailableColumns
Panel
*
this
=
(
AvailableColumns
Panel
*
)
object
;
Panel
_done
(
super
);
free
(
this
);
}
HandlerResult
AvailableColumns
ListBox
_eventHandler
(
ListBox
*
super
,
int
ch
)
{
AvailableColumns
ListBox
*
this
=
(
AvailableColumns
ListBox
*
)
super
;
char
*
text
=
((
ListItem
*
)
ListBox
_getSelected
(
super
))
->
value
;
HandlerResult
AvailableColumns
Panel
_eventHandler
(
Panel
*
super
,
int
ch
)
{
AvailableColumns
Panel
*
this
=
(
AvailableColumns
Panel
*
)
super
;
char
*
text
=
((
ListItem
*
)
Panel
_getSelected
(
super
))
->
value
;
HandlerResult
result
=
IGNORED
;
switch
(
ch
)
{
...
...
@@ -59,11 +59,11 @@ HandlerResult AvailableColumnsListBox_eventHandler(ListBox* super, int ch) {
case
KEY_ENTER
:
case
KEY_F
(
5
):
{
int
at
=
ListBox
_getSelectedIndex
(
this
->
columns
)
+
1
;
if
(
at
==
ListBox
_getSize
(
this
->
columns
))
int
at
=
Panel
_getSelectedIndex
(
this
->
columns
)
+
1
;
if
(
at
==
Panel
_getSize
(
this
->
columns
))
at
--
;
ListBox
_insert
(
this
->
columns
,
at
,
(
Object
*
)
ListItem_new
(
text
,
0
));
Columns
ListBox
_update
(
this
->
columns
);
Panel
_insert
(
this
->
columns
,
at
,
(
Object
*
)
ListItem_new
(
text
,
0
));
Columns
Panel
_update
(
this
->
columns
);
result
=
HANDLED
;
break
;
}
...
...
AvailableColumnsListBox.h
View file @
c2cdcd0c
/* Do not edit this file. It was automatically genarated. */
#ifndef HEADER_AvailableColumns
ListBox
#define HEADER_AvailableColumns
ListBox
#ifndef HEADER_AvailableColumns
Panel
#define HEADER_AvailableColumns
Panel
#include "Settings.h"
#include "Header.h"
#include "ScreenManager.h"
#include "
ListBox
.h"
#include "
Panel
.h"
#include "debug.h"
#include <assert.h>
typedef
struct
AvailableColumns
ListBox
_
{
ListBox
super
;
typedef
struct
AvailableColumns
Panel
_
{
Panel
super
;
Settings
*
settings
;
ScreenManager
*
scr
;
ListBox
*
columns
;
}
AvailableColumns
ListBox
;
Panel
*
columns
;
}
AvailableColumns
Panel
;
AvailableColumns
ListBox
*
AvailableColumns
ListBox
_new
(
Settings
*
settings
,
ListBox
*
columns
,
ScreenManager
*
scr
);
AvailableColumns
Panel
*
AvailableColumns
Panel
_new
(
Settings
*
settings
,
Panel
*
columns
,
ScreenManager
*
scr
);
void
AvailableColumns
ListBox
_delete
(
Object
*
object
);
void
AvailableColumns
Panel
_delete
(
Object
*
object
);
HandlerResult
AvailableColumns
ListBox
_eventHandler
(
ListBox
*
super
,
int
ch
);
HandlerResult
AvailableColumns
Panel
_eventHandler
(
Panel
*
super
,
int
ch
);
#endif
AvailableMetersListBox.c
View file @
c2cdcd0c
#include "AvailableMeters
ListBox
.h"
#include "AvailableMeters
Panel
.h"
#include "Settings.h"
#include "Header.h"
#include "ScreenManager.h"
#include "
ListBox
.h"
#include "
Panel
.h"
#include "debug.h"
#include <assert.h>
/*{
typedef struct AvailableMeters
ListBox
_ {
ListBox
super;
typedef struct AvailableMeters
Panel
_ {
Panel
super;
Settings* settings;
ListBox
* leftBox;
ListBox
* rightBox;
Panel
* leftBox;
Panel
* rightBox;
ScreenManager* scr;
} AvailableMeters
ListBox
;
} AvailableMeters
Panel
;
}*/
AvailableMeters
ListBox
*
AvailableMeters
ListBox
_new
(
Settings
*
settings
,
ListBox
*
leftMeters
,
ListBox
*
rightMeters
,
ScreenManager
*
scr
)
{
AvailableMeters
ListBox
*
this
=
(
AvailableMeters
ListBox
*
)
malloc
(
sizeof
(
AvailableMeters
ListBox
));
ListBox
*
super
=
(
ListBox
*
)
this
;
ListBox
_init
(
super
,
1
,
1
,
1
,
1
,
LISTITEM_CLASS
,
true
);
((
Object
*
)
this
)
->
delete
=
AvailableMeters
ListBox
_delete
;
AvailableMeters
Panel
*
AvailableMeters
Panel
_new
(
Settings
*
settings
,
Panel
*
leftMeters
,
Panel
*
rightMeters
,
ScreenManager
*
scr
)
{
AvailableMeters
Panel
*
this
=
(
AvailableMeters
Panel
*
)
malloc
(
sizeof
(
AvailableMeters
Panel
));
Panel
*
super
=
(
Panel
*
)
this
;
Panel
_init
(
super
,
1
,
1
,
1
,
1
,
LISTITEM_CLASS
,
true
);
((
Object
*
)
this
)
->
delete
=
AvailableMeters
Panel
_delete
;
this
->
settings
=
settings
;
this
->
leftBox
=
leftMeters
;
this
->
rightBox
=
rightMeters
;
this
->
scr
=
scr
;
super
->
eventHandler
=
AvailableMeters
ListBox
_EventHandler
;
super
->
eventHandler
=
AvailableMeters
Panel
_EventHandler
;
ListBox
_setHeader
(
super
,
"Available meters"
);
Panel
_setHeader
(
super
,
"Available meters"
);
for
(
int
i
=
1
;
Meter_types
[
i
];
i
++
)
{
MeterType
*
type
=
Meter_types
[
i
];
if
(
type
!=
&
CPUMeter
)
{
ListBox
_add
(
super
,
(
Object
*
)
ListItem_new
(
type
->
uiName
,
i
<<
16
));
Panel
_add
(
super
,
(
Object
*
)
ListItem_new
(
type
->
uiName
,
i
<<
16
));
}
}
MeterType
*
type
=
&
CPUMeter
;
int
processors
=
settings
->
pl
->
processorCount
;
if
(
processors
>
1
)
{
ListBox
_add
(
super
,
(
Object
*
)
ListItem_new
(
"CPU average"
,
0
));
Panel
_add
(
super
,
(
Object
*
)
ListItem_new
(
"CPU average"
,
0
));
for
(
int
i
=
1
;
i
<=
processors
;
i
++
)
{
char
buffer
[
50
];
sprintf
(
buffer
,
"%s %d"
,
type
->
uiName
,
i
);
ListBox
_add
(
super
,
(
Object
*
)
ListItem_new
(
buffer
,
i
));
Panel
_add
(
super
,
(
Object
*
)
ListItem_new
(
buffer
,
i
));
}
}
else
{
ListBox
_add
(
super
,
(
Object
*
)
ListItem_new
(
"CPU"
,
1
));
Panel
_add
(
super
,
(
Object
*
)
ListItem_new
(
"CPU"
,
1
));
}
return
this
;
}
void
AvailableMeters
ListBox
_delete
(
Object
*
object
)
{
ListBox
*
super
=
(
ListBox
*
)
object
;
AvailableMeters
ListBox
*
this
=
(
AvailableMeters
ListBox
*
)
object
;
ListBox
_done
(
super
);
void
AvailableMeters
Panel
_delete
(
Object
*
object
)
{
Panel
*
super
=
(
Panel
*
)
object
;
AvailableMeters
Panel
*
this
=
(
AvailableMeters
Panel
*
)
object
;
Panel
_done
(
super
);
free
(
this
);
}
/* private */
inline
void
AvailableMeters
ListBox
_addHeader
(
Header
*
header
,
ListBox
*
lb
,
MeterType
*
type
,
int
param
,
HeaderSide
side
)
{
inline
void
AvailableMeters
Panel
_addHeader
(
Header
*
header
,
Panel
*
lb
,
MeterType
*
type
,
int
param
,
HeaderSide
side
)
{
Meter
*
meter
=
(
Meter
*
)
Header_addMeter
(
header
,
type
,
param
,
side
);
ListBox
_add
(
lb
,
(
Object
*
)
Meter_toListItem
(
meter
));
Panel
_add
(
lb
,
(
Object
*
)
Meter_toListItem
(
meter
));
}
HandlerResult
AvailableMeters
ListBox
_EventHandler
(
ListBox
*
super
,
int
ch
)
{
AvailableMeters
ListBox
*
this
=
(
AvailableMeters
ListBox
*
)
super
;
HandlerResult
AvailableMeters
Panel
_EventHandler
(
Panel
*
super
,
int
ch
)
{
AvailableMeters
Panel
*
this
=
(
AvailableMeters
Panel
*
)
super
;
Header
*
header
=
this
->
settings
->
header
;
ListItem
*
selected
=
(
ListItem
*
)
ListBox
_getSelected
(
super
);
ListItem
*
selected
=
(
ListItem
*
)
Panel
_getSelected
(
super
);
int
param
=
selected
->
key
&
0xff
;
int
type
=
selected
->
key
>>
16
;
HandlerResult
result
=
IGNORED
;
...
...
@@ -83,7 +83,7 @@ HandlerResult AvailableMetersListBox_EventHandler(ListBox* super, int ch) {
case
'l'
:
case
'L'
:
{
AvailableMeters
ListBox
_addHeader
(
header
,
this
->
leftBox
,
Meter_types
[
type
],
param
,
LEFT_HEADER
);
AvailableMeters
Panel
_addHeader
(
header
,
this
->
leftBox
,
Meter_types
[
type
],
param
,
LEFT_HEADER
);
result
=
HANDLED
;
break
;
}
...
...
@@ -91,7 +91,7 @@ HandlerResult AvailableMetersListBox_EventHandler(ListBox* super, int ch) {
case
'r'
:
case
'R'
:
{
AvailableMeters
ListBox
_addHeader
(
header
,
this
->
rightBox
,
Meter_types
[
type
],
param
,
RIGHT_HEADER
);
AvailableMeters
Panel
_addHeader
(
header
,
this
->
rightBox
,
Meter_types
[
type
],
param
,
RIGHT_HEADER
);
result
=
HANDLED
;
break
;
}
...
...
AvailableMetersListBox.h
View file @
c2cdcd0c
/* Do not edit this file. It was automatically genarated. */
#ifndef HEADER_AvailableMeters
ListBox
#define HEADER_AvailableMeters
ListBox
#ifndef HEADER_AvailableMeters
Panel
#define HEADER_AvailableMeters
Panel
#include "Settings.h"
#include "Header.h"
#include "ScreenManager.h"
#include "
ListBox
.h"
#include "
Panel
.h"
#include "debug.h"
#include <assert.h>
typedef
struct
AvailableMeters
ListBox
_
{
ListBox
super
;
typedef
struct
AvailableMeters
Panel
_
{
Panel
super
;
Settings
*
settings
;
ListBox
*
leftBox
;
ListBox
*
rightBox
;
Panel
*
leftBox
;
Panel
*
rightBox
;
ScreenManager
*
scr
;
}
AvailableMeters
ListBox
;
}
AvailableMeters
Panel
;
AvailableMeters
ListBox
*
AvailableMeters
ListBox
_new
(
Settings
*
settings
,
ListBox
*
leftMeters
,
ListBox
*
rightMeters
,
ScreenManager
*
scr
);
AvailableMeters
Panel
*
AvailableMeters
Panel
_new
(
Settings
*
settings
,
Panel
*
leftMeters
,
Panel
*
rightMeters
,
ScreenManager
*
scr
);
void
AvailableMeters
ListBox
_delete
(
Object
*
object
);
void
AvailableMeters
Panel
_delete
(
Object
*
object
);
HandlerResult
AvailableMeters
ListBox
_EventHandler
(
ListBox
*
super
,
int
ch
);
HandlerResult
AvailableMeters
Panel
_EventHandler
(
Panel
*
super
,
int
ch
);
#endif
CategoriesListBox.c
View file @
c2cdcd0c
#include "Categories
ListBox
.h"
#include "AvailableMeters
ListBox
.h"
#include "Meters
ListBox
.h"
#include "DisplayOptions
ListBox
.h"
#include "Columns
ListBox
.h"
#include "Colors
ListBox
.h"
#include "AvailableColumns
ListBox
.h"
#include "Categories
Panel
.h"
#include "AvailableMeters
Panel
.h"
#include "Meters
Panel
.h"
#include "DisplayOptions
Panel
.h"
#include "Columns
Panel
.h"
#include "Colors
Panel
.h"
#include "AvailableColumns
Panel
.h"
#include "
ListBox
.h"
#include "
Panel
.h"
#include "debug.h"
#include <assert.h>
/*{
typedef struct Categories
ListBox
_ {
ListBox
super;
typedef struct Categories
Panel
_ {
Panel
super;
Settings* settings;
ScreenManager* scr;
} Categories
ListBox
;
} Categories
Panel
;
}*/
...
...
@@ -41,36 +41,36 @@ char* ColorsFunctions[10] = {" ", " ", " ", " ", " ", "
/* private property */
char
*
AvailableColumnsFunctions
[
10
]
=
{
" "
,
" "
,
" "
,
" "
,
"Add "
,
" "
,
" "
,
" "
,
" "
,
"Done "
};
Categories
ListBox
*
Categories
ListBox
_new
(
Settings
*
settings
,
ScreenManager
*
scr
)
{
Categories
ListBox
*
this
=
(
Categories
ListBox
*
)
malloc
(
sizeof
(
Categories
ListBox
));
ListBox
*
super
=
(
ListBox
*
)
this
;
ListBox
_init
(
super
,
1
,
1
,
1
,
1
,
LISTITEM_CLASS
,
true
);
((
Object
*
)
this
)
->
delete
=
Categories
ListBox
_delete
;
Categories
Panel
*
Categories
Panel
_new
(
Settings
*
settings
,
ScreenManager
*
scr
)
{
Categories
Panel
*
this
=
(
Categories
Panel
*
)
malloc
(
sizeof
(
Categories
Panel
));
Panel
*
super
=
(
Panel
*
)
this
;
Panel
_init
(
super
,
1
,
1
,
1
,
1
,
LISTITEM_CLASS
,
true
);
((
Object
*
)
this
)
->
delete
=
Categories
Panel
_delete
;
this
->
settings
=
settings
;
this
->
scr
=
scr
;
super
->
eventHandler
=
Categories
ListBox
_eventHandler
;
ListBox
_setHeader
(
super
,
"Setup"
);
ListBox
_add
(
super
,
(
Object
*
)
ListItem_new
(
"Meters"
,
0
));
ListBox
_add
(
super
,
(
Object
*
)
ListItem_new
(
"Display options"
,
0
));
ListBox
_add
(
super
,
(
Object
*
)
ListItem_new
(
"Colors"
,
0
));
ListBox
_add
(
super
,
(
Object
*
)
ListItem_new
(
"Columns"
,
0
));
super
->
eventHandler
=
Categories
Panel
_eventHandler
;
Panel
_setHeader
(
super
,
"Setup"
);
Panel
_add
(
super
,
(
Object
*
)
ListItem_new
(
"Meters"
,
0
));
Panel
_add
(
super
,
(
Object
*
)
ListItem_new
(
"Display options"
,
0
));
Panel
_add
(
super
,
(
Object
*
)
ListItem_new
(
"Colors"
,
0
));
Panel
_add
(
super
,
(
Object
*
)
ListItem_new
(
"Columns"
,
0
));
return
this
;
}
void
Categories
ListBox
_delete
(
Object
*
object
)
{
ListBox
*
super
=
(
ListBox
*
)
object
;
Categories
ListBox
*
this
=
(
Categories
ListBox
*
)
object
;
ListBox
_done
(
super
);
void
Categories
Panel
_delete
(
Object
*
object
)
{
Panel
*
super
=
(
Panel
*
)
object
;
Categories
Panel
*
this
=
(
Categories
Panel
*
)
object
;
Panel
_done
(
super
);
free
(
this
);
}
HandlerResult
Categories
ListBox
_eventHandler
(
ListBox
*
super
,
int
ch
)
{
Categories
ListBox
*
this
=
(
Categories
ListBox
*
)
super
;
HandlerResult
Categories
Panel
_eventHandler
(
Panel
*
super
,
int
ch
)
{
Categories
Panel
*
this
=
(
Categories
Panel
*
)
super
;
HandlerResult
result
=
IGNORED
;
int
previous
=
ListBox
_getSelectedIndex
(
super
);
int
previous
=
Panel
_getSelectedIndex
(
super
);
switch
(
ch
)
{
case
KEY_UP
:
...
...
@@ -79,24 +79,24 @@ HandlerResult CategoriesListBox_eventHandler(ListBox* super, int ch) {
case
KEY_PPAGE
:
case
KEY_HOME
:
case
KEY_END
:
{
ListBox
_onKey
(
super
,
ch
);
int
selected
=
ListBox
_getSelectedIndex
(
super
);
Panel
_onKey
(
super
,
ch
);
int
selected
=
Panel
_getSelectedIndex
(
super
);
if
(
previous
!=
selected
)
{
int
size
=
ScreenManager_size
(
this
->
scr
);
for
(
int
i
=
1
;
i
<
size
;
i
++
)
ScreenManager_remove
(
this
->
scr
,
1
);
switch
(
selected
)
{
case
0
:
Categories
ListBox
_makeMetersPage
(
this
);
Categories
Panel
_makeMetersPage
(
this
);
break
;
case
1
:
Categories
ListBox
_makeDisplayOptionsPage
(
this
);
Categories
Panel
_makeDisplayOptionsPage
(
this
);
break
;
case
2
:
Categories
ListBox
_makeColorsPage
(
this
);
Categories
Panel
_makeColorsPage
(
this
);
break
;
case
3
:
Categories
ListBox
_makeColumnsPage
(
this
);
Categories
Panel
_makeColumnsPage
(
this
);
break
;
}
}
...
...
@@ -107,28 +107,28 @@ HandlerResult CategoriesListBox_eventHandler(ListBox* super, int ch) {
return
result
;
}
void
Categories
ListBox
_makeMetersPage
(
Categories
ListBox
*
this
)
{
ListBox
*
lbLeftMeters
=
(
ListBox
*
)
Meters
ListBox
_new
(
this
->
settings
,
"Left column"
,
this
->
settings
->
header
->
leftMeters
,
this
->
scr
);
ListBox
*
lbRightMeters
=
(
ListBox
*
)
Meters
ListBox
_new
(
this
->
settings
,
"Right column"
,
this
->
settings
->
header
->
rightMeters
,
this
->
scr
);
ListBox
*
lbAvailableMeters
=
(
ListBox
*
)
AvailableMeters
ListBox
_new
(
this
->
settings
,
lbLeftMeters
,
lbRightMeters
,
this
->
scr
);
void
Categories
Panel
_makeMetersPage
(
Categories
Panel
*
this
)
{
Panel
*
lbLeftMeters
=
(
Panel
*
)
Meters
Panel
_new
(
this
->
settings
,
"Left column"
,
this
->
settings
->
header
->
leftMeters
,
this
->
scr
);
Panel
*
lbRightMeters
=
(
Panel
*
)
Meters
Panel
_new
(
this
->
settings
,
"Right column"
,
this
->
settings
->
header
->
rightMeters
,
this
->
scr
);
Panel
*
lbAvailableMeters
=
(
Panel
*
)
AvailableMeters
Panel
_new
(
this
->
settings
,
lbLeftMeters
,
lbRightMeters
,
this
->
scr
);
ScreenManager_add
(
this
->
scr
,
lbLeftMeters
,
FunctionBar_new
(
10
,
MetersFunctions
,
NULL
,
NULL
),
20
);
ScreenManager_add
(
this
->
scr
,
lbRightMeters
,
FunctionBar_new
(
10
,
MetersFunctions
,
NULL
,
NULL
),
20
);
ScreenManager_add
(
this
->
scr
,
lbAvailableMeters
,
FunctionBar_new
(
10
,
AvailableMetersFunctions
,
NULL
,
NULL
),
-
1
);
}
void
Categories
ListBox
_makeDisplayOptionsPage
(
Categories
ListBox
*
this
)
{
ListBox
*
lbDisplayOptions
=
(
ListBox
*
)
DisplayOptions
ListBox
_new
(
this
->
settings
,
this
->
scr
);
void
Categories
Panel
_makeDisplayOptionsPage
(
Categories
Panel
*
this
)
{
Panel
*
lbDisplayOptions
=
(
Panel
*
)
DisplayOptions
Panel
_new
(
this
->
settings
,
this
->
scr
);
ScreenManager_add
(
this
->
scr
,
lbDisplayOptions
,
FunctionBar_new
(
10
,
DisplayOptionsFunctions
,
NULL
,
NULL
),
-
1
);
}
void
Categories
ListBox
_makeColorsPage
(
Categories
ListBox
*
this
)
{
ListBox
*
lbColors
=
(
ListBox
*
)
Colors
ListBox
_new
(
this
->
settings
,
this
->
scr
);
void
Categories
Panel
_makeColorsPage
(
Categories
Panel
*
this
)
{
Panel
*
lbColors
=
(
Panel
*
)
Colors
Panel
_new
(
this
->
settings
,
this
->
scr
);
ScreenManager_add
(
this
->
scr
,
lbColors
,
FunctionBar_new
(
10
,
ColorsFunctions
,
NULL
,
NULL
),
-
1
);
}
void
Categories
ListBox
_makeColumnsPage
(
Categories
ListBox
*
this
)
{
ListBox
*
lbColumns
=
(
ListBox
*
)
Columns
ListBox
_new
(
this
->
settings
,
this
->
scr
);
ListBox
*
lbAvailableColumns
=
(
ListBox
*
)
AvailableColumns
ListBox
_new
(
this
->
settings
,
lbColumns
,
this
->
scr
);
void
Categories
Panel
_makeColumnsPage
(
Categories
Panel
*
this
)
{
Panel
*
lbColumns
=
(
Panel
*
)
Columns
Panel
_new
(
this
->
settings
,
this
->
scr
);
Panel
*
lbAvailableColumns
=
(
Panel
*
)
AvailableColumns
Panel
_new
(
this
->
settings
,
lbColumns
,
this
->
scr
);
ScreenManager_add
(
this
->
scr
,
lbColumns
,
FunctionBar_new
(
10
,
ColumnsFunctions
,
NULL
,
NULL
),
20
);
ScreenManager_add
(
this
->
scr
,
lbAvailableColumns
,
FunctionBar_new
(
10
,
AvailableColumnsFunctions
,
NULL
,
NULL
),
-
1
);
}
CategoriesListBox.h
View file @
c2cdcd0c
/* Do not edit this file. It was automatically genarated. */
#ifndef HEADER_Categories
ListBox
#define HEADER_Categories
ListBox
#ifndef HEADER_Categories
Panel
#define HEADER_Categories
Panel
#include "AvailableMeters
ListBox
.h"
#include "Meters
ListBox
.h"
#include "DisplayOptions
ListBox
.h"
#include "AvailableMeters
Panel
.h"
#include "Meters
Panel
.h"
#include "DisplayOptions
Panel
.h"
#include "
ListBox
.h"
#include "
Panel
.h"
#include "debug.h"
#include <assert.h>
typedef
struct
Categories
ListBox
_
{
ListBox
super
;
typedef
struct
Categories
Panel
_
{
Panel
super
;
Settings
*
settings
;
ScreenManager
*
scr
;
}
Categories
ListBox
;
}
Categories
Panel
;
Categories
ListBox
*
Categories
ListBox
_new
(
Settings
*
settings
,
ScreenManager
*
scr
);
Categories
Panel
*
Categories
Panel
_new
(
Settings
*
settings
,
ScreenManager
*
scr
);
void
Categories
ListBox
_delete
(
Object
*
object
);
void
Categories
Panel
_delete
(
Object
*
object
);
HandlerResult
Categories
ListBox
_eventHandler
(
ListBox
*
super
,
int
ch
);
HandlerResult
Categories
Panel
_eventHandler
(
Panel
*
super
,
int
ch
);
void
Categories
ListBox
_makeMetersPage
(
Categories
ListBox
*
this
);
void
Categories
Panel
_makeMetersPage
(
Categories
Panel
*
this
);
void
Categories
ListBox
_makeDisplayOptionsPage
(
Categories
ListBox
*
this
);
void
Categories
Panel
_makeDisplayOptionsPage
(
Categories
Panel
*
this
);
void
Categories
ListBox
_makeColorsPage
(
Categories
ListBox
*
this
);
void
Categories
Panel
_makeColorsPage
(
Categories
Panel
*
this
);
void
Categories
ListBox
_makeColumnsPage
(
Categories
ListBox
*
this
);
void
Categories
Panel
_makeColumnsPage
(
Categories
Panel
*
this
);
#endif
ChangeLog
View file @
c2cdcd0c
...
...
@@ -137,7 +137,7 @@ What's new in version 0.4
* Clock and load average meters
(thanks to Marc Calahan)
* BUGFIX: numeric swap indicator was printing bogus value
* BUGFIX: internal fixes on
ListBox
widget
* BUGFIX: internal fixes on
Panel
widget
* Clear the bottom line when exiting
* Press "F3" during search to walk through the results
* Improved navigation on column configuration screen
...
...
ColorsListBox.c
View file @
c2cdcd0c
#include "CRT.h"
#include "Colors
ListBox
.h"
#include "Colors
Panel
.h"
#include "
ListBox
.h"
#include "
Panel
.h"
#include "CheckItem.h"
#include "Settings.h"
#include "ScreenManager.h"
...
...
@@ -11,20 +11,20 @@
#include <assert.h>
// TO ADD A NEW SCHEME:
// * Increment the size of bool check in Colors
ListBox
.h
// * Increment the size of bool check in Colors
Panel
.h
// * Add the entry in the ColorSchemes array below in the file
// * Add a define in CRT.h that matches the order of the array
// * Add the colors in CRT_setColors
/*{
typedef struct Colors
ListBox
_ {
ListBox
super;
typedef struct Colors
Panel
_ {
Panel
super;
Settings* settings;
ScreenManager* scr;
bool check[5];
} Colors
ListBox
;
} Colors
Panel
;
}*/
...
...
@@ -39,37 +39,37 @@ static char* ColorSchemes[] = {
NULL
};
Colors
ListBox
*
Colors
ListBox
_new
(
Settings
*
settings
,
ScreenManager
*
scr
)
{
Colors
ListBox
*
this
=
(
Colors
ListBox
*
)
malloc
(
sizeof
(
Colors
ListBox
));
ListBox
*
super
=
(
ListBox
*
)
this
;
ListBox
_init
(
super
,
1
,
1
,
1
,
1
,
CHECKITEM_CLASS
,
true
);
((
Object
*
)
this
)
->
delete
=
Colors
ListBox
_delete
;
Colors
Panel
*
Colors
Panel
_new
(
Settings
*
settings
,
ScreenManager
*
scr
)
{
Colors
Panel
*
this
=
(
Colors
Panel
*
)
malloc
(
sizeof
(
Colors
Panel
));
Panel
*
super
=
(
Panel
*
)
this
;
Panel
_init
(
super
,
1
,
1
,
1
,
1
,
CHECKITEM_CLASS
,
true
);
((
Object
*
)
this
)
->
delete
=
Colors
Panel
_delete
;
this
->
settings
=
settings
;
this
->
scr
=
scr
;
super
->
eventHandler
=
Colors
ListBox
_EventHandler
;
super
->
eventHandler
=
Colors
Panel
_EventHandler
;
ListBox
_setHeader
(
super
,
"Colors"
);
Panel
_setHeader
(
super
,
"Colors"
);
for
(
int
i
=
0
;
ColorSchemes
[
i
]
!=
NULL
;
i
++
)
{
ListBox
_add
(
super
,
(
Object
*
)
CheckItem_new
(
String_copy
(
ColorSchemes
[
i
]),
&
(
this
->
check
[
i
])));
Panel
_add
(
super
,
(
Object
*
)
CheckItem_new
(
String_copy
(
ColorSchemes
[
i
]),
&
(
this
->
check
[
i
])));
this
->
check
[
i
]
=
false
;
}
this
->
check
[
settings
->
colorScheme
]
=
true
;
return
this
;
}
void
Colors
ListBox
_delete
(
Object
*
object
)
{
ListBox
*
super
=
(
ListBox
*
)
object
;
Colors
ListBox
*
this
=
(
Colors
ListBox
*
)
object
;
ListBox
_done
(
super
);
void
Colors
Panel
_delete
(
Object
*
object
)
{
Panel
*
super
=
(
Panel
*
)
object
;
Colors
Panel
*
this
=
(
Colors
Panel
*
)
object
;
Panel
_done
(
super
);
free
(
this
);
}
HandlerResult
Colors
ListBox
_EventHandler
(
ListBox
*
super
,
int
ch
)
{
Colors
ListBox
*
this
=
(
Colors
ListBox
*
)
super
;
HandlerResult
Colors
Panel
_EventHandler
(
Panel
*
super
,
int
ch
)
{
Colors
Panel
*
this
=
(
Colors
Panel
*
)
super
;
HandlerResult
result
=
IGNORED
;
int
mark
=
ListBox
_getSelectedIndex
(
super
);
int
mark
=
Panel
_getSelectedIndex
(
super
);
switch
(
ch
)
{
case
0x0a
:
...
...
@@ -88,7 +88,7 @@ HandlerResult ColorsListBox_EventHandler(ListBox* super, int ch) {
this
->
settings
->
changed
=
true
;
Header
*
header
=
this
->
settings
->
header
;
CRT_setColors
(
mark
);
ListBox
*
lbMenu
=
(
ListBox
*
)
Vector_get
(
this
->
scr
->
items
,
0
);
Panel
*
lbMenu
=
(
Panel
*
)
Vector_get
(
this
->
scr
->
items
,
0
);
Header_draw
(
header
);
RichString_setAttr
(
&
(
super
->
header
),
CRT_colors
[
PANEL_HEADER_FOCUS
]);
RichString_setAttr
(
&
(
lbMenu
->
header
),
CRT_colors
[
PANEL_HEADER_UNFOCUS
]);
...
...
ColorsListBox.h
View file @
c2cdcd0c
/* Do not edit this file. It was automatically genarated. */
#ifndef HEADER_Colors
ListBox
#define HEADER_Colors
ListBox
#ifndef HEADER_Colors
Panel
#define HEADER_Colors
Panel
#include "
ListBox
.h"
#include "
Panel
.h"
#include "CheckItem.h"
#include "Settings.h"
#include "ScreenManager.h"
...
...
@@ -13,20 +13,20 @@
#include <assert.h>
typedef
struct
Colors
ListBox
_
{
ListBox
super
;
typedef
struct
Colors
Panel
_
{
Panel
super
;
Settings
*
settings
;
ScreenManager
*
scr
;
bool
check
[
5
];
}
Colors
ListBox
;
}
Colors
Panel
;
Colors
ListBox
*
Colors
ListBox
_new
(
Settings
*
settings
,
ScreenManager
*
scr
);
Colors
Panel
*
Colors
Panel
_new
(
Settings
*
settings
,
ScreenManager
*
scr
);
void
Colors
ListBox
_delete
(
Object
*
object
);
void
Colors
Panel
_delete
(
Object
*
object
);
HandlerResult
Colors
ListBox
_EventHandler
(
ListBox
*
super
,
int
ch
);
HandlerResult
Colors
Panel
_EventHandler
(
Panel
*
super
,
int
ch
);
#endif
ColumnsListBox.c
View file @
c2cdcd0c
#include "Columns
ListBox
.h"
#include "Columns
Panel
.h"
#include "
ListBox
.h"
#include "
Panel
.h"
#include "Settings.h"
#include "ScreenManager.h"
...
...
@@ -10,49 +10,49 @@
/*{
typedef struct Columns
ListBox
_ {
ListBox
super;
typedef struct Columns
Panel
_ {
Panel
super;
Settings* settings;
ScreenManager* scr;
} Columns
ListBox
;
} Columns
Panel
;
}*/
Columns
ListBox
*
Columns
ListBox
_new
(
Settings
*
settings
,
ScreenManager
*
scr
)
{
Columns
ListBox
*
this
=
(
Columns
ListBox
*
)
malloc
(
sizeof
(
Columns
ListBox
));
ListBox
*
super
=
(
ListBox
*
)
this
;
ListBox
_init
(
super
,
1
,
1
,
1
,
1
,
LISTITEM_CLASS
,
true
);
((
Object
*
)
this
)
->
delete
=
Columns
ListBox
_delete
;
Columns
Panel
*
Columns
Panel
_new
(
Settings
*
settings
,
ScreenManager
*
scr
)
{
Columns
Panel
*
this
=
(
Columns
Panel
*
)
malloc
(
sizeof
(
Columns
Panel
));
Panel
*
super
=
(
Panel
*
)
this
;
Panel
_init
(
super
,
1
,
1
,
1
,
1
,
LISTITEM_CLASS
,
true
);
((
Object
*
)
this
)
->
delete
=
Columns
Panel
_delete
;
this
->
settings
=
settings
;
this
->
scr
=
scr
;
super
->
eventHandler
=
Columns
ListBox
_eventHandler
;
ListBox
_setHeader
(
super
,
"Active Columns"
);
super
->
eventHandler
=
Columns
Panel
_eventHandler
;
Panel
_setHeader
(
super
,
"Active Columns"
);
ProcessField
*
fields
=
this
->
settings
->
pl
->
fields
;
for
(;
*
fields
;
fields
++
)
{
ListBox
_add
(
super
,
(
Object
*
)
ListItem_new
(
Process_fieldNames
[
*
fields
],
0
));
Panel
_add
(
super
,
(
Object
*
)
ListItem_new
(
Process_fieldNames
[
*
fields
],
0
));
}
return
this
;
}
void
Columns
ListBox
_delete
(
Object
*
object
)
{
ListBox
*
super
=
(
ListBox
*
)
object
;
Columns
ListBox
*
this
=
(
Columns
ListBox
*
)
object
;
ListBox
_done
(
super
);
void
Columns
Panel
_delete
(
Object
*
object
)
{
Panel
*
super
=
(
Panel
*
)
object
;
Columns
Panel
*
this
=
(
Columns
Panel
*
)
object
;
Panel
_done
(
super
);
free
(
this
);
}
void
Columns
ListBox
_update
(
ListBox
*
super
)
{
Columns
ListBox
*
this
=
(
Columns
ListBox
*
)
super
;
int
size
=
ListBox
_getSize
(
super
);
void
Columns
Panel
_update
(
Panel
*
super
)
{
Columns
Panel
*
this
=
(
Columns
Panel
*
)
super
;
int
size
=
Panel
_getSize
(
super
);
this
->
settings
->
changed
=
true
;
// FIXME: this is crappily inefficient
free
(
this
->
settings
->
pl
->
fields
);
this
->
settings
->
pl
->
fields
=
(
ProcessField
*
)
malloc
(
sizeof
(
ProcessField
)
*
(
size
+
1
));
for
(
int
i
=
0
;
i
<
size
;
i
++
)
{
char
*
text
=
((
ListItem
*
)
ListBox
_get
(
super
,
i
))
->
value
;
char
*
text
=
((
ListItem
*
)
Panel
_get
(
super
,
i
))
->
value
;
for
(
int
j
=
1
;
j
<=
LAST_PROCESSFIELD
;
j
++
)
{
if
(
String_eq
(
text
,
Process_fieldNames
[
j
]))
{
this
->
settings
->
pl
->
fields
[
i
]
=
j
;
...
...
@@ -63,11 +63,11 @@ void ColumnsListBox_update(ListBox* super) {
this
->
settings
->
pl
->
fields
[
size
]
=
0
;
}
HandlerResult
Columns
ListBox
_eventHandler
(
ListBox
*
super
,
int
ch
)
{
HandlerResult
Columns
Panel
_eventHandler
(
Panel
*
super
,
int
ch
)
{
int
selected
=
ListBox
_getSelectedIndex
(
super
);
int
selected
=
Panel
_getSelectedIndex
(
super
);
HandlerResult
result
=
IGNORED
;
int
size
=
ListBox
_getSize
(
super
);
int
size
=
Panel
_getSize
(
super
);
switch
(
ch
)
{
case
KEY_F
(
7
):
...
...
@@ -75,7 +75,7 @@ HandlerResult ColumnsListBox_eventHandler(ListBox* super, int ch) {
case
'-'
:
{
if
(
selected
<
size
-
1
)
ListBox
_moveSelectedUp
(
super
);
Panel
_moveSelectedUp
(
super
);
result
=
HANDLED
;
break
;
}
...
...
@@ -84,7 +84,7 @@ HandlerResult ColumnsListBox_eventHandler(ListBox* super, int ch) {
case
'+'
:
{
if
(
selected
<
size
-
2
)
ListBox
_moveSelectedDown
(
super
);
Panel
_moveSelectedDown
(
super
);
result
=
HANDLED
;
break
;
}
...
...
@@ -92,13 +92,13 @@ HandlerResult ColumnsListBox_eventHandler(ListBox* super, int ch) {
case
KEY_DC
:
{
if
(
selected
<
size
-
1
)
{
ListBox
_remove
(
super
,
selected
);
Panel
_remove
(
super
,
selected
);
}
result
=
HANDLED
;
break
;
}
}
if
(
result
==
HANDLED
)
Columns
ListBox
_update
(
super
);
Columns
Panel
_update
(
super
);
return
result
;
}
ColumnsListBox.h
View file @
c2cdcd0c
/* Do not edit this file. It was automatically genarated. */
#ifndef HEADER_Columns
ListBox
#define HEADER_Columns
ListBox
#ifndef HEADER_Columns
Panel
#define HEADER_Columns
Panel
#include "
ListBox
.h"
#include "
Panel
.h"
#include "Settings.h"
#include "ScreenManager.h"
...
...
@@ -12,21 +12,21 @@
#include <assert.h>
typedef
struct
Columns
ListBox
_
{
ListBox
super
;
typedef
struct
Columns
Panel
_
{
Panel
super
;
Settings
*
settings
;
Vector
*
columns
;
ScreenManager
*
scr
;
}
Columns
ListBox
;
}
Columns
Panel
;
Columns
ListBox
*
Columns
ListBox
_new
(
Settings
*
settings
,
ScreenManager
*
scr
);
Columns
Panel
*
Columns
Panel
_new
(
Settings
*
settings
,
ScreenManager
*
scr
);
void
Columns
ListBox
_delete
(
Object
*
object
);
void
Columns
Panel
_delete
(
Object
*
object
);
void
Columns
ListBox
_update
(
ListBox
*
super
);
void
Columns
Panel
_update
(
Panel
*
super
);
HandlerResult
Columns
ListBox
_eventHandler
(
ListBox
*
super
,
int
ch
);
HandlerResult
Columns
Panel
_eventHandler
(
Panel
*
super
,
int
ch
);
#endif
DisplayOptionsListBox.c
View file @
c2cdcd0c
#include "DisplayOptions
ListBox
.h"
#include "DisplayOptions
Panel
.h"
#include "
ListBox
.h"
#include "
Panel
.h"
#include "CheckItem.h"
#include "Settings.h"
#include "ScreenManager.h"
...
...
@@ -11,48 +11,48 @@
/*{
typedef struct DisplayOptions
ListBox
_ {
ListBox
super;
typedef struct DisplayOptions
Panel
_ {
Panel
super;
Settings* settings;
ScreenManager* scr;
} DisplayOptions
ListBox
;
} DisplayOptions
Panel
;
}*/
DisplayOptions
ListBox
*
DisplayOptions
ListBox
_new
(
Settings
*
settings
,
ScreenManager
*
scr
)
{
DisplayOptions
ListBox
*
this
=
(
DisplayOptions
ListBox
*
)
malloc
(
sizeof
(
DisplayOptions
ListBox
));
ListBox
*
super
=
(
ListBox
*
)
this
;
ListBox
_init
(
super
,
1
,
1
,
1
,
1
,
CHECKITEM_CLASS
,
true
);
((
Object
*
)
this
)
->
delete
=
DisplayOptions
ListBox
_delete
;
DisplayOptions
Panel
*
DisplayOptions
Panel
_new
(
Settings
*
settings
,
ScreenManager
*
scr
)
{
DisplayOptions
Panel
*
this
=
(
DisplayOptions
Panel
*
)
malloc
(
sizeof
(
DisplayOptions
Panel
));
Panel
*
super
=
(
Panel
*
)
this
;
Panel
_init
(
super
,
1
,
1
,
1
,
1
,
CHECKITEM_CLASS
,
true
);
((
Object
*
)
this
)
->
delete
=
DisplayOptions
Panel
_delete
;
this
->
settings
=
settings
;
this
->
scr
=
scr
;
super
->
eventHandler
=
DisplayOptions
ListBox
_EventHandler
;
ListBox
_setHeader
(
super
,
"Display options"
);
ListBox
_add
(
super
,
(
Object
*
)
CheckItem_new
(
String_copy
(
"Tree view"
),
&
(
settings
->
pl
->
treeView
)));
ListBox
_add
(
super
,
(
Object
*
)
CheckItem_new
(
String_copy
(
"Shadow other users' processes"
),
&
(
settings
->
pl
->
shadowOtherUsers
)));
ListBox
_add
(
super
,
(
Object
*
)
CheckItem_new
(
String_copy
(
"Hide kernel threads"
),
&
(
settings
->
pl
->
hideKernelThreads
)));
ListBox
_add
(
super
,
(
Object
*
)
CheckItem_new
(
String_copy
(
"Hide userland threads"
),
&
(
settings
->
pl
->
hideUserlandThreads
)));
ListBox
_add
(
super
,
(
Object
*
)
CheckItem_new
(
String_copy
(
"Highlight program
\"
basename
\"
"
),
&
(
settings
->
pl
->
highlightBaseName
)));
ListBox
_add
(
super
,
(
Object
*
)
CheckItem_new
(
String_copy
(
"Highlight megabytes in memory counters"
),
&
(
settings
->
pl
->
highlightMegabytes
)));
ListBox
_add
(
super
,
(
Object
*
)
CheckItem_new
(
String_copy
(
"Leave a margin around header"
),
&
(
settings
->
header
->
margin
)));
super
->
eventHandler
=
DisplayOptions
Panel
_EventHandler
;
Panel
_setHeader
(
super
,
"Display options"
);
Panel
_add
(
super
,
(
Object
*
)
CheckItem_new
(
String_copy
(
"Tree view"
),
&
(
settings
->
pl
->
treeView
)));
Panel
_add
(
super
,
(
Object
*
)
CheckItem_new
(
String_copy
(
"Shadow other users' processes"
),
&
(
settings
->
pl
->
shadowOtherUsers
)));
Panel
_add
(
super
,
(
Object
*
)
CheckItem_new
(
String_copy
(
"Hide kernel threads"
),
&
(
settings
->
pl
->
hideKernelThreads
)));
Panel
_add
(
super
,
(
Object
*
)
CheckItem_new
(
String_copy
(
"Hide userland threads"
),
&
(
settings
->
pl
->
hideUserlandThreads
)));
Panel
_add
(
super
,
(
Object
*
)
CheckItem_new
(
String_copy
(
"Highlight program
\"
basename
\"
"
),
&
(
settings
->
pl
->
highlightBaseName
)));
Panel
_add
(
super
,
(
Object
*
)
CheckItem_new
(
String_copy
(
"Highlight megabytes in memory counters"
),
&
(
settings
->
pl
->
highlightMegabytes
)));
Panel
_add
(
super
,
(
Object
*
)
CheckItem_new
(
String_copy
(
"Leave a margin around header"
),
&
(
settings
->
header
->
margin
)));
return
this
;
}
void
DisplayOptions
ListBox
_delete
(
Object
*
object
)
{
ListBox
*
super
=
(
ListBox
*
)
object
;
DisplayOptions
ListBox
*
this
=
(
DisplayOptions
ListBox
*
)
object
;
ListBox
_done
(
super
);
void
DisplayOptions
Panel
_delete
(
Object
*
object
)
{
Panel
*
super
=
(
Panel
*
)
object
;
DisplayOptions
Panel
*
this
=
(
DisplayOptions
Panel
*
)
object
;
Panel
_done
(
super
);
free
(
this
);
}
HandlerResult
DisplayOptions
ListBox
_EventHandler
(
ListBox
*
super
,
int
ch
)
{
DisplayOptions
ListBox
*
this
=
(
DisplayOptions
ListBox
*
)
super
;
HandlerResult
DisplayOptions
Panel
_EventHandler
(
Panel
*
super
,
int
ch
)
{
DisplayOptions
Panel
*
this
=
(
DisplayOptions
Panel
*
)
super
;
HandlerResult
result
=
IGNORED
;
CheckItem
*
selected
=
(
CheckItem
*
)
ListBox
_getSelected
(
super
);
CheckItem
*
selected
=
(
CheckItem
*
)
Panel
_getSelected
(
super
);
switch
(
ch
)
{
case
0x0a
:
...
...
DisplayOptionsListBox.h
View file @
c2cdcd0c
/* Do not edit this file. It was automatically genarated. */
#ifndef HEADER_DisplayOptions
ListBox
#define HEADER_DisplayOptions
ListBox
#ifndef HEADER_DisplayOptions
Panel
#define HEADER_DisplayOptions
Panel
#include "
ListBox
.h"
#include "
Panel
.h"
#include "CheckItem.h"
#include "Settings.h"
#include "ScreenManager.h"
...
...
@@ -13,19 +13,19 @@
#include <assert.h>
typedef
struct
DisplayOptions
ListBox
_
{
ListBox
super
;
typedef
struct
DisplayOptions
Panel
_
{
Panel
super
;
Settings
*
settings
;
ScreenManager
*
scr
;
}
DisplayOptions
ListBox
;
}
DisplayOptions
Panel
;
DisplayOptions
ListBox
*
DisplayOptions
ListBox
_new
(
Settings
*
settings
,
ScreenManager
*
scr
);
DisplayOptions
Panel
*
DisplayOptions
Panel
_new
(
Settings
*
settings
,
ScreenManager
*
scr
);
void
DisplayOptions
ListBox
_delete
(
Object
*
object
);
void
DisplayOptions
Panel
_delete
(
Object
*
object
);
HandlerResult
DisplayOptions
ListBox
_EventHandler
(
ListBox
*
super
,
int
ch
);
HandlerResult
DisplayOptions
Panel
_EventHandler
(
Panel
*
super
,
int
ch
);
#endif
Makefile.am
View file @
c2cdcd0c
...
...
@@ -10,22 +10,22 @@ pixmap_DATA = htop.png
AM_CFLAGS
=
-pedantic
-Wall
-std
=
c99
AM_CPPFLAGS
=
-DSYSCONFDIR
=
\"
$(sysconfdir)
\"
htop_SOURCES
=
AvailableMeters
ListBox
.c Categories
ListBox
.c ClockMeter.c
\
CPUMeter.c CRT.c DebugMemory.c DisplayOptions
ListBox
.c FunctionBar.c
\
Hashtable.c Header.c htop.c
ListBox
.c ListItem.c LoadAverageMeter.c
\
MemoryMeter.c Meter.c Meters
ListBox
.c Object.c Process.c
\
htop_SOURCES
=
AvailableMeters
Panel
.c Categories
Panel
.c ClockMeter.c
\
CPUMeter.c CRT.c DebugMemory.c DisplayOptions
Panel
.c FunctionBar.c
\
Hashtable.c Header.c htop.c
Panel
.c ListItem.c LoadAverageMeter.c
\
MemoryMeter.c Meter.c Meters
Panel
.c Object.c Process.c
\
ProcessList.c RichString.c ScreenManager.c Settings.c SignalItem.c
\
Signals
ListBox
.c String.c SwapMeter.c TasksMeter.c Vector.c
\
UptimeMeter.c UsersTable.c AvailableMeters
ListBox
.h Categories
ListBox
.h
\
Signals
Panel
.c String.c SwapMeter.c TasksMeter.c Vector.c
\
UptimeMeter.c UsersTable.c AvailableMeters
Panel
.h Categories
Panel
.h
\
ClockMeter.h config.h CPUMeter.h CRT.h debug.h DebugMemory.h
\
DisplayOptions
ListBox
.h FunctionBar.h Hashtable.h Header.h htop.h
ListBox
.h
\
DisplayOptions
Panel
.h FunctionBar.h Hashtable.h Header.h htop.h
Panel
.h
\
ListItem.h LoadAverageMeter.h MemoryMeter.h Meter.h
\
Meters
ListBox
.h Object.h Process.h ProcessList.h RichString.h ScreenManager.h
\
Settings.h SignalItem.h Signals
ListBox
.h String.h SwapMeter.h TasksMeter.h
\
Meters
Panel
.h Object.h Process.h ProcessList.h RichString.h ScreenManager.h
\
Settings.h SignalItem.h Signals
Panel
.h String.h SwapMeter.h TasksMeter.h
\
Vector.h UptimeMeter.h UsersTable.h CheckItem.c CheckItem.h
\
Colors
ListBox
.c Colors
ListBox
.h TraceScreen.c TraceScreen.h
\
AvailableColumns
ListBox
.c AvailableColumns
ListBox
.h Columns
ListBox
.c
\
Columns
ListBox
.h
Colors
Panel
.c Colors
Panel
.h TraceScreen.c TraceScreen.h
\
AvailableColumns
Panel
.c AvailableColumns
Panel
.h Columns
Panel
.c
\
Columns
Panel
.h
debug
:
$(MAKE)
all
CFLAGS
=
"-g -DDEBUG"
MetersListBox.c
View file @
c2cdcd0c
#include "Meters
ListBox
.h"
#include "Meters
Panel
.h"
#include "
ListBox
.h"
#include "
Panel
.h"
#include "Settings.h"
#include "ScreenManager.h"
...
...
@@ -10,45 +10,45 @@
/*{
typedef struct Meters
ListBox
_ {
ListBox
super;
typedef struct Meters
Panel
_ {
Panel
super;
Settings* settings;
Vector* meters;
ScreenManager* scr;
} Meters
ListBox
;
} Meters
Panel
;
}*/
Meters
ListBox
*
Meters
ListBox
_new
(
Settings
*
settings
,
char
*
header
,
Vector
*
meters
,
ScreenManager
*
scr
)
{
Meters
ListBox
*
this
=
(
Meters
ListBox
*
)
malloc
(
sizeof
(
Meters
ListBox
));
ListBox
*
super
=
(
ListBox
*
)
this
;
ListBox
_init
(
super
,
1
,
1
,
1
,
1
,
LISTITEM_CLASS
,
true
);
((
Object
*
)
this
)
->
delete
=
Meters
ListBox
_delete
;
Meters
Panel
*
Meters
Panel
_new
(
Settings
*
settings
,
char
*
header
,
Vector
*
meters
,
ScreenManager
*
scr
)
{
Meters
Panel
*
this
=
(
Meters
Panel
*
)
malloc
(
sizeof
(
Meters
Panel
));
Panel
*
super
=
(
Panel
*
)
this
;
Panel
_init
(
super
,
1
,
1
,
1
,
1
,
LISTITEM_CLASS
,
true
);
((
Object
*
)
this
)
->
delete
=
Meters
Panel
_delete
;
this
->
settings
=
settings
;
this
->
meters
=
meters
;
this
->
scr
=
scr
;
super
->
eventHandler
=
Meters
ListBox
_EventHandler
;
ListBox
_setHeader
(
super
,
header
);
super
->
eventHandler
=
Meters
Panel
_EventHandler
;
Panel
_setHeader
(
super
,
header
);
for
(
int
i
=
0
;
i
<
Vector_size
(
meters
);
i
++
)
{
Meter
*
meter
=
(
Meter
*
)
Vector_get
(
meters
,
i
);
ListBox
_add
(
super
,
(
Object
*
)
Meter_toListItem
(
meter
));
Panel
_add
(
super
,
(
Object
*
)
Meter_toListItem
(
meter
));
}
return
this
;
}
void
Meters
ListBox
_delete
(
Object
*
object
)
{
ListBox
*
super
=
(
ListBox
*
)
object
;
Meters
ListBox
*
this
=
(
Meters
ListBox
*
)
object
;
ListBox
_done
(
super
);
void
Meters
Panel
_delete
(
Object
*
object
)
{
Panel
*
super
=
(
Panel
*
)
object
;
Meters
Panel
*
this
=
(
Meters
Panel
*
)
object
;
Panel
_done
(
super
);
free
(
this
);
}
HandlerResult
Meters
ListBox
_EventHandler
(
ListBox
*
super
,
int
ch
)
{
Meters
ListBox
*
this
=
(
Meters
ListBox
*
)
super
;
HandlerResult
Meters
Panel
_EventHandler
(
Panel
*
super
,
int
ch
)
{
Meters
Panel
*
this
=
(
Meters
Panel
*
)
super
;
int
selected
=
ListBox
_getSelectedIndex
(
super
);
int
selected
=
Panel
_getSelectedIndex
(
super
);
HandlerResult
result
=
IGNORED
;
switch
(
ch
)
{
...
...
@@ -62,7 +62,7 @@ HandlerResult MetersListBox_EventHandler(ListBox* super, int ch) {
int
mode
=
meter
->
mode
+
1
;
if
(
mode
==
LAST_METERMODE
)
mode
=
1
;
Meter_setMode
(
meter
,
mode
);
ListBox
_set
(
super
,
selected
,
(
Object
*
)
Meter_toListItem
(
meter
));
Panel
_set
(
super
,
selected
,
(
Object
*
)
Meter_toListItem
(
meter
));
result
=
HANDLED
;
break
;
}
...
...
@@ -71,7 +71,7 @@ HandlerResult MetersListBox_EventHandler(ListBox* super, int ch) {
case
'-'
:
{
Vector_moveUp
(
this
->
meters
,
selected
);
ListBox
_moveSelectedUp
(
super
);
Panel
_moveSelectedUp
(
super
);
result
=
HANDLED
;
break
;
}
...
...
@@ -80,7 +80,7 @@ HandlerResult MetersListBox_EventHandler(ListBox* super, int ch) {
case
'+'
:
{
Vector_moveDown
(
this
->
meters
,
selected
);
ListBox
_moveSelectedDown
(
super
);
Panel
_moveSelectedDown
(
super
);
result
=
HANDLED
;
break
;
}
...
...
@@ -89,7 +89,7 @@ HandlerResult MetersListBox_EventHandler(ListBox* super, int ch) {
{
if
(
selected
<
Vector_size
(
this
->
meters
))
{
Vector_remove
(
this
->
meters
,
selected
);
ListBox
_remove
(
super
,
selected
);
Panel
_remove
(
super
,
selected
);
}
result
=
HANDLED
;
break
;
...
...
MetersListBox.h
View file @
c2cdcd0c
/* Do not edit this file. It was automatically genarated. */
#ifndef HEADER_Meters
ListBox
#define HEADER_Meters
ListBox
#ifndef HEADER_Meters
Panel
#define HEADER_Meters
Panel
#include "
ListBox
.h"
#include "
Panel
.h"
#include "Settings.h"
#include "ScreenManager.h"
...
...
@@ -12,19 +12,19 @@
#include <assert.h>
typedef
struct
Meters
ListBox
_
{
ListBox
super
;
typedef
struct
Meters
Panel
_
{
Panel
super
;
Settings
*
settings
;
Vector
*
meters
;
ScreenManager
*
scr
;
}
Meters
ListBox
;
}
Meters
Panel
;
Meters
ListBox
*
Meters
ListBox
_new
(
Settings
*
settings
,
char
*
header
,
Vector
*
meters
,
ScreenManager
*
scr
);
Meters
Panel
*
Meters
Panel
_new
(
Settings
*
settings
,
char
*
header
,
Vector
*
meters
,
ScreenManager
*
scr
);
void
Meters
ListBox
_delete
(
Object
*
object
);
void
Meters
Panel
_delete
(
Object
*
object
);
HandlerResult
Meters
ListBox
_EventHandler
(
ListBox
*
super
,
int
ch
);
HandlerResult
Meters
Panel
_EventHandler
(
Panel
*
super
,
int
ch
);
#endif
ListBox
.c
→
Panel
.c
View file @
c2cdcd0c
/*
htop -
ListBox
.c
htop -
Panel
.c
(C) 2004-2006 Hisham H. Muhammad
Released under the GNU GPL, see the COPYING file
in the source distribution for its full text.
*/
#include "Object.h"
#include "
ListBox
.h"
#include "
Panel
.h"
#include "Vector.h"
#include "CRT.h"
#include "RichString.h"
...
...
@@ -22,7 +22,7 @@ in the source distribution for its full text.
/*{
typedef struct
ListBox_ ListBox
;
typedef struct
Panel_ Panel
;
typedef enum HandlerResult_ {
HANDLED,
...
...
@@ -30,9 +30,9 @@ typedef enum HandlerResult_ {
BREAK_LOOP
} HandlerResult;
typedef HandlerResult(*
ListBox
_EventHandler)(
ListBox
*, int);
typedef HandlerResult(*
Panel
_EventHandler)(
Panel
*, int);
struct
ListBox
_ {
struct
Panel
_ {
Object super;
int x, y, w, h;
WINDOW* window;
...
...
@@ -42,10 +42,10 @@ struct ListBox_ {
int oldSelected;
bool needsRedraw;
RichString header;
ListBox
_EventHandler eventHandler;
Panel
_EventHandler eventHandler;
};
extern char*
LISTBOX
_CLASS;
extern char*
PANEL
_CLASS;
}*/
...
...
@@ -57,25 +57,25 @@ extern char* LISTBOX_CLASS;
#endif
/* private property */
char
*
LISTBOX
_CLASS
=
"
ListBox
"
;
char
*
PANEL
_CLASS
=
"
Panel
"
;
ListBox
*
ListBox
_new
(
int
x
,
int
y
,
int
w
,
int
h
,
char
*
type
,
bool
owner
)
{
ListBox
*
this
;
this
=
malloc
(
sizeof
(
ListBox
));
ListBox
_init
(
this
,
x
,
y
,
w
,
h
,
type
,
owner
);
Panel
*
Panel
_new
(
int
x
,
int
y
,
int
w
,
int
h
,
char
*
type
,
bool
owner
)
{
Panel
*
this
;
this
=
malloc
(
sizeof
(
Panel
));
Panel
_init
(
this
,
x
,
y
,
w
,
h
,
type
,
owner
);
return
this
;
}
void
ListBox
_delete
(
Object
*
cast
)
{
ListBox
*
this
=
(
ListBox
*
)
cast
;
ListBox
_done
(
this
);
void
Panel
_delete
(
Object
*
cast
)
{
Panel
*
this
=
(
Panel
*
)
cast
;
Panel
_done
(
this
);
free
(
this
);
}
void
ListBox_init
(
ListBox
*
this
,
int
x
,
int
y
,
int
w
,
int
h
,
char
*
type
,
bool
owner
)
{
void
Panel_init
(
Panel
*
this
,
int
x
,
int
y
,
int
w
,
int
h
,
char
*
type
,
bool
owner
)
{
Object
*
super
=
(
Object
*
)
this
;
super
->
class
=
LISTBOX
_CLASS
;
super
->
delete
=
ListBox
_delete
;
super
->
class
=
PANEL
_CLASS
;
super
->
delete
=
Panel
_delete
;
this
->
x
=
x
;
this
->
y
=
y
;
this
->
w
=
w
;
...
...
@@ -90,13 +90,13 @@ void ListBox_init(ListBox* this, int x, int y, int w, int h, char* type, bool ow
this
->
header
.
len
=
0
;
}
void
ListBox_done
(
ListBox
*
this
)
{
void
Panel_done
(
Panel
*
this
)
{
assert
(
this
!=
NULL
);
RichString_delete
(
this
->
header
);
Vector_delete
(
this
->
items
);
}
inline
void
ListBox
_setRichHeader
(
ListBox
*
this
,
RichString
header
)
{
inline
void
Panel
_setRichHeader
(
Panel
*
this
,
RichString
header
)
{
assert
(
this
!=
NULL
);
if
(
this
->
header
.
len
>
0
)
{
...
...
@@ -106,15 +106,15 @@ inline void ListBox_setRichHeader(ListBox* this, RichString header) {
this
->
needsRedraw
=
true
;
}
inline
void
ListBox
_setHeader
(
ListBox
*
this
,
char
*
header
)
{
ListBox
_setRichHeader
(
this
,
RichString_quickString
(
CRT_colors
[
PANEL_HEADER_FOCUS
],
header
));
inline
void
Panel
_setHeader
(
Panel
*
this
,
char
*
header
)
{
Panel
_setRichHeader
(
this
,
RichString_quickString
(
CRT_colors
[
PANEL_HEADER_FOCUS
],
header
));
}
void
ListBox
_setEventHandler
(
ListBox
*
this
,
ListBox
_EventHandler
eh
)
{
void
Panel
_setEventHandler
(
Panel
*
this
,
Panel
_EventHandler
eh
)
{
this
->
eventHandler
=
eh
;
}
void
ListBox_move
(
ListBox
*
this
,
int
x
,
int
y
)
{
void
Panel_move
(
Panel
*
this
,
int
x
,
int
y
)
{
assert
(
this
!=
NULL
);
this
->
x
=
x
;
...
...
@@ -122,7 +122,7 @@ void ListBox_move(ListBox* this, int x, int y) {
this
->
needsRedraw
=
true
;
}
void
ListBox
_resize
(
ListBox
*
this
,
int
w
,
int
h
)
{
void
Panel
_resize
(
Panel
*
this
,
int
w
,
int
h
)
{
assert
(
this
!=
NULL
);
if
(
this
->
header
.
len
>
0
)
...
...
@@ -132,7 +132,7 @@ void ListBox_resize(ListBox* this, int w, int h) {
this
->
needsRedraw
=
true
;
}
void
ListBox_prune
(
ListBox
*
this
)
{
void
Panel_prune
(
Panel
*
this
)
{
assert
(
this
!=
NULL
);
Vector_prune
(
this
->
items
);
...
...
@@ -142,33 +142,33 @@ void ListBox_prune(ListBox* this) {
this
->
needsRedraw
=
true
;
}
void
ListBox_add
(
ListBox
*
this
,
Object
*
o
)
{
void
Panel_add
(
Panel
*
this
,
Object
*
o
)
{
assert
(
this
!=
NULL
);
Vector_add
(
this
->
items
,
o
);
this
->
needsRedraw
=
true
;
}
void
ListBox
_insert
(
ListBox
*
this
,
int
i
,
Object
*
o
)
{
void
Panel
_insert
(
Panel
*
this
,
int
i
,
Object
*
o
)
{
assert
(
this
!=
NULL
);
Vector_insert
(
this
->
items
,
i
,
o
);
this
->
needsRedraw
=
true
;
}
void
ListBox_set
(
ListBox
*
this
,
int
i
,
Object
*
o
)
{
void
Panel_set
(
Panel
*
this
,
int
i
,
Object
*
o
)
{
assert
(
this
!=
NULL
);
Vector_set
(
this
->
items
,
i
,
o
);
}
Object
*
ListBox_get
(
ListBox
*
this
,
int
i
)
{
Object
*
Panel_get
(
Panel
*
this
,
int
i
)
{
assert
(
this
!=
NULL
);
return
Vector_get
(
this
->
items
,
i
);
}
Object
*
ListBox
_remove
(
ListBox
*
this
,
int
i
)
{
Object
*
Panel
_remove
(
Panel
*
this
,
int
i
)
{
assert
(
this
!=
NULL
);
this
->
needsRedraw
=
true
;
...
...
@@ -178,13 +178,13 @@ Object* ListBox_remove(ListBox* this, int i) {
return
removed
;
}
Object
*
ListBox
_getSelected
(
ListBox
*
this
)
{
Object
*
Panel
_getSelected
(
Panel
*
this
)
{
assert
(
this
!=
NULL
);
return
Vector_get
(
this
->
items
,
this
->
selected
);
}
void
ListBox
_moveSelectedUp
(
ListBox
*
this
)
{
void
Panel
_moveSelectedUp
(
Panel
*
this
)
{
assert
(
this
!=
NULL
);
Vector_moveUp
(
this
->
items
,
this
->
selected
);
...
...
@@ -192,7 +192,7 @@ void ListBox_moveSelectedUp(ListBox* this) {
this
->
selected
--
;
}
void
ListBox
_moveSelectedDown
(
ListBox
*
this
)
{
void
Panel
_moveSelectedDown
(
Panel
*
this
)
{
assert
(
this
!=
NULL
);
Vector_moveDown
(
this
->
items
,
this
->
selected
);
...
...
@@ -200,26 +200,26 @@ void ListBox_moveSelectedDown(ListBox* this) {
this
->
selected
++
;
}
int
ListBox
_getSelectedIndex
(
ListBox
*
this
)
{
int
Panel
_getSelectedIndex
(
Panel
*
this
)
{
assert
(
this
!=
NULL
);
return
this
->
selected
;
}
int
ListBox
_getSize
(
ListBox
*
this
)
{
int
Panel
_getSize
(
Panel
*
this
)
{
assert
(
this
!=
NULL
);
return
Vector_size
(
this
->
items
);
}
void
ListBox
_setSelected
(
ListBox
*
this
,
int
selected
)
{
void
Panel
_setSelected
(
Panel
*
this
,
int
selected
)
{
assert
(
this
!=
NULL
);
selected
=
MAX
(
0
,
MIN
(
Vector_size
(
this
->
items
)
-
1
,
selected
));
this
->
selected
=
selected
;
}
void
ListBox_draw
(
ListBox
*
this
,
bool
focus
)
{
void
Panel_draw
(
Panel
*
this
,
bool
focus
)
{
assert
(
this
!=
NULL
);
int
first
,
last
;
...
...
@@ -311,7 +311,7 @@ void ListBox_draw(ListBox* this, bool focus) {
move
(
0
,
0
);
}
void
ListBox_onKey
(
ListBox
*
this
,
int
key
)
{
void
Panel_onKey
(
Panel
*
this
,
int
key
)
{
assert
(
this
!=
NULL
);
switch
(
key
)
{
case
KEY_DOWN
:
...
...
ListBox
.h
→
Panel
.h
View file @
c2cdcd0c
/* Do not edit this file. It was automatically genarated. */
#ifndef HEADER_
ListBox
#define HEADER_
ListBox
#ifndef HEADER_
Panel
#define HEADER_
Panel
/*
htop
(C) 2004-2006 Hisham H. Muhammad
...
...
@@ -25,7 +25,7 @@ in the source distribution for its full text.
//#link curses
typedef
struct
ListBox_
ListBox
;
typedef
struct
Panel_
Panel
;
typedef
enum
HandlerResult_
{
HANDLED
,
...
...
@@ -33,9 +33,9 @@ typedef enum HandlerResult_ {
BREAK_LOOP
}
HandlerResult
;
typedef
HandlerResult
(
*
ListBox
_EventHandler
)(
ListBox
*
,
int
);
typedef
HandlerResult
(
*
Panel
_EventHandler
)(
Panel
*
,
int
);
struct
ListBox
_
{
struct
Panel
_
{
Object
super
;
int
x
,
y
,
w
,
h
;
WINDOW
*
window
;
...
...
@@ -45,57 +45,57 @@ struct ListBox_ {
int
oldSelected
;
bool
needsRedraw
;
RichString
header
;
ListBox
_EventHandler
eventHandler
;
Panel
_EventHandler
eventHandler
;
};
extern
char
*
LISTBOX
_CLASS
;
extern
char
*
PANEL
_CLASS
;
ListBox
*
ListBox
_new
(
int
x
,
int
y
,
int
w
,
int
h
,
char
*
type
,
bool
owner
);
Panel
*
Panel
_new
(
int
x
,
int
y
,
int
w
,
int
h
,
char
*
type
,
bool
owner
);
void
ListBox
_delete
(
Object
*
cast
);
void
Panel
_delete
(
Object
*
cast
);
void
ListBox_init
(
ListBox
*
this
,
int
x
,
int
y
,
int
w
,
int
h
,
char
*
type
,
bool
owner
);
void
Panel_init
(
Panel
*
this
,
int
x
,
int
y
,
int
w
,
int
h
,
char
*
type
,
bool
owner
);
void
ListBox_done
(
ListBox
*
this
);
void
Panel_done
(
Panel
*
this
);
void
ListBox
_setEventHandler
(
ListBox
*
this
,
ListBox
_EventHandler
eh
);
void
Panel
_setEventHandler
(
Panel
*
this
,
Panel
_EventHandler
eh
);
void
ListBox
_setRichHeader
(
ListBox
*
this
,
RichString
header
);
void
Panel
_setRichHeader
(
Panel
*
this
,
RichString
header
);
void
ListBox
_setHeader
(
ListBox
*
this
,
char
*
header
);
void
Panel
_setHeader
(
Panel
*
this
,
char
*
header
);
void
ListBox_move
(
ListBox
*
this
,
int
x
,
int
y
);
void
Panel_move
(
Panel
*
this
,
int
x
,
int
y
);
void
ListBox
_resize
(
ListBox
*
this
,
int
w
,
int
h
);
void
Panel
_resize
(
Panel
*
this
,
int
w
,
int
h
);
void
ListBox_prune
(
ListBox
*
this
);
void
Panel_prune
(
Panel
*
this
);
void
ListBox_add
(
ListBox
*
this
,
Object
*
o
);
void
Panel_add
(
Panel
*
this
,
Object
*
o
);
void
ListBox
_insert
(
ListBox
*
this
,
int
i
,
Object
*
o
);
void
Panel
_insert
(
Panel
*
this
,
int
i
,
Object
*
o
);
void
ListBox_set
(
ListBox
*
this
,
int
i
,
Object
*
o
);
void
Panel_set
(
Panel
*
this
,
int
i
,
Object
*
o
);
Object
*
ListBox_get
(
ListBox
*
this
,
int
i
);
Object
*
Panel_get
(
Panel
*
this
,
int
i
);
Object
*
ListBox
_remove
(
ListBox
*
this
,
int
i
);
Object
*
Panel
_remove
(
Panel
*
this
,
int
i
);
Object
*
ListBox
_getSelected
(
ListBox
*
this
);
Object
*
Panel
_getSelected
(
Panel
*
this
);
void
ListBox
_moveSelectedUp
(
ListBox
*
this
);
void
Panel
_moveSelectedUp
(
Panel
*
this
);
void
ListBox
_moveSelectedDown
(
ListBox
*
this
);
void
Panel
_moveSelectedDown
(
Panel
*
this
);
int
ListBox
_getSelectedIndex
(
ListBox
*
this
);
int
Panel
_getSelectedIndex
(
Panel
*
this
);
int
ListBox
_getSize
(
ListBox
*
this
);
int
Panel
_getSize
(
Panel
*
this
);
void
ListBox
_setSelected
(
ListBox
*
this
,
int
selected
);
void
Panel
_setSelected
(
Panel
*
this
,
int
selected
);
void
ListBox_draw
(
ListBox
*
this
,
bool
focus
);
void
Panel_draw
(
Panel
*
this
,
bool
focus
);
void
ListBox_onKey
(
ListBox
*
this
,
int
key
);
void
Panel_onKey
(
Panel
*
this
,
int
key
);
#endif
ScreenManager.c
View file @
c2cdcd0c
...
...
@@ -6,7 +6,7 @@ in the source distribution for its full text.
*/
#include "ScreenManager.h"
#include "
ListBox
.h"
#include "
Panel
.h"
#include "Object.h"
#include "Vector.h"
#include "FunctionBar.h"
...
...
@@ -47,7 +47,7 @@ ScreenManager* ScreenManager_new(int x1, int y1, int x2, int y2, Orientation ori
this
->
y2
=
y2
;
this
->
fuBar
=
NULL
;
this
->
orientation
=
orientation
;
this
->
items
=
Vector_new
(
LISTBOX
_CLASS
,
owner
,
DEFAULT_SIZE
);
this
->
items
=
Vector_new
(
PANEL
_CLASS
,
owner
,
DEFAULT_SIZE
);
this
->
fuBars
=
Vector_new
(
FUNCTIONBAR_CLASS
,
true
,
DEFAULT_SIZE
);
this
->
itemCount
=
0
;
this
->
owner
=
owner
;
...
...
@@ -64,19 +64,19 @@ inline int ScreenManager_size(ScreenManager* this) {
return
this
->
itemCount
;
}
void
ScreenManager_add
(
ScreenManager
*
this
,
ListBox
*
item
,
FunctionBar
*
fuBar
,
int
size
)
{
void
ScreenManager_add
(
ScreenManager
*
this
,
Panel
*
item
,
FunctionBar
*
fuBar
,
int
size
)
{
if
(
this
->
orientation
==
HORIZONTAL
)
{
int
lastX
=
0
;
if
(
this
->
itemCount
>
0
)
{
ListBox
*
last
=
(
ListBox
*
)
Vector_get
(
this
->
items
,
this
->
itemCount
-
1
);
Panel
*
last
=
(
Panel
*
)
Vector_get
(
this
->
items
,
this
->
itemCount
-
1
);
lastX
=
last
->
x
+
last
->
w
+
1
;
}
if
(
size
>
0
)
{
ListBox
_resize
(
item
,
size
,
LINES
-
this
->
y1
+
this
->
y2
);
Panel
_resize
(
item
,
size
,
LINES
-
this
->
y1
+
this
->
y2
);
}
else
{
ListBox
_resize
(
item
,
COLS
-
this
->
x1
+
this
->
x2
-
lastX
,
LINES
-
this
->
y1
+
this
->
y2
);
Panel
_resize
(
item
,
COLS
-
this
->
x1
+
this
->
x2
-
lastX
,
LINES
-
this
->
y1
+
this
->
y2
);
}
ListBox
_move
(
item
,
lastX
,
this
->
y1
);
Panel
_move
(
item
,
lastX
,
this
->
y1
);
}
// TODO: VERTICAL
Vector_add
(
this
->
items
,
item
);
...
...
@@ -89,9 +89,9 @@ void ScreenManager_add(ScreenManager* this, ListBox* item, FunctionBar* fuBar, i
this
->
itemCount
++
;
}
ListBox
*
ScreenManager_remove
(
ScreenManager
*
this
,
int
index
)
{
Panel
*
ScreenManager_remove
(
ScreenManager
*
this
,
int
index
)
{
assert
(
this
->
itemCount
>
index
);
ListBox
*
lb
=
(
ListBox
*
)
Vector_remove
(
this
->
items
,
index
);
Panel
*
lb
=
(
Panel
*
)
Vector_remove
(
this
->
items
,
index
);
Vector_remove
(
this
->
fuBars
,
index
);
this
->
fuBar
=
NULL
;
this
->
itemCount
--
;
...
...
@@ -112,21 +112,21 @@ void ScreenManager_resize(ScreenManager* this, int x1, int y1, int x2, int y2) {
int
items
=
this
->
itemCount
;
int
lastX
=
0
;
for
(
int
i
=
0
;
i
<
items
-
1
;
i
++
)
{
ListBox
*
lb
=
(
ListBox
*
)
Vector_get
(
this
->
items
,
i
);
ListBox
_resize
(
lb
,
lb
->
w
,
LINES
-
y1
+
y2
);
ListBox
_move
(
lb
,
lastX
,
y1
);
Panel
*
lb
=
(
Panel
*
)
Vector_get
(
this
->
items
,
i
);
Panel
_resize
(
lb
,
lb
->
w
,
LINES
-
y1
+
y2
);
Panel
_move
(
lb
,
lastX
,
y1
);
lastX
=
lb
->
x
+
lb
->
w
+
1
;
}
ListBox
*
lb
=
(
ListBox
*
)
Vector_get
(
this
->
items
,
items
-
1
);
ListBox
_resize
(
lb
,
COLS
-
x1
+
x2
-
lastX
,
LINES
-
y1
+
y2
);
ListBox
_move
(
lb
,
lastX
,
y1
);
Panel
*
lb
=
(
Panel
*
)
Vector_get
(
this
->
items
,
items
-
1
);
Panel
_resize
(
lb
,
COLS
-
x1
+
x2
-
lastX
,
LINES
-
y1
+
y2
);
Panel
_move
(
lb
,
lastX
,
y1
);
}
void
ScreenManager_run
(
ScreenManager
*
this
,
ListBox
**
lastFocus
,
int
*
lastKey
)
{
void
ScreenManager_run
(
ScreenManager
*
this
,
Panel
**
lastFocus
,
int
*
lastKey
)
{
bool
quit
=
false
;
int
focus
=
0
;
ListBox
*
lbFocus
=
(
ListBox
*
)
Vector_get
(
this
->
items
,
focus
);
Panel
*
lbFocus
=
(
Panel
*
)
Vector_get
(
this
->
items
,
focus
);
if
(
this
->
fuBar
)
FunctionBar_draw
(
this
->
fuBar
,
NULL
);
...
...
@@ -134,8 +134,8 @@ void ScreenManager_run(ScreenManager* this, ListBox** lastFocus, int* lastKey) {
while
(
!
quit
)
{
int
items
=
this
->
itemCount
;
for
(
int
i
=
0
;
i
<
items
;
i
++
)
{
ListBox
*
lb
=
(
ListBox
*
)
Vector_get
(
this
->
items
,
i
);
ListBox
_draw
(
lb
,
i
==
focus
);
Panel
*
lb
=
(
Panel
*
)
Vector_get
(
this
->
items
,
i
);
Panel
_draw
(
lb
,
i
==
focus
);
if
(
i
<
items
)
{
if
(
this
->
orientation
==
HORIZONTAL
)
{
mvvline
(
lb
->
y
,
lb
->
x
+
lb
->
w
,
' '
,
lb
->
h
+
1
);
...
...
@@ -159,12 +159,12 @@ void ScreenManager_run(ScreenManager* this, ListBox** lastFocus, int* lastKey) {
ch
=
FunctionBar_synthesizeEvent
(
this
->
fuBar
,
mevent
.
x
);
}
else
{
for
(
int
i
=
0
;
i
<
this
->
itemCount
;
i
++
)
{
ListBox
*
lb
=
(
ListBox
*
)
Vector_get
(
this
->
items
,
i
);
Panel
*
lb
=
(
Panel
*
)
Vector_get
(
this
->
items
,
i
);
if
(
mevent
.
x
>
lb
->
x
&&
mevent
.
x
<=
lb
->
x
+
lb
->
w
&&
mevent
.
y
>
lb
->
y
&&
mevent
.
y
<=
lb
->
y
+
lb
->
h
)
{
focus
=
i
;
lbFocus
=
lb
;
ListBox
_setSelected
(
lb
,
mevent
.
y
-
lb
->
y
+
lb
->
scrollV
-
1
);
Panel
_setSelected
(
lb
,
mevent
.
y
-
lb
->
y
+
lb
->
scrollV
-
1
);
loop
=
true
;
break
;
}
...
...
@@ -196,8 +196,8 @@ void ScreenManager_run(ScreenManager* this, ListBox** lastFocus, int* lastKey) {
tryLeft:
if
(
focus
>
0
)
focus
--
;
lbFocus
=
(
ListBox
*
)
Vector_get
(
this
->
items
,
focus
);
if
(
ListBox
_getSize
(
lbFocus
)
==
0
&&
focus
>
0
)
lbFocus
=
(
Panel
*
)
Vector_get
(
this
->
items
,
focus
);
if
(
Panel
_getSize
(
lbFocus
)
==
0
&&
focus
>
0
)
goto
tryLeft
;
break
;
case
KEY_RIGHT
:
...
...
@@ -205,8 +205,8 @@ void ScreenManager_run(ScreenManager* this, ListBox** lastFocus, int* lastKey) {
tryRight:
if
(
focus
<
this
->
itemCount
-
1
)
focus
++
;
lbFocus
=
(
ListBox
*
)
Vector_get
(
this
->
items
,
focus
);
if
(
ListBox
_getSize
(
lbFocus
)
==
0
&&
focus
<
this
->
itemCount
-
1
)
lbFocus
=
(
Panel
*
)
Vector_get
(
this
->
items
,
focus
);
if
(
Panel
_getSize
(
lbFocus
)
==
0
&&
focus
<
this
->
itemCount
-
1
)
goto
tryRight
;
break
;
case
KEY_F
(
10
):
...
...
@@ -215,7 +215,7 @@ void ScreenManager_run(ScreenManager* this, ListBox** lastFocus, int* lastKey) {
quit
=
true
;
continue
;
default:
ListBox
_onKey
(
lbFocus
,
ch
);
Panel
_onKey
(
lbFocus
,
ch
);
break
;
}
}
...
...
ScreenManager.h
View file @
c2cdcd0c
...
...
@@ -9,7 +9,7 @@ Released under the GNU GPL, see the COPYING file
in the source distribution for its full text.
*/
#include "
ListBox
.h"
#include "
Panel
.h"
#include "Object.h"
#include "Vector.h"
#include "FunctionBar.h"
...
...
@@ -45,14 +45,14 @@ void ScreenManager_delete(ScreenManager* this);
inline
int
ScreenManager_size
(
ScreenManager
*
this
);
void
ScreenManager_add
(
ScreenManager
*
this
,
ListBox
*
item
,
FunctionBar
*
fuBar
,
int
size
);
void
ScreenManager_add
(
ScreenManager
*
this
,
Panel
*
item
,
FunctionBar
*
fuBar
,
int
size
);
ListBox
*
ScreenManager_remove
(
ScreenManager
*
this
,
int
index
);
Panel
*
ScreenManager_remove
(
ScreenManager
*
this
,
int
index
);
void
ScreenManager_setFunctionBar
(
ScreenManager
*
this
,
FunctionBar
*
fuBar
);
void
ScreenManager_resize
(
ScreenManager
*
this
,
int
x1
,
int
y1
,
int
x2
,
int
y2
);
void
ScreenManager_run
(
ScreenManager
*
this
,
ListBox
**
lastFocus
,
int
*
lastKey
);
void
ScreenManager_run
(
ScreenManager
*
this
,
Panel
**
lastFocus
,
int
*
lastKey
);
#endif
Prev
1
2
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
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 comment