llfloatertest.cpp

Go to the documentation of this file.
00001 
00033 #include "llviewerprecompiledheaders.h"
00034 
00035 #include "llfloatertest.h"
00036 
00037 #include "llbutton.h"
00038 #include "llcheckboxctrl.h"
00039 #include "llcombobox.h"
00040 #include "llfloater.h"
00041 #include "lliconctrl.h"
00042 #include "lllineeditor.h"
00043 #include "llradiogroup.h"
00044 #include "llscrollcontainer.h"
00045 #include "llscrolllistctrl.h"
00046 #include "llslider.h"
00047 #include "llsliderctrl.h"
00048 #include "lltabcontainer.h"
00049 #include "lltextbox.h"
00050 #include "lltexteditor.h"
00051 #include "llview.h"
00052 #include "llviewborder.h"
00053 
00054 #include "llnamelistctrl.h"
00055 #include "lluictrlfactory.h"
00056 #include "llviewercontrol.h"
00057 
00058 class LLFloaterTestImpl : public LLFloater
00059 {
00060 public:
00061         LLFloaterTestImpl();
00062 
00063 private:
00064         static void onClickButton(void*);
00065         static void onClickText(void*);
00066         static void onClickTab(void*, bool);
00067         static void onCommitCheck(LLUICtrl*, void*);
00068         static void onCommitCombo(LLUICtrl*, void*);
00069         static void onCommitLine(LLUICtrl*, void*);
00070         static void onKeyLine(LLLineEditor*, void*);
00071         static void onFocusLostLine(LLFocusableElement*, void*);
00072         static void onChangeRadioGroup(LLUICtrl*, void*);
00073 
00074         LLButton* mBtnSimple;
00075         LLButton* mBtnUnicode;
00076         LLButton* mBtnImages;
00077         LLCheckBoxCtrl* mCheckSimple;
00078         LLCheckBoxCtrl* mCheckUnicode;
00079         LLComboBox* mCombo;
00080         LLIconCtrl* mIcon;
00081         LLLineEditor* mLineEditor;
00082         LLRadioGroup* mRadioGroup;
00083         LLRadioCtrl* mRadio1;
00084         LLRadioCtrl* mRadio2;
00085         LLScrollableContainerView* mScroll;
00086         LLScrollListCtrl* mScrollList;
00087         LLTabContainer* mTab;
00088         LLTextEditor* mTextEditor;
00089         LLView* mView;
00090         LLViewBorder* mViewBorder;
00091 
00092         LLNameListCtrl* mNameList;
00093 };
00094 
00095 
00096 LLFloaterTestImpl::LLFloaterTestImpl()
00097 :       LLFloater("test", LLRect(0, 500, 700, 0), "Test UI")
00098 {
00099         const S32 HPAD = 5;
00100         const S32 VPAD = 5;
00101         const S32 LEFT = HPAD;
00102         const S32 RIGHT = getRect().getWidth() - HPAD;
00103         const S32 TOP = getRect().getHeight() - LLFLOATER_HEADER_SIZE - VPAD;
00104         const S32 BOTTOM = VPAD;
00105         const S32 LINE = 15;
00106 
00107         //S32 x = LEFT;
00108         S32 y = TOP;
00109 
00110         LLTextBox* text = NULL;
00111         LLButton* btn = NULL;
00112         LLTabContainer* tab = NULL;
00113         LLPanel* panel = NULL;
00114         LLCheckBoxCtrl* check = NULL;
00115         LLComboBox* combo = NULL;
00116 
00117         btn = new LLButton("can't click",
00118                 LLRect(LEFT+150, y, LEFT+150+100, y-LINE),
00119                 NULL,   // LLString converts to ""
00120                 onClickButton, this);
00121         btn->setFollows(FOLLOWS_LEFT|FOLLOWS_TOP);
00122         btn->setFont(LLFontGL::sSansSerifSmall);
00123         addChild(btn);
00124 
00125         text = new LLTextBox("simple_text", 
00126                 "simple sans-serif text that is mouse opaque opaque opaque",
00127                 50,     // max_width
00128                 LLFontGL::sSansSerifSmall,
00129                 TRUE);  // mouse_opaque
00130         text->setClickedCallback(onClickText);
00131         text->setRect(LLRect(LEFT, y, RIGHT, y-LINE));
00132         addChild(text);
00133 
00134         y -= VPAD + LINE;
00135 
00136         btn = new LLButton("can click",
00137                 LLRect(LEFT+150, y, LEFT+150+100, y-LINE),
00138                 NULL,   // LLString converts to ""
00139                 onClickButton, this);
00140         btn->setFollows(FOLLOWS_LEFT|FOLLOWS_TOP);
00141         btn->setFont(LLFontGL::sSansSerifSmall);
00142         addChild(btn);
00143 
00144         text = new LLTextBox("simple2_text", 
00145                 LLRect(LEFT, y, RIGHT, y-LINE),
00146                 "monospaced, non-opaque text with tooltip, non-opaque non-opaque",
00147                 LLFontGL::sMonospace,
00148                 FALSE); // mouse_opaque
00149         text->setToolTip(LLString("I'm a tooltip"));
00150         addChild(text);
00151 
00152         y -= VPAD + LINE;
00153 
00154         tab = new LLTabContainer("test_tab", 
00155                 LLRect(LEFT, y, RIGHT, BOTTOM),
00156                 LLTabContainer::TOP,
00157                 TRUE,   // bordered
00158                 FALSE); // horizontal
00159         addChild(tab);
00160         mTab = tab;
00161 
00162         //-----------------------------------------------------------------------
00163         // First tab container panel
00164         //-----------------------------------------------------------------------
00165         panel = new LLPanel("first_tab_panel",
00166                 LLRect(0, 400, 400, 0), // dummy rect
00167                 TRUE);  // bordered
00168         tab->addTabPanel(panel, "First", 
00169                 TRUE,   // select
00170                 onClickTab, this);
00171 
00172         y = panel->getRect().getHeight() - VPAD;
00173 
00174         text = new LLTextBox("unicode_text",
00175                 LLRect(LEFT, y, RIGHT, y-LINE),
00176                 LLString("File"),
00177                 LLFontGL::sSansSerif,
00178                 TRUE);  // mouse_opaque
00179         text->setToolTip(LLString("This should be Unicode text"));
00180         panel->addChild(text);
00181 
00182         y -= VPAD + LINE;
00183 
00184         btn = new LLButton("unicode_btn", LLRect(LEFT, y, LEFT+100, y-20));
00185         btn->setLabel(LLString("unicode"));
00186         panel->addChild(btn);
00187 
00188         y -= VPAD + 20;
00189 
00190         btn = new LLButton("image_btn",
00191                 LLRect(LEFT, y, LEFT+32, y-32),
00192                 "tool_zoom.tga",
00193                 "tool_zoom_active.tga",
00194                 "",     // control_name,
00195                 onClickButton, this,
00196                 LLFontGL::sSansSerifSmall);
00197         btn->setFollows(FOLLOWS_LEFT | FOLLOWS_TOP);
00198         panel->addChild(btn);
00199 
00200         y -= VPAD + 32;
00201 
00202         check = new LLCheckBoxCtrl("simple_check",
00203                 LLRect(LEFT, y, LEFT+150, y-LLCHECKBOXCTRL_HEIGHT),
00204                 "Simple Checkbox",
00205                 LLFontGL::sSansSerifSmall,
00206                 onCommitCheck, this,
00207                 TRUE,   // initial_value
00208                 FALSE,  // radio_style
00209                 "UIFloaterTestBool");   // control_which
00210         panel->addChild(check);
00211 
00212         y -= VPAD + LLCHECKBOXCTRL_HEIGHT;
00213 
00214         check = new LLCheckBoxCtrl("unicode_check",
00215                 LLRect(LEFT, y, LEFT+150, y-LLCHECKBOXCTRL_HEIGHT),
00216                 "TODO: Unicode Checkbox",
00217                 LLFontGL::sSansSerifSmall,
00218                 onCommitCheck, this,
00219                 TRUE,   // initial_value
00220                 FALSE,  // radio_style
00221                 "");    // control_which
00222         panel->addChild(check);
00223         mCheckUnicode = check;
00224 
00225         y -= VPAD + LLCHECKBOXCTRL_HEIGHT;
00226 
00227         combo = new LLComboBox("combo",
00228                 LLRect(LEFT, y, LEFT+100, y-LLCOMBOBOX_HEIGHT),
00229                 "Combobox Label",
00230                 onCommitCombo, this);
00231         combo->add("first item");
00232         combo->add("second item");
00233         combo->add("should go to the top", ADD_TOP);
00234         combo->add("disabled item", NULL, ADD_BOTTOM, FALSE);
00235         panel->addChild(combo);
00236 
00237         y -= VPAD + LLCOMBOBOX_HEIGHT;
00238 
00239         LLIconCtrl* icon = new LLIconCtrl(
00240                 "test_icon",
00241                 LLRect(LEFT, y, LEFT+32, y-32),
00242                 "object_cone.tga" );
00243         panel->addChild(icon);
00244         mIcon = icon;
00245 
00246         y -= VPAD + 32;
00247 
00248         LLLineEditor* line = new LLLineEditor(
00249                 "test_line",
00250                 LLRect(LEFT, y, LEFT+200, y-20),
00251                 "test some unicode text here",
00252                 LLFontGL::sSansSerif,
00253                 200,    // max_length_bytes
00254                 onCommitLine,
00255                 onKeyLine,
00256                 onFocusLostLine,
00257                 this);
00258         line->setHandleEditKeysDirectly(true);
00259         panel->addChild(line);
00260 
00261         y -= VPAD + 20;
00262 
00263         LLRadioGroup* group = new LLRadioGroup(
00264                 "radio_group",
00265                 LLRect(LEFT, y, LEFT+200, y - 50),
00266                 0,      // initial_index
00267                 onChangeRadioGroup, this,
00268                 TRUE);  // border
00269         panel->addChild(group);
00270 
00271         S32 yy = 100;
00272         group->addRadioButton("Radio1", "Radio 1", LLRect(0, yy, 200, yy-LINE), LLFontGL::sSansSerifSmall);
00273         yy -= LINE;
00274         group->addRadioButton("Radio2", "Radio 2", LLRect(0, yy, 200, yy-LINE), LLFontGL::sSansSerifSmall);
00275         yy -= LINE;
00276         group->addRadioButton("Radio3", "Radio 3", LLRect(0, yy, 200, yy-LINE), LLFontGL::sSansSerifSmall);
00277         yy -= LINE;
00278 
00279         //-----------------------------------------------------------------------
00280         // Second tab container panel
00281         //-----------------------------------------------------------------------
00282         panel = new LLPanel("second_tab_panel",
00283                 LLRect(0, 400, 400, 0), // dummy rect
00284                 TRUE);  // bordered
00285         tab->addTabPanel(panel, "Second", 
00286                 FALSE,  // select
00287                 onClickTab, this);
00288 
00289         y = panel->getRect().getHeight() - VPAD;
00290 
00291         btn = new LLButton("Simple Button",
00292                 LLRect(LEFT, y, LEFT+100, y - 20),
00293                 "",
00294                 onClickButton, this);
00295         btn->setFollows(FOLLOWS_TOP|FOLLOWS_LEFT);
00296         panel->addChild(btn);
00297         mBtnSimple = btn;
00298 
00299         //-----------------------------------------------------------------------
00300         // Hook us up with the floater view
00301         //-----------------------------------------------------------------------
00302         open();         /* Flawfinder: ignore */
00303         center();
00304 }
00305 
00306 // static
00307 void LLFloaterTestImpl::onClickButton(void*)
00308 {
00309         llinfos << "button clicked" << llendl;
00310 }
00311 
00312 // static
00313 void LLFloaterTestImpl::onClickText(void*)
00314 {
00315         llinfos << "text clicked" << llendl;
00316 }
00317 
00318 // static
00319 void LLFloaterTestImpl::onClickTab(void*, bool)
00320 {
00321         llinfos << "click tab" << llendl;
00322 }
00323 
00324 // static
00325 void LLFloaterTestImpl::onCommitCheck(LLUICtrl*, void*)
00326 {
00327         llinfos << "commit check" << llendl;
00328 }
00329 
00330 // static
00331 void LLFloaterTestImpl::onCommitCombo(LLUICtrl* ctrl, void*)
00332 {
00333         LLComboBox* combo = (LLComboBox*)ctrl;
00334         LLString name = combo->getSimple();
00335         LLSD value = combo->getValue();
00336         llinfos << "commit combo name " << name << " value " << value.asString() << llendl;
00337 }
00338 
00339 // static
00340 void LLFloaterTestImpl::onCommitLine(LLUICtrl*, void*)
00341 {
00342         llinfos << "commit line editor" << llendl;
00343 }
00344 
00345 // static
00346 void LLFloaterTestImpl::onKeyLine(LLLineEditor*, void*)
00347 {
00348         llinfos << "keystroke line editor" << llendl;
00349 }
00350 
00351 // static
00352 void LLFloaterTestImpl::onFocusLostLine(LLFocusableElement*, void*)
00353 {
00354         llinfos << "focus lost line editor" << llendl;
00355 }
00356 
00357 // static
00358 void LLFloaterTestImpl::onChangeRadioGroup(LLUICtrl*, void*)
00359 {
00360         llinfos << "change radio group" << llendl;
00361 }
00362 
00363 //---------------------------------------------------------------------------
00364 
00365 // static
00366 void LLFloaterTest::show(void*)
00367 {
00368         new LLFloaterTest();
00369 }
00370 
00371 LLFloaterTest::LLFloaterTest()
00372 :       impl(* new LLFloaterTestImpl)
00373 {
00374 }
00375 
00376 LLFloaterTest::~LLFloaterTest()
00377 {
00378         delete &impl;
00379 }
00380 
00381 //---------------------------------------------------------------------------
00382 
00383 LLFloaterSimple::LLFloaterSimple(const std::string& xml_filename)
00384 {
00385         LLUICtrlFactory::getInstance()->buildFloater(this, xml_filename);
00386 }

Generated on Fri May 16 08:33:31 2008 for SecondLife by  doxygen 1.5.5