7599f0ec8c
When the scroll bar slider is dragged, the list scrolls only far enough to see all items; only the arrow buttons can scroll it so far that the last item goes to the top of the view. Fix scroll bar proportional size: was wrong when the list was only a little longer than the visible area. Minor fixes such as "delete files[i];" -> "delete[] files[i];" (where the item being deleted is an array of characters) and removal of global variables. Smooth scrolling when dragging the slider: one item at a time, rather than one tenth of the list at a time. Fix a bug that would have occurred if instantiated with arrows=2. Sort properties primarily by name and then by numerical index order, rather than a simple ASCII string order. E.g. "js[1]", "js[2]", "js[10]" rather than "js[1]", "js[10]", "js[2]". Avoid crashing if the selected property path does not exist; display an empty list instead. This cannot happen when the property picker is working properly, but did happen due to missing indices prior to this patch, and could happen if the user is allowed to type a pathname, as in the http and telnet interfaces. Fix truncation of strings to PUSTRING_MAX: was wrong when string length was exactly 80. Fix: move the scroll bar to the top each time a new list is displayed. It was left at its previous position, while the top of the new list was displayed, not corresponding to the slider. Use getDisplayName instead of duplicated code: gives a better decision on whether to display the index, and avoids invalid property paths being generated which would previously crash find_props(). Replace unnecessary node lookups by name with direct access: tidier and more efficient. E.g. "getValueTypeString (node->getNode(name.c_str()))" -> "getValueTypeString (child)".
88 lines
1.9 KiB
C++
Executable file
88 lines
1.9 KiB
C++
Executable file
/*
|
|
prop_picker.hxx
|
|
|
|
*/
|
|
|
|
#include <plib/pu.h>
|
|
|
|
#include <stdio.h>
|
|
#include "gui.h"
|
|
|
|
void prop_pickerInit();
|
|
void prop_pickerView( puObject * );
|
|
void prop_pickerRefresh();
|
|
void prop_editInit(char * name, char * value );
|
|
void prop_editOpen( char * name, char * value );
|
|
|
|
class fgPropPicker ;
|
|
class fgPropEdit ;
|
|
|
|
class fgPropPicker : public puDialogBox
|
|
{
|
|
|
|
static void handle_select ( puObject *b ) ;
|
|
static void input_entered ( puObject *b ) ;
|
|
static void fgPropPickerHandleSlider ( puObject * slider );
|
|
static void fgPropPickerHandleArrow ( puObject *arrow );
|
|
static void fgPropPickerHandleOk ( puObject* b );
|
|
|
|
void delete_arrays () ;
|
|
|
|
char** files ;
|
|
char** names ;
|
|
char** values ;
|
|
char* dflag ;
|
|
int num_files ;
|
|
int arrow_count ;
|
|
char startDir [ PUSTRING_MAX * 2 ] ;
|
|
|
|
/* puInput *input ; */
|
|
|
|
protected:
|
|
|
|
puFrame *frame ;
|
|
puListBox *list_box ;
|
|
puSlider *slider ;
|
|
puOneShot *cancel_button ;
|
|
puOneShot *ok_button ;
|
|
puArrowButton *down_arrow ;
|
|
puArrowButton *up_arrow ;
|
|
|
|
public:
|
|
puText *proppath ;
|
|
void find_props () ;
|
|
fgPropPicker ( int x, int y, int w, int h, int arrows,
|
|
const char *dir, const char *title = "Pick a file" ) ;
|
|
|
|
~fgPropPicker () {;}
|
|
|
|
static void go_up_one_directory ( char *fname ) ;
|
|
static void chop_file ( char *fname ) ;
|
|
|
|
} ;
|
|
|
|
class fgPropEdit : public puDialogBox
|
|
{
|
|
|
|
static void fgPropEditHandleCancel ( puObject *b ) ;
|
|
static void fgPropEditHandleOK ( puObject* b );
|
|
|
|
protected:
|
|
|
|
puFrame *frame ;
|
|
puOneShot *cancel_button ;
|
|
puOneShot *ok_button ;
|
|
|
|
public:
|
|
puText *propname ;
|
|
puInput *propinput ;
|
|
char propPath [ PUSTRING_MAX * 2 ] ;
|
|
|
|
fgPropEdit ( char *name, char *value, char *proppath ) ;
|
|
|
|
~fgPropEdit () {;}
|
|
|
|
static void go_up_one_directory ( char *fname ) ;
|
|
static void chop_file ( char *fname ) ;
|
|
|
|
} ;
|