summaryrefslogtreecommitdiffstats
path: root/OptionItem.h
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 09:00:29 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 09:00:29 +0000
commit52e25213825024b8bb446eb26b03bedc9d5c2103 (patch)
treeda70bf44b2423f6f8e9a070c063fed79d190b489 /OptionItem.h
parentInitial commit. (diff)
downloadhtop-52e25213825024b8bb446eb26b03bedc9d5c2103.tar.xz
htop-52e25213825024b8bb446eb26b03bedc9d5c2103.zip
Adding upstream version 3.2.2.upstream/3.2.2upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--OptionItem.h80
1 files changed, 80 insertions, 0 deletions
diff --git a/OptionItem.h b/OptionItem.h
new file mode 100644
index 0000000..ba28775
--- /dev/null
+++ b/OptionItem.h
@@ -0,0 +1,80 @@
+#ifndef HEADER_OptionItem
+#define HEADER_OptionItem
+/*
+htop - OptionItem.h
+(C) 2004-2011 Hisham H. Muhammad
+Released under the GNU GPLv2+, see the COPYING file
+in the source distribution for its full text.
+*/
+
+#include <stdbool.h>
+
+#include "Object.h"
+
+
+enum OptionItemType {
+ OPTION_ITEM_TEXT,
+ 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;
+
+typedef struct TextItem_ {
+ OptionItem super;
+
+ char* text;
+} TextItem;
+
+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;
+extern const OptionItemClass TextItem_class;
+extern const OptionItemClass CheckItem_class;
+extern const OptionItemClass NumberItem_class;
+
+TextItem* TextItem_new(const char* text);
+
+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