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