2020-11-21 20:40:08 +00:00
|
|
|
#ifndef HEADER_OptionItem
|
|
|
|
#define HEADER_OptionItem
|
|
|
|
/*
|
|
|
|
htop - OptionItem.h
|
|
|
|
(C) 2004-2011 Hisham H. Muhammad
|
2021-09-22 09:33:00 +00:00
|
|
|
Released under the GNU GPLv2+, see the COPYING file
|
2020-11-21 20:40:08 +00:00
|
|
|
in the source distribution for its full text.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdbool.h>
|
|
|
|
|
|
|
|
#include "Object.h"
|
|
|
|
|
|
|
|
|
|
|
|
enum OptionItemType {
|
2022-05-04 19:26:33 +00:00
|
|
|
OPTION_ITEM_TEXT,
|
2020-11-21 20:40:08 +00:00
|
|
|
OPTION_ITEM_CHECK,
|
|
|
|
OPTION_ITEM_NUMBER,
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct OptionItemClass_ {
|
|
|
|
const ObjectClass super;
|
|
|
|
|
|
|
|
enum OptionItemType kind;
|
|
|
|
} OptionItemClass;
|
|
|
|
|
|
|
|
#define As_OptionItem(this_) ((const OptionItemClass*)((this_)->super.klass))
|
|
|
|
#define OptionItem_kind(this_) As_OptionItem(this_)->kind
|
|
|
|
|
|
|
|
typedef struct OptionItem_ {
|
|
|
|
Object super;
|
|
|
|
|
|
|
|
char* text;
|
|
|
|
} OptionItem;
|
|
|
|
|
2022-05-04 19:26:33 +00:00
|
|
|
typedef struct TextItem_ {
|
|
|
|
OptionItem super;
|
|
|
|
|
|
|
|
char* text;
|
|
|
|
} TextItem;
|
|
|
|
|
2020-11-21 20:40:08 +00:00
|
|
|
typedef struct CheckItem_ {
|
|
|
|
OptionItem super;
|
|
|
|
|
|
|
|
bool* ref;
|
|
|
|
bool value;
|
|
|
|
} CheckItem;
|
|
|
|
|
|
|
|
typedef struct NumberItem_ {
|
|
|
|
OptionItem super;
|
|
|
|
|
|
|
|
char* text;
|
|
|
|
int* ref;
|
|
|
|
int value;
|
|
|
|
int scale;
|
|
|
|
int min;
|
|
|
|
int max;
|
|
|
|
} NumberItem;
|
|
|
|
|
|
|
|
extern const OptionItemClass OptionItem_class;
|
2022-05-04 19:26:33 +00:00
|
|
|
extern const OptionItemClass TextItem_class;
|
2020-11-21 20:40:08 +00:00
|
|
|
extern const OptionItemClass CheckItem_class;
|
|
|
|
extern const OptionItemClass NumberItem_class;
|
|
|
|
|
2022-05-04 19:26:33 +00:00
|
|
|
TextItem* TextItem_new(const char* text);
|
|
|
|
|
2020-11-21 20:40:08 +00:00
|
|
|
CheckItem* CheckItem_newByRef(const char* text, bool* ref);
|
|
|
|
CheckItem* CheckItem_newByVal(const char* text, bool value);
|
|
|
|
bool CheckItem_get(const CheckItem* this);
|
|
|
|
void CheckItem_set(CheckItem* this, bool value);
|
|
|
|
void CheckItem_toggle(CheckItem* this);
|
|
|
|
|
|
|
|
NumberItem* NumberItem_newByRef(const char* text, int* ref, int scale, int min, int max);
|
|
|
|
NumberItem* NumberItem_newByVal(const char* text, int value, int scale, int min, int max);
|
|
|
|
int NumberItem_get(const NumberItem* this);
|
|
|
|
void NumberItem_decrease(NumberItem* this);
|
|
|
|
void NumberItem_increase(NumberItem* this);
|
|
|
|
void NumberItem_toggle(NumberItem* this);
|
|
|
|
|
|
|
|
#endif
|