]> git.mxchange.org Git - flightgear.git/blobdiff - src/GUI/puList.cxx
Don't restore initial screen geometry because there is nothing in fg_os* to resize...
[flightgear.git] / src / GUI / puList.cxx
index 4654084adb66772bbf469149266adc7272612395..d5b707cdb91299ffc214ea91662ae65bd0dfa826 100644 (file)
@@ -17,6 +17,17 @@ handle_slider (puObject * slider)
 }
 
 
+/**
+ * Static function: handle list entry clicks.
+ */
+static void
+handle_list_entry (puObject * listbox)
+{
+    puListBox * box = (puListBox *)listbox->getUserData();
+    box->invokeCallback();
+}
+
+
 /**
  * Static function: handle arrow clicks.
  */
@@ -50,15 +61,17 @@ handle_arrow (puObject * arrow)
     slider->setValue(1.0f - float(index)/list_box->getNumItems());
 }
 
-puList::puList (int x, int y, int w, int h)
-    : puGroup(x, y)
+puList::puList (int x, int y, int w, int h, int sl_width)
+    : puGroup(x, y),
+      sw(sl_width)
 {
     type |= PUCLASS_LIST;
     init(w, h);
 }
 
-puList::puList (int x, int y, int w, int h, char ** contents)
-    : puGroup(x, y)
+puList::puList (int x, int y, int w, int h, char ** contents, int sl_width)
+    : puGroup(x, y),
+      sw(sl_width)
 {
     type |= PUCLASS_LIST;
     init(w, h);
@@ -94,22 +107,23 @@ puList::init (int w, int h)
 {
     _frame = new puFrame(0, 0, w, h);
 
-    _list_box = new puListBox(0, 0, w-30, h);
+    _list_box = new puListBox(0, 0, w-sw, h);
     _list_box->setStyle(-PUSTYLE_SMALL_SHADED);
     _list_box->setUserData(this);
+    _list_box->setCallback(handle_list_entry);
     _list_box->setValue(0);
 
-    _slider = new puSlider(w-30, 30, h-60, true);
+    _slider = new puSlider(w-sw, sw, h-2*sw, true, sw);
     _slider->setValue(1.0f);
     _slider->setUserData(_list_box);
     _slider->setCallback(handle_slider);
     _slider->setCBMode(PUSLIDER_ALWAYS);
 
-    _down_arrow = new puArrowButton(w-30, 0, w, 30, PUARROW_DOWN) ;
+    _down_arrow = new puArrowButton(w-sw, 0, w, sw, PUARROW_DOWN) ;
     _down_arrow->setUserData(_slider);
     _down_arrow->setCallback(handle_arrow);
 
-    _up_arrow = new puArrowButton(w-30, h-30, w, h, PUARROW_UP);
+    _up_arrow = new puArrowButton(w-sw, h-sw, w, h, PUARROW_UP);
     _up_arrow->setUserData(_slider);
     _up_arrow->setCallback(handle_arrow);
 
@@ -130,4 +144,18 @@ puList::setColour (int which, float r, float g, float b, float a)
     _list_box->setColour(which, r, g, b, a);
 }
 
+void
+puList::setSize (int w, int h)
+{
+    puObject::setSize(w, h);
+    _frame->setSize(w, h);
+    _list_box->setSize(w-sw, h);
+
+    _slider->setPosition(w-sw, sw);
+    _slider->setSize(sw, h-2*sw);
+
+    _down_arrow->setPosition(w-sw, 0);
+    _up_arrow->setPosition(w-sw, h-sw);
+}
+
 // end of puList.cxx