2 Copyright (C) 2003 Jasem Mutlaq (mutlaqja@ikarustech.com)
4 This application is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
9 2004-01-15 INDI element is the most basic unit of the INDI KStars client.
15 #include <kdialogbase.h>
20 #include "indi/lilxml.h"
22 #define INDIVERSION 1.5 /* we support this or less */
25 #define PROPERTY_LABEL_WIDTH 80
26 #define ELEMENT_LABEL_WIDTH 105
27 #define ELEMENT_READ_WIDTH 150
28 #define ELEMENT_WRITE_WIDTH 175
29 #define ELEMENT_FULL_WIDTH 340
30 #define BUTTON_WIDTH 101
31 #define MIN_SET_WIDTH 50
32 #define MAX_SET_WIDTH 110
35 #define INDI_PULSE_TRACKING 15000
38 * lights use PState, TB's use the alternate binary names.
40 typedef enum {PS_IDLE
= 0, PS_OK
, PS_BUSY
, PS_ALERT
, PS_N
} PState
;
41 #define PS_OFF PS_IDLE /* alternate name */
42 #define PS_ON PS_OK /* alternate name */
43 typedef enum {PP_RW
= 0, PP_WO
, PP_RO
} PPerm
;
44 typedef enum {PG_NONE
= 0, PG_TEXT
, PG_NUMERIC
, PG_BUTTONS
,
45 PG_RADIO
, PG_MENU
, PG_LIGHTS
, PG_BLOB
} PGui
;
47 /* INDI std properties */
48 /* N.B. Need to modify corresponding entry in indidevice.cpp when changed */
49 enum stdProperties
{ CONNECTION
, EQUATORIAL_COORD
, EQUATORIAL_EOD_COORD
, ON_COORD_SET
, ABORT_MOTION
, SOLAR_SYSTEM
,
50 GEOGRAPHIC_COORD
, HORIZONTAL_COORD
, TIME
, EXPOSE_DURATION
,
51 DEVICE_PORT
, PARK
, MOVEMENT
, SDTIME
, DATA_CHANNEL
, VIDEO_STREAM
, IMAGE_SIZE
, FILTER_CONF
};
53 /* Devices families that we explicity support (i.e. with std properties) */
54 enum deviceFamily
{ KSTARS_TELESCOPE
, KSTARS_CCD
, KSTARS_FILTER
, KSTARS_VIDEO
, KSTARS_FOCUSER
, KSTARS_DOME
, KSTARS_GPS
};
56 #define MAXSCSTEPS 1000 /* max number of steps in a scale */
57 #define MAXRADIO 4 /* max numbere of buttons in a property */
59 /* Forward decleration */
65 class KSqueezedTextLabel
;
76 /* Useful XML functions */
77 XMLAtt
* findAtt (XMLEle
*ep
, const char *name
, char errmsg
[]);
78 XMLEle
* findEle (XMLEle
*ep
, INDI_P
*pp
, const char *child
, char errmsg
[]);
81 class INDI_E
: public QObject
85 INDI_E(INDI_P
*parentProperty
, QString inName
, QString inLabel
);
87 QString name
; /* name */
88 QString label
; /* label is the name by default, unless specefied */
89 PState state
; /* control on/off t/f etc */
90 INDI_P
*pp
; /* parent property */
92 QHBoxLayout
*EHBox
; /* Horizontal layout */
94 /* GUI widgets, only malloced when needed */
95 KSqueezedTextLabel
*label_w
; // label
96 KLineEdit
*read_w
; // read field
97 KLineEdit
*write_w
; // write field
98 KLed
*led_w
; // light led
99 KDoubleSpinBox
*spin_w
; // spinbox
100 QSlider
*slider_w
; // Slider
101 KPushButton
*push_w
; // push button
102 KPushButton
*browse_w
; // browse button
103 QCheckBox
*check_w
; // check box
104 QSpacerItem
*hSpacer
; // Horizontal spacer
106 double min
, max
, step
; // params for scale
107 double value
; // current value
108 double targetValue
; // target value
109 QString text
; // current text
110 QString format
; // number format, if applicable
112 int buildTextGUI (QString initText
);
113 int buildNumberGUI (double initValue
);
118 void initNumberValues(double newMin
, double newMax
, double newStep
, char * newFormat
);
119 void updateValue(double newValue
);
120 void setMin (double inMin
);
121 void setMax (double inMax
);
123 void setupElementLabel();
124 void setupElementRead(int length
);
125 void setupElementWrite(int length
);
126 void setupElementScale(int length
);
127 void setupBrowseButton();
130 void spinChanged(double value
);
131 void sliderChanged(int value
);