/** Searches for a ScrollBar and a TextArea to link them */ void Window::Link(unsigned short SBID, unsigned short TAID) { ScrollBar* sb = NULL; TextArea* ta = NULL; std::vector< Control*>::iterator m; for (m = Controls.begin(); m != Controls.end(); m++) { if (( *m )->Owner != this) continue; if (( *m )->ControlType == IE_GUI_SCROLLBAR) { if (( *m )->ControlID == SBID) { sb = ( ScrollBar * ) ( *m ); if (ta != NULL) break; } } else if (( *m )->ControlType == IE_GUI_TEXTAREA) { if (( *m )->ControlID == TAID) { ta = ( TextArea * ) ( *m ); if (sb != NULL) break; } } } if (sb && ta) { sb->ta = ta; ta->SetScrollBar( sb ); } }
bool Summarizer::mouseOver(TextArea& textarea, vec2 mouse) { mouseover=false; if(right && mouse.x < pos_x) return false; if(mouse.y < top_gap || mouse.y > (display.height-bottom_gap)) return false; if(items.empty()) return false; float y = mouse.y; for(SummItem& item : items) { if(item.departing) continue; if(item.pos.y<=y && (item.pos.y+font.getMaxHeight()+4) > y) { if(mouse.x< item.pos.x || mouse.x > item.pos.x + item.width) continue; std::vector<std::string> content; textarea.setText(item.unit.expanded); textarea.setColour(vec3(item.colour)); textarea.setPos(mouse); mouseover=true; return true; } } return false; }
/** Provides per-pixel scrolling. Top = 0px */ void ScrollBar::SetPosForY(unsigned short y) { if (Value > 1) {// if the value is 1 we are simultaniously at both the top and bottom so there is nothing to do unsigned short YMax = Height - GetFrameHeight(IE_GUI_SCROLLBAR_SLIDER) - GetFrameHeight(IE_GUI_SCROLLBAR_DOWN_UNPRESSED) - GetFrameHeight(IE_GUI_SCROLLBAR_UP_UNPRESSED); if (y > YMax) y = YMax; if (stepPx) { unsigned short NewPos = (unsigned short)(y / stepPx); if (Pos != NewPos) { SetPos( NewPos, false ); } if (ta) { // we must "scale" the pixels the slider moves TextArea* t = (TextArea*) ta; unsigned int taY = y * (t->GetRowHeight() / stepPx); t->ScrollToY(taY, this); } SliderYPos = (y + GetFrameHeight(IE_GUI_SCROLLBAR_UP_UNPRESSED) - 0); core->RedrawAll(); } }else{ // top is our default position SliderYPos = GetFrameHeight(IE_GUI_SCROLLBAR_UP_UNPRESSED); } }
bool RequestBall::mouseOver(TextArea& textarea, vec2& mouse) { //within 3 pixels vec2 from_mouse = pos - mouse; if( glm::dot(from_mouse, from_mouse) < 36.0f) { std::vector<std::string> content; content.push_back( std::string( le->path ) ); content.push_back( " " ); if(le->vhost.size()>0) content.push_back( std::string("Virtual-Host: ") + le->vhost ); content.push_back( std::string("Remote-Host: ") + le->hostname ); if(le->referrer.size()>0) content.push_back( std::string("Referrer: ") + le->referrer ); if(le->user_agent.size()>0) content.push_back( std::string("User-Agent: ") + le->user_agent ); textarea.setText(content); textarea.setPos(mouse); textarea.setColour(colour); return true; } return false; }
MenuItem* GOFactory::createMenuItem( fVector3 p_position, fVector2 p_size, string p_text, fVector2 p_textOffset, fVector2 p_fontSize, string p_bgTexPath) { float scrW = GAME_FAIL; float scrH = GAME_FAIL; if(m_io != NULL) { scrW = (float)m_io->getScreenWidth(); scrH = (float)m_io->getScreenHeight(); } fVector2 finalPos, finalTextOffset; finalPos.x = scrW * (p_position.x); finalPos.y = scrH * (p_position.y); finalTextOffset.x = scrW * (p_textOffset.x); finalTextOffset.y = scrH * (p_textOffset.y); SpriteInfo* spriteInfo = NULL; if( p_bgTexPath != "" ) spriteInfo = CreateSpriteInfo( p_bgTexPath, fVector3(finalPos.x, finalPos.y, p_position.z), fVector2(p_size.x*scrW, p_size.y*scrH), NULL ); GlyphMap* font = NULL; TextArea* text = NULL; if( p_text != "" ) { text = createMenuItemTextArea(p_position, p_text, p_textOffset, p_fontSize ); text->setText( p_text ); } return new MenuItem( spriteInfo, text, finalPos, finalTextOffset ); }
void HomeLayout::onTweetPosted(AbstractObjectBase* tweet) { Q_UNUSED(tweet); RequestEnvelope *env = qobject_cast<RequestEnvelope *>(sender()); disconnect(env, SIGNAL(requestComplete(AbstractObjectBase*)), this, SLOT(onTweetPosted(AbstractObjectBase*))); qDebug() << "Successfully posted the tweet"; TextArea *tweetText = root()->findChild<TextArea*>("tweetText"); tweetText->setText("Tweet Posted!"); }
FormElement *TextareaFactory::CreateElement(string name, string value) { TextArea *retVal = new TextArea(); retVal->SetName(name); retVal->SetValue(value); return retVal; }
ActivityIndicatorRecipe::ActivityIndicatorRecipe(Container *parent) : CustomControl(parent) { // The recipe Container Container *recipeContainer = new Container(); recipeContainer->setLeftPadding(20.0); recipeContainer->setRightPadding(20.0); // The introduction text TextArea *introText = new TextArea(); introText->setText((const QString) "This is a milk boiling simulator recipe"); introText->setEditable(false); introText->textStyle()->setBase(SystemDefaults::TextStyles::bodyText()); introText->setBottomMargin(100); Container* smashContainer = new Container(); smashContainer->setLayout(new DockLayout()); // Create the unbroken egg ImageView mUnbroken = ImageView::create("asset:///images/stockcurve/egg.png"); // Center the unbroken egg image mUnbroken->setHorizontalAlignment(HorizontalAlignment::Center); mUnbroken->setVerticalAlignment(VerticalAlignment::Center); // Since this broken egg image is on top of the unbroken egg image, we can hide // this image by changing the opacity value of this image. mBroken = ImageView::create("asset:///images/stockcurve/broken_egg.png").opacity(0.0); // Center the brown egg image (same as unbroken one) mBroken->setHorizontalAlignment(HorizontalAlignment::Center); mBroken->setVerticalAlignment(VerticalAlignment::Center); mActivityIndicator = new ActivityIndicator(); mActivityIndicator->setPreferredSize(130, 130); smashContainer->add(mUnbroken); smashContainer->add(mActivityIndicator); smashContainer->add(mBroken); mButton = new Button(); mButton->setTopMargin(100); mButton->setText((const QString) "start cooking"); connect(mButton, SIGNAL(clicked()), this, SLOT(onClicked())); // Add the controls to the recipe Container and set it as root. recipeContainer->add(introText); recipeContainer->add(smashContainer); recipeContainer->add(mButton); setRoot(recipeContainer); }
TupCrashWidget::TupCrashWidget(int sig) : QDialog(0), m_sig(sig) { setModal(true); setWindowTitle(CHANDLER->title()); setWindowIcon(QPixmap(THEME_DIR + "icons/skull.png")); m_layout = new QVBoxLayout(this); m_tabber = new QTabWidget(this); m_layout->addWidget(m_tabber); QWidget *page1 = new QWidget; QVBoxLayout *page1layout = new QVBoxLayout(page1); QLabel *message = new QLabel("<font color="+CHANDLER->messageColor().name()+">"+ CHANDLER->message()+"</color>"); page1layout->addWidget(message); QHBoxLayout *hbox = new QHBoxLayout; QString text = CHANDLER->defaultText(); QImage img(CHANDLER->defaultImage()); if (CHANDLER->containsSignalEntry(sig)) { text = CHANDLER->signalText(sig); img = QImage(CHANDLER->signalImage(sig)); } QLabel *sigImg = new QLabel; sigImg->setPixmap(QPixmap::fromImage(img)); hbox->addWidget(sigImg); TextArea *sigText = new TextArea(); sigText->setHtml(text); hbox->addWidget(sigText); page1layout->addLayout(hbox); m_tabber->addTab(page1, tr("What's happening?")); QPushButton *launch = new QPushButton(CHANDLER->launchButtonLabel(),this); connect(launch, SIGNAL(clicked()), SLOT(restart())); m_layout->addWidget(launch); QPushButton *end = new QPushButton(CHANDLER->closeButtonLabel(),this); connect(end, SIGNAL(clicked()), SLOT(exit())); m_layout->addWidget(end); setLayout(m_layout); }
/** Sets a new position, relays the change to an associated textarea and calls any existing GUI OnChange callback */ void ScrollBar::SetPos(int NewPos) { if (Pos && ( Pos == NewPos )) { return; } Changed = true; Pos = (ieWord) NewPos; if (ta) { TextArea* t = ( TextArea* ) ta; t->SetRow( Pos ); } if (VarName[0] != 0) { core->GetDictionary()->SetAt( VarName, Pos ); } RunEventHandler( ScrollBarOnChange ); }
Container *Intro::setUpExampleUI() { // A small example UI, illustrating some of the core controls. // The UI is arranged using a Container with a stack layout. Container *exampleUI = new Container(); StackLayout *exampleUILayout = new StackLayout(); exampleUI->setLayout(exampleUILayout); // A TextArea with text input functionality TextArea *exampleTextArea = new TextArea(); exampleTextArea->textStyle()->setBase(SystemDefaults::TextStyles::bodyText()); exampleTextArea->setHorizontalAlignment(HorizontalAlignment::Fill); // An example of a Slider Slider *exampleSlider = new Slider(); exampleSlider->setValue(0.5f); exampleSlider->setHorizontalAlignment(HorizontalAlignment::Left); exampleSlider->setVerticalAlignment(VerticalAlignment::Bottom); // A ToggleButton ToggleButton *exampleToggle = new ToggleButton(); exampleToggle->setHorizontalAlignment(HorizontalAlignment::Right); // A regular Button Button *exampleButton = new Button(); exampleButton->setText("Button"); // Container for the buttons Container *buttonContainer = new Container(); DockLayout *buttonContainerLayout = new DockLayout(); buttonContainer->setLayout(buttonContainerLayout); buttonContainer->setHorizontalAlignment(HorizontalAlignment::Fill); // Adding the buttons to the container. buttonContainer->add(exampleToggle); buttonContainer->add(exampleButton); // Add the Controls to the Container, the layouting is done using // layout properties and margins of each control (see code above). exampleUI->add(exampleTextArea); exampleUI->add(exampleSlider); exampleUI->add(buttonContainer); return exampleUI; }
void DisplayMessage::DisplayString(const char* Text, Scriptable *target) const { Label *l = core->GetMessageLabel(); if (l) { l->SetText(Text); } TextArea *ta = core->GetMessageTextArea(); if (ta) { ta->AppendText( Text, -1 ); } else { if(target) { char *tmp = strdup(Text); target->DisplayHeadText(tmp); } } }
bool Paddle::mouseOver(TextArea& textarea, vec2& mouse) { if(pos.x <= mouse.x && pos.x + width >= mouse.x && abs(pos.y - mouse.y) < height/2) { std::vector<std::string> content; content.push_back( token ); textarea.setText(content); textarea.setPos(mouse); textarea.setColour(vec3(colour)); return true; } return false; }
void Window::RedrawControls(const char* VarName, unsigned int Sum) { for (unsigned int i = 0; i < Controls.size(); i++) { switch (Controls[i]->ControlType) { case IE_GUI_MAP: { MapControl *mc = ( MapControl* ) (Controls[i]); mc->RedrawMapControl( VarName, Sum ); break; } case IE_GUI_BUTTON: { Button* bt = ( Button* ) ( Controls[i] ); bt->RedrawButton( VarName, Sum ); break; } case IE_GUI_TEXTAREA: { TextArea* pb = ( TextArea* ) ( Controls[i] ); pb->RedrawTextArea( VarName, Sum ); break; } case IE_GUI_PROGRESSBAR: { Progressbar* pb = ( Progressbar* ) ( Controls[i] ); pb->RedrawProgressbar( VarName, Sum ); break; } case IE_GUI_SLIDER: { Slider* sl = ( Slider* ) ( Controls[i] ); sl->RedrawSlider( VarName, Sum ); break; } case IE_GUI_SCROLLBAR: { ScrollBar* sb = ( ScrollBar* ) ( Controls[i] ); sb->RedrawScrollBar( VarName, Sum ); break; } } } }
string DialogFrame::showInputDialog(Component parentComponent, string option, string title, string message) { //parentComponent.drawWin(); string input; ConsoleWordWrapper::formatString(&message, 80); int dLength = getLengthFromString(message); int dWidth = getWidthFromString(message); int centerX = (parentComponent.getLength() / 2) - (dLength / 2); int centerY = (parentComponent.getWidth() / 2) - (dWidth / 2)-2; int startLine; Frame dFrame(centerX, centerY, dLength, dWidth+4, title); dFrame.setBackground(COLOR_WHITE); TextArea dTextArea = dFrame.addTextArea(); if (message.length() <= 80) { startLine = (dTextArea.getLength() / 2) - (message.length() / 2); } dTextArea.addText(startLine, 0, message); InputField dInputField(centerX + 5, dFrame.getBegY() + dFrame.getWidth()-6, dLength - 10, 3); //std::vector<std::string> bNames{ "Continue" }; dFrame.setSize(dFrame.getLength(), dFrame.getWidth() + 3); ButtonMenu dButtonMenu(dFrame.getBegX(), dFrame.getBegY() + dFrame.getWidth() - 4, dFrame.getLength(), 3, option); input = dInputField.getInput(); werase(dFrame.component); return input; }
ProgressIndicatorRecipe::ProgressIndicatorRecipe(Container *parent) : CustomControl(parent) { // The recipe Container Container *recipeContainer = Container::create().left(20.0).right(20.0); // The introduction text TextArea *introText = new TextArea(); introText->setText((const QString) "Drag the slider to change the ProgressIndicator"); introText->setEditable(false); introText->textStyle()->setBase(SystemDefaults::TextStyles::bodyText()); introText->setBottomMargin(100); mProgressIndicator = new ProgressIndicator(); mProgressIndicator->setFromValue(0); mProgressIndicator->setToValue(100); connect(mProgressIndicator, SIGNAL(valueChanged(float)), this, SLOT(onValueChanged(float))); // Create a Slider and connect a slot function to the signal for Slider value changing. Slider *slider = new Slider(); slider->setTopMargin(100); slider->setFromValue(0); slider->setToValue(100); // Connect the Slider value directly to the value property of the ProgressIndicator. connect(slider, SIGNAL(immediateValueChanged(float)), mProgressIndicator, SLOT(setValue(float))); // Create a Slider and connect a slot function to the signal for Slider value changing. mButton = new Button(); mButton->setText((const QString) "Pause"); connect(mButton, SIGNAL(clicked()), this, SLOT(onClicked())); // Add the controls to the recipe Container and set it as root. recipeContainer->add(introText); recipeContainer->add(mProgressIndicator); recipeContainer->add(slider); recipeContainer->add(mButton); setRoot(recipeContainer); }
void DialogFrame::showMessageDialog(Component parentComponent, string option, string title, string message) { //parentComponent.drawWin(); ConsoleWordWrapper::formatString(&message, 80); int dLength = getLengthFromString(message); int dWidth = getWidthFromString(message); int centerX = (parentComponent.getLength() / 2) - (dLength/2); int centerY = (parentComponent.getWidth() / 2) - (dWidth/2)-2; int startLine; Frame dFrame(centerX, centerY, dLength, dWidth, title); dFrame.setBackground(COLOR_WHITE); TextArea dTextArea = dFrame.addTextArea(); if (message.length() <= 80) { startLine = (dTextArea.getLength() / 2) - (message.length() / 2); } //startLine = 0; dTextArea.addText(startLine, 0, message); //Need to return the button menu itself from frame.h, but cant for some reason //dFrame.addButtonMenu("< Continue >"); //dFrame.setSize(dFrame.getLength(), dFrame.getWidth() + 4); dFrame.setSize(dFrame.getLength(), dFrame.getWidth() + 3); ButtonMenu dButtonMenu(dFrame.getBegX(), dFrame.getBegY() + dFrame.getWidth() - 4, dFrame.getLength(), 3, option); dButtonMenu.getButtonChoice(); werase(dFrame.component); }
void TupCrashWidget::addBacktracePage(const QString &execInfo, const QString &backtrace) { #ifdef K_DEBUG T_FUNCINFO << execInfo << " " << backtrace; #endif QWidget *btPage = new QWidget; QVBoxLayout *layout = new QVBoxLayout(btPage); layout->addWidget(new QLabel(tr("Executable information"))); TextArea *fileInfo = new TextArea; fileInfo->setHtml(execInfo); layout->addWidget(fileInfo); layout->addWidget(new QLabel(tr("Backtrace"))); TextArea *btInfo = new TextArea; btInfo->setHtml(backtrace); layout->addWidget(btInfo); m_tabber->addTab(btPage, tr("Backtrace")); }
int main(int argc, char * argv[]) { Font *font(FontFactory::create( (unsigned char*)_binary_sans_set_bin_start, (unsigned char*)_binary_sans_map_bin_start)); TextAreaFactory::setFont(font); //TextAreaFactory::usePaletteData((const char*)_binary_vera_pal_bin_start, 32); Keyboard * keyBoard = new Keyboard(); ScrollPane scrollPane; keyBoard->setTopLevel(&scrollPane); #if 1 TextField * tf = new TextField("Enter the value here. This line is too big to fit in"); TextField * passwd = new TextField(std::string()); RichTextArea * rich = (RichTextArea*)TextAreaFactory::create(TextAreaFactory::TXT_RICH); Button * goBtn = new Button("Go"); rich->appendText("This is some long text "); passwd->setSize(60,18); scrollPane.setTopLevel(); scrollPane.add(rich); scrollPane.add(passwd); scrollPane.add(goBtn); scrollPane.setSize(Canvas::instance().width(),Canvas::instance().height()); scrollPane.add(tf); scrollPane.setScrollIncrement(13); #else RichTextArea * rich = (RichTextArea*)TextAreaFactory::create(TextAreaFactory::TXT_RICH); TextArea * t = TextAreaFactory::create(); EditableTextArea * t2 = (EditableTextArea*)TextAreaFactory::create(TextAreaFactory::TXT_EDIT); // t2->setBackgroundColor(Color(31,31,0)); ScrollPane * subPane = new ScrollPane; subPane->add(t2); subPane->setTopLevel(false); subPane->setSize(Canvas::instance().width(),Canvas::instance().height()); subPane->setScrollIncrement(t2->font().height()); subPane->setStretchChildren(true); ComboBox * emptyCombo = new ComboBox(); ComboBox * oneValCombo = new ComboBox(); ComboBox * combo = new ComboBox(); combo->setSize(60, 18); ComboBox * combo2 = new ComboBox(); combo2->setSize(90, 18); std::string str("Hello World"); Button * b1 = new Button(str); str = "Combo box!"; oneValCombo->addItem(str); combo->addItem(str); combo2->addItem(str); combo2->addItem(str); str = "Another One - with very wide text"; Button * b2 = new Button(str); combo->addItem(str); combo2->addItem(str); combo2->addItem(str); str = "Three- wide, but fixed width"; Button * b3 = new Button(str); b3->setSize(60, 18); combo2->addItem(str); combo2->addItem(str); str = "Go"; Button * b4 = new Button(str); //b4->setSize(6*13, 10); str = "Last one!"; Button * b5 = new Button(str); combo->addItem(str); combo2->addItem(str); combo2->addItem(str); t2->setListener(keyBoard); str = "A text field that has a very, very long and pointless string"; TextField * tf1 = new TextField(str); tf1->setSize(160, 18); tf1->setListener(keyBoard); combo2->addItem(str); TextArea * rbLabel = TextAreaFactory::create(); str = "Radio button label."; rbLabel->appendText(str); TextArea * cbLabel = TextAreaFactory::create(); str = "CheckBox label."; cbLabel->appendText(str); RadioButton * rb = new RadioButton(); RadioButton * rb2 = new RadioButton(); RadioButton * rb3 = new RadioButton(); CheckBox * cb = new CheckBox(); ButtonGroup bg; bg.add(rb); bg.add(rb2); bg.add(rb3); keyBoard->setTopLevel(&scrollPane); scrollPane.setTopLevel(); scrollPane.add(rich); scrollPane.add(t); scrollPane.add(b1); scrollPane.add(b2); scrollPane.add(b3); scrollPane.add(tf1); scrollPane.add(b4); scrollPane.add(emptyCombo); scrollPane.add(oneValCombo); scrollPane.add(combo2); scrollPane.add(rb); scrollPane.add(rb2); scrollPane.add(rb3); scrollPane.add(rbLabel); scrollPane.add(cb); scrollPane.add(cbLabel); scrollPane.add(subPane); scrollPane.add(combo); scrollPane.add(b5); scrollPane.setSize(Canvas::instance().width(),Canvas::instance().height()); scrollPane.setScrollIncrement(t->font().height()); std::string richText1("This is normal text. "); std::string richText2("This is a link."); std::string richText3("Longer text, but still normal. "); std::string richText4("Normal text. "); std::string richText5("Link text. "); rich->appendText(richText1); rich->insertNewline(); rich->appendText(richText1); rich->appendText(richText1); rich->appendText(richText3); rich->appendText(richText4); rich->addLink("www.link1.com"); rich->appendText(richText2); rich->endLink(); rich->appendText(richText3); rich->appendText(richText1); rich->addLink("www.link2.com"); rich->appendText(richText5); rich->endLink(); std::string s(_binary_test_map_bin_start, 1000); t->appendText(s); std::string s2(&_binary_test_map_bin_start[1200], 1300); t2->appendText(s2); subPane->setSize(t2->width(), 100); t2->setParentScroller(subPane); #endif scrollPane.setLocation(0,0); scrollPane.setSize(Canvas::instance().width(),Canvas::instance().height()); bool needsPainting = true; while(true) { swiWaitForVBlank(); scanKeys(); u16 keys = keysDownRepeat(); //u16 keys = keysHeld(); if (keys & KEY_UP) { scrollPane.up(); scrollPane.up(); needsPainting = true; } if (keys & KEY_DOWN) { scrollPane.down(); scrollPane.down(); needsPainting = true; } if (keys & KEY_X) { //printf("%s\n",t2->asString().c_str()); break; } if (keys & KEY_Y) { scrollPane.setVisible(not scrollPane.visible()); keyBoard->setVisible(not keyBoard->visible()); needsPainting = true; } if (keys & KEY_TOUCH) { touchPosition tp; touchRead(&tp); Stylus stylus; stylus.update(Stylus::DOWN, true, tp.px, tp.py+SCREEN_HEIGHT); needsPainting = keyBoard->dirty(); if (not needsPainting) needsPainting = scrollPane.dirty(); } needsPainting |= keyBoard->tick(); if (needsPainting) { scrollPane.paint(scrollPane.preferredSize()); keyBoard->paint(scrollPane.preferredSize()); Canvas::instance().endPaint(); } needsPainting = false; } delete keyBoard; }
InputRecipe::InputRecipe(Container *parent) : CustomControl(parent) { Container *recipeContainer = new Container(); StackLayout *recipeLayout = new StackLayout(); recipeContainer->setLayout(recipeLayout); recipeLayout->setLeftPadding(80); recipeLayout->setRightPadding(80); // Label used to display the entered text. mInputLabel = new Label(); mInputLabel->setText((const QString) " "); mInputLabel->setLayoutProperties( StackLayoutProperties::create().horizontal(HorizontalAlignment::Fill)); mInputLabel->setBottomMargin(50.0); mInputLabel->textStyle()->setBase(SystemDefaults::TextStyles::bodyText()); // A multi line text input. TextArea *textArea = new TextArea(); textArea->setHintText("Enter text into multi-line TextArea"); textArea->setMinHeight(120.0f); textArea->setMaxHeight(200.0f); textArea->setPreferredHeight(0); textArea->setBottomMargin(50.0); textArea->textStyle()->setBase(SystemDefaults::TextStyles::bodyText()); textArea->setLayoutProperties( StackLayoutProperties::create().horizontal(HorizontalAlignment::Fill)); // Connect to the textChanged (to update text). connect(textArea, SIGNAL(textChanging(const QString &)), this, SLOT(onTextChanging(const QString &))); // A single line input field with a clear functionality. TextField *textField = new TextField(); textField->setHintText("Enter text into a single line TextField"); textField->setLayoutProperties( StackLayoutProperties::create().horizontal(HorizontalAlignment::Fill)); textField->setBottomMargin(50.0); // Connect to the textChanged (to update text). connect(textField, SIGNAL(textChanging(const QString &)), this, SLOT(onTextChanging(const QString &))); // A disabled text field. TextField *disabledTextField = new TextField(); disabledTextField->setHintText("This is a disabled text field"); disabledTextField->setEnabled(false); disabledTextField->setLayoutProperties( StackLayoutProperties::create().horizontal(HorizontalAlignment::Fill)); disabledTextField->setBottomMargin(50.0); // Add the controls to the recipe Container and set it as the CustomControl root. recipeContainer->add(mInputLabel); recipeContainer->add(textField); recipeContainer->add(disabledTextField); recipeContainer->add(textArea); //recipeContainer->add(inputContainer); setRoot(recipeContainer); }
/** Returns the i-th window in the Previously Loaded Stream */ Window* CHUImporter::GetWindow(unsigned int wid) { ieWord WindowID, XPos, YPos, Width, Height, BackGround; ieWord ControlsCount, FirstControl; ieResRef MosFile; unsigned int i; if (!str) { Log(ERROR, "CHUImporter", "No data stream to read from, skipping controls"); return NULL; } bool found = false; for (unsigned int c = 0; c < WindowCount; c++) { str->Seek( WEOffset + ( 0x1c * c ), GEM_STREAM_START ); str->ReadWord( &WindowID ); if (WindowID == wid) { found = true; break; } } if (!found) { return NULL; } str->Seek( 2, GEM_CURRENT_POS ); str->ReadWord( &XPos ); str->ReadWord( &YPos ); str->ReadWord( &Width ); str->ReadWord( &Height ); str->ReadWord( &BackGround ); str->ReadWord( &ControlsCount ); str->ReadResRef( MosFile ); str->ReadWord( &FirstControl ); Window* win = new Window( WindowID, XPos, YPos, Width, Height ); if (BackGround == 1) { ResourceHolder<ImageMgr> mos(MosFile); if (mos != NULL) { win->SetBackGround( mos->GetSprite2D(), true ); } } if (!core->IsAvailable( IE_BAM_CLASS_ID )) { Log(ERROR, "CHUImporter", "No BAM Importer Available, skipping controls"); return win; } for (i = 0; i < ControlsCount; i++) { str->Seek( CTOffset + ( ( FirstControl + i ) * 8 ), GEM_STREAM_START ); ieDword COffset, CLength, ControlID; Region ctrlFrame; ieWord tmp; ieByte ControlType, temp; str->ReadDword( &COffset ); str->ReadDword( &CLength ); str->Seek( COffset, GEM_STREAM_START ); str->ReadDword( &ControlID ); str->ReadWord( &tmp ); ctrlFrame.x = tmp; str->ReadWord( &tmp); ctrlFrame.y = tmp; str->ReadWord( &tmp ); ctrlFrame.w = tmp; str->ReadWord( &tmp ); ctrlFrame.h = tmp; str->Read( &ControlType, 1 ); str->Read( &temp, 1 ); switch (ControlType) { case IE_GUI_BUTTON: { //Button Button* btn = new Button(ctrlFrame); btn->ControlID = ControlID; ieResRef BAMFile; ieByte Cycle, tmp; ieDword Flags; ieByte UnpressedIndex, x1; ieByte PressedIndex, x2; ieByte SelectedIndex, y1; ieByte DisabledIndex, y2; str->ReadResRef( BAMFile ); str->Read( &Cycle, 1 ); str->Read( &tmp, 1 ); Flags = ((ieDword) tmp)<<8; str->Read( &UnpressedIndex, 1 ); str->Read( &x1, 1 ); str->Read( &PressedIndex, 1 ); str->Read( &x2, 1 ); str->Read( &SelectedIndex, 1 ); str->Read( &y1, 1 ); str->Read( &DisabledIndex, 1 ); str->Read( &y2, 1 ); btn->Owner = win; /** Justification comes from the .chu, other bits are set by script */ if (!Width) { btn->SetFlags(IE_GUI_BUTTON_NO_IMAGE, BM_OR); } if (core->HasFeature(GF_UPPER_BUTTON_TEXT)) { btn->SetFlags(IE_GUI_BUTTON_CAPS, BM_OR); } btn->SetFlags( Flags, BM_OR ); if (Flags & IE_GUI_BUTTON_ANCHOR) { btn->SetAnchor(x1 | (x2<<8), y1 | (y2<<8)); } if (strnicmp( BAMFile, "guictrl\0", 8 ) == 0) { if (UnpressedIndex == 0) { //printMessage("CHUImporter", "Special Button Control, Skipping Image Loading\n",GREEN ); win->AddControl( btn ); break; } } AnimationFactory* bam = ( AnimationFactory* ) gamedata->GetFactoryResource( BAMFile, IE_BAM_CLASS_ID, IE_NORMAL ); if (!bam ) { Log(ERROR, "CHUImporter", "Cannot Load Button Images, skipping control"); /* IceWind Dale 2 has fake BAM ResRefs for some Buttons, this will handle bad ResRefs */ win->AddControl( btn ); break; } /** Cycle is only a byte for buttons */ Sprite2D* tspr = bam->GetFrame( UnpressedIndex, (unsigned char) Cycle ); btn->SetImage( BUTTON_IMAGE_UNPRESSED, tspr ); tspr = bam->GetFrame( PressedIndex, Cycle ); btn->SetImage( BUTTON_IMAGE_PRESSED, tspr ); //ignorebuttonframes is a terrible hack if (core->HasFeature( GF_IGNORE_BUTTON_FRAMES) ) { if (bam->GetCycleSize(Cycle) == 4 ) SelectedIndex=2; } tspr = bam->GetFrame( SelectedIndex, (unsigned char) Cycle ); btn->SetImage( BUTTON_IMAGE_SELECTED, tspr ); if (core->HasFeature( GF_IGNORE_BUTTON_FRAMES) ) { if (bam->GetCycleSize( (unsigned char) Cycle) == 4 ) DisabledIndex=3; } tspr = bam->GetFrame( DisabledIndex, (unsigned char) Cycle ); btn->SetImage( BUTTON_IMAGE_DISABLED, tspr ); win->AddControl( btn ); } break; case IE_GUI_PROGRESSBAR: { //GemRB specific, progressbar ieResRef MOSFile, MOSFile2; ieResRef BAMFile; ieWord KnobXPos, KnobYPos; ieWord CapXPos, CapYPos; ieWord KnobStepsCount; ieWord Cycle; str->ReadResRef( MOSFile ); str->ReadResRef( MOSFile2 ); str->ReadResRef( BAMFile ); str->ReadWord( &KnobStepsCount ); str->ReadWord( &Cycle ); str->ReadWord( &KnobXPos ); str->ReadWord( &KnobYPos ); str->ReadWord( &CapXPos ); str->ReadWord( &CapYPos ); Progressbar* pbar = new Progressbar(ctrlFrame, KnobStepsCount, true ); pbar->ControlID = ControlID; pbar->SetSliderPos( KnobXPos, KnobYPos, CapXPos, CapYPos ); Sprite2D* img = NULL; Sprite2D* img2 = NULL; if ( MOSFile[0] ) { ResourceHolder<ImageMgr> mos(MOSFile); img = mos->GetSprite2D(); } if ( MOSFile2[0] ) { ResourceHolder<ImageMgr> mos(MOSFile2); img2 = mos->GetSprite2D(); } pbar->SetImage( img, img2 ); if( KnobStepsCount ) { /* getting the bam */ AnimationFactory *af = (AnimationFactory *) gamedata->GetFactoryResource(BAMFile, IE_BAM_CLASS_ID ); /* Getting the Cycle of the bam */ pbar->SetAnimation(af->GetCycle( Cycle & 0xff ) ); } else { ResourceHolder<ImageMgr> mos(BAMFile); Sprite2D* img3 = mos->GetSprite2D(); pbar->SetBarCap( img3 ); } win->AddControl( pbar ); } break; case IE_GUI_SLIDER: { //Slider ieResRef MOSFile, BAMFile; ieWord Cycle, Knob, GrabbedKnob; ieWord KnobXPos, KnobYPos, KnobStep, KnobStepsCount; str->ReadResRef( MOSFile ); str->ReadResRef( BAMFile ); str->ReadWord( &Cycle ); str->ReadWord( &Knob ); str->ReadWord( &GrabbedKnob ); str->ReadWord( &KnobXPos ); str->ReadWord( &KnobYPos ); str->ReadWord( &KnobStep ); str->ReadWord( &KnobStepsCount ); Slider* sldr = new Slider( ctrlFrame, KnobXPos, KnobYPos, KnobStep, KnobStepsCount, true ); sldr->ControlID = ControlID; ResourceHolder<ImageMgr> mos(MOSFile); Sprite2D* img = mos->GetSprite2D(); sldr->SetImage( IE_GUI_SLIDER_BACKGROUND, img); AnimationFactory* bam = ( AnimationFactory* ) gamedata->GetFactoryResource( BAMFile, IE_BAM_CLASS_ID, IE_NORMAL ); if( bam ) { img = bam->GetFrame( Knob, 0 ); sldr->SetImage( IE_GUI_SLIDER_KNOB, img ); img = bam->GetFrame( GrabbedKnob, 0 ); sldr->SetImage( IE_GUI_SLIDER_GRABBEDKNOB, img ); } else { sldr->SetState(IE_GUI_SLIDER_BACKGROUND); } win->AddControl( sldr ); } break; case IE_GUI_EDIT: { //Text Edit ieResRef BGMos; ieResRef FontResRef, CursorResRef; ieWord maxInput; ieWord CurCycle, CurFrame; ieWord PosX, PosY; ieWord Pos2X, Pos2Y; ieVariable Initial; str->ReadResRef( BGMos ); //These are two more MOS resrefs, probably unused str->Seek( 16, GEM_CURRENT_POS ); str->ReadResRef( CursorResRef ); str->ReadWord( &CurCycle ); str->ReadWord( &CurFrame ); str->ReadWord( &PosX ); str->ReadWord( &PosY ); //FIXME: I still don't know what to do with this point //Contrary to forum posts, it is definitely not a scrollbar ID str->ReadWord( &Pos2X ); str->ReadWord( &Pos2Y ); str->ReadResRef( FontResRef ); //this field is still unknown or unused str->Seek( 2, GEM_CURRENT_POS ); //This is really a text field, but apparently the original engine //always writes it over, and never uses it str->Read( Initial, 32 ); Initial[32]=0; str->ReadWord( &maxInput ); Font* fnt = core->GetFont( FontResRef ); AnimationFactory* bam = ( AnimationFactory* ) gamedata->GetFactoryResource( CursorResRef, IE_BAM_CLASS_ID, IE_NORMAL ); Sprite2D *cursor = NULL; if (bam) { cursor = bam->GetFrame( CurCycle, CurFrame ); } ResourceHolder<ImageMgr> mos(BGMos); Sprite2D *img = NULL; if(mos) { img = mos->GetSprite2D(); } TextEdit* te = new TextEdit( ctrlFrame, maxInput, PosX, PosY ); te->ControlID = ControlID; te->SetFont( fnt ); te->SetCursor( cursor ); te->SetBackGround( img ); //The original engine always seems to ignore this textfield //te->SetText (Initial ); win->AddControl( te ); } break; case IE_GUI_TEXTAREA: { //Text Area ieResRef FontResRef, InitResRef; Color fore, init, back; ieWord SBID; str->ReadResRef( FontResRef ); str->ReadResRef( InitResRef ); Font* fnt = core->GetFont( FontResRef ); Font* ini = core->GetFont( InitResRef ); str->Read( &fore, 4 ); str->Read( &init, 4 ); str->Read( &back, 4 ); str->ReadWord( &SBID ); TextArea* ta = new TextArea( ctrlFrame, fore, init, back ); ta->ControlID = ControlID; ta->SetFonts( ini, fnt ); win->AddControl( ta ); if (SBID != 0xffff) win->Link( SBID, ( unsigned short ) ControlID ); } break; case IE_GUI_LABEL: { //Label ieResRef FontResRef; ieStrRef StrRef; RevColor fore, back; ieWord alignment; str->ReadDword( &StrRef ); str->ReadResRef( FontResRef ); Font* fnt = core->GetFont( FontResRef ); str->Read( &fore, 4 ); str->Read( &back, 4 ); str->ReadWord( &alignment ); char* str = core->GetString( StrRef ); Label* lab = new Label( ctrlFrame, fnt, str ); core->FreeString( str ); lab->ControlID = ControlID; if (alignment & 1) { lab->useRGB = true; Color f, b; f.r = fore.b; f.g = fore.g; f.b = fore.r; f.a = 0; b.r = back.b; b.g = back.g; b.b = back.r; b.a = 0; lab->SetColor( f, b ); } int align = IE_FONT_ALIGN_CENTER; if (( alignment & 0x10 ) != 0) { align = IE_FONT_ALIGN_RIGHT; goto endvertical; } if (( alignment & 0x04 ) != 0) { goto endvertical; } if (( alignment & 0x08 ) != 0) { align = IE_FONT_ALIGN_LEFT; goto endvertical; } endvertical: if (( alignment & 0x20 ) != 0) { align |= IE_FONT_ALIGN_TOP; goto endalign; } if (( alignment & 0x80 ) != 0) { align |= IE_FONT_ALIGN_BOTTOM; } else { align |= IE_FONT_ALIGN_MIDDLE; } endalign: lab->SetAlignment( align ); win->AddControl( lab ); } break; case IE_GUI_SCROLLBAR: { //ScrollBar ieResRef BAMResRef; ieWord Cycle, TAID, imgIdx; str->ReadResRef( BAMResRef ); str->ReadWord( &Cycle ); AnimationFactory* bam = ( AnimationFactory* ) gamedata->GetFactoryResource( BAMResRef, IE_BAM_CLASS_ID, IE_NORMAL ); if (!bam) { Log(ERROR, "CHUImporter", "Unable to create scrollbar, no BAM: %s", BAMResRef); break; } Sprite2D* images[IE_SCROLLBAR_IMAGE_COUNT]; for (int i=0; i < IE_SCROLLBAR_IMAGE_COUNT; i++) { str->ReadWord( &imgIdx ); images[i] = bam->GetFrame( imgIdx, Cycle ); } str->ReadWord( &TAID ); ScrollBar* sbar = new ScrollBar(ctrlFrame, images); sbar->ControlID = ControlID; win->AddControl( sbar ); if (TAID != 0xffff) win->Link( ( unsigned short ) ControlID, TAID ); } break; default: Log(ERROR, "CHUImporter", "Control Not Supported"); } } return win; }
PanelCrashReport(UnexpectedThrowable PanelCrashReport::unexpectedthrowable) { setBackground(new Color(0x2e3444)); setLayout(new BorderLayout()); StringWriter stringwriter = new StringWriter(); unexpectedthrowable.field_6514_b.printStackTrace(new PrintWriter(stringwriter)); String s = stringwriter.toString(); String s1 = ""; String s2 = ""; try { s2 = (new StringBuilder()).append(s2).append("Generated ").append((new SimpleDateFormat()).format(new Date())).append("\n").toString(); s2 = (new StringBuilder()).append(s2).append("\n").toString(); s2 = (new StringBuilder()).append(s2).append("Minecraft: Minecraft Alpha v1.2.2 (Mrneo240 Custom v0.4)\n").toString(); s2 = (new StringBuilder()).append(s2).append("OS: ").append(System.getProperty("os.name")).append(" (").append(System.getProperty("os.arch")).append(") version ").append(System.getProperty("os.version")).append("\n").toString(); s2 = (new StringBuilder()).append(s2).append("Java: ").append(System.getProperty("java.version")).append(", ").append(System.getProperty("java.vendor")).append("\n").toString(); s2 = (new StringBuilder()).append(s2).append("VM: ").append(System.getProperty("java.vm.name")).append(" (").append(System.getProperty("java.vm.info")).append("), ").append(System.getProperty("java.vm.vendor")).append("\n").toString(); s2 = (new StringBuilder()).append(s2).append("LWJGL: ").append(Sys.getVersion()).append("\n").toString(); s1 = GL11.glGetString(7936); s2 = (new StringBuilder()).append(s2).append("OpenGL: ").append(GL11.glGetString(7937)).append(" version ").append(GL11.glGetString(7938)).append(", ").append(GL11.glGetString(7936)).append("\n").toString(); } catch(Throwable throwable) { s2 = (new StringBuilder()).append(s2).append("[failed to get system properties (").append(throwable).append(")]\n").toString(); } s2 = (new StringBuilder()).append(s2).append("\n").toString(); s2 = (new StringBuilder()).append(s2).append(s).toString(); String s3 = ""; s3 = (new StringBuilder()).append(s3).append("\n").toString(); s3 = (new StringBuilder()).append(s3).append("\n").toString(); if(s.contains("Pixel format not accelerated")) { s3 = (new StringBuilder()).append(s3).append(" Bad video card drivers! \n").toString(); s3 = (new StringBuilder()).append(s3).append(" ----------------------- \n").toString(); s3 = (new StringBuilder()).append(s3).append("\n").toString(); s3 = (new StringBuilder()).append(s3).append("Minecraft was unable to start because it failed to find an accelerated OpenGL mode.\n").toString(); s3 = (new StringBuilder()).append(s3).append("This can usually be fixed by updating the video card drivers.\n").toString(); if(s1.toLowerCase().contains("nvidia")) { s3 = (new StringBuilder()).append(s3).append("\n").toString(); s3 = (new StringBuilder()).append(s3).append("You might be able to find drivers for your video card here:\n").toString(); s3 = (new StringBuilder()).append(s3).append(" http://www.nvidia.com/\n").toString(); } else if(s1.toLowerCase().contains("ati")) { s3 = (new StringBuilder()).append(s3).append("\n").toString(); s3 = (new StringBuilder()).append(s3).append("You might be able to find drivers for your video card here:\n").toString(); s3 = (new StringBuilder()).append(s3).append(" http://www.amd.com/\n").toString(); } } else { s3 = (new StringBuilder()).append(s3).append(" Minecraft has crashed! \n").toString(); s3 = (new StringBuilder()).append(s3).append(" ---------------------- \n").toString(); s3 = (new StringBuilder()).append(s3).append("\n").toString(); s3 = (new StringBuilder()).append(s3).append("Minecraft has stopped running because it encountered a problem.\n").toString(); s3 = (new StringBuilder()).append(s3).append("\n").toString(); s3 = (new StringBuilder()).append(s3).append("If you wish to report this, please copy this entire text and email it to [email protected].\n").toString(); s3 = (new StringBuilder()).append(s3).append("Please include a description of what you did when the error occured.\n").toString(); } s3 = (new StringBuilder()).append(s3).append("\n").toString(); s3 = (new StringBuilder()).append(s3).append("\n").toString(); s3 = (new StringBuilder()).append(s3).append("\n").toString(); s3 = (new StringBuilder()).append(s3).append("--- BEGIN ERROR REPORT ").append(Integer.toHexString(s3.hashCode())).append(" --------\n").toString(); s3 = (new StringBuilder()).append(s3).append(s2).toString(); s3 = (new StringBuilder()).append(s3).append("--- END ERROR REPORT ").append(Integer.toHexString(s3.hashCode())).append(" ----------\n").toString(); s3 = (new StringBuilder()).append(s3).append("\n").toString(); s3 = (new StringBuilder()).append(s3).append("\n").toString(); TextArea textarea = new TextArea(s3, 0, 0, 1); textarea.setFont(new Font("Monospaced", 0, 12)); add(new CanvasMajongLogo(), "North"); add(new CanvasCrashReport(80), "East"); add(new CanvasCrashReport(80), "West"); add(new CanvasCrashReport(100), "South"); add(textarea, "Center"); }
ActivityIndicatorRecipe::ActivityIndicatorRecipe(Container *parent) : CustomControl(parent) { // The recipe Container. Container *recipeContainer = new Container(); StackLayout *recipeLayout = new StackLayout(); recipeLayout->setLeftPadding(20.0); recipeLayout->setRightPadding(20.0); recipeContainer->setLayout(recipeLayout); // The introduction text. TextArea *introText = new TextArea(); introText->setText((const QString) "This is a milk boiling simulator recepie"); introText->setEditable(false); introText->textStyle()->setColor(Color::Gray); introText->textStyle()->setBase(SystemDefaults::TextStyles::bodyText()); introText->setBottomMargin(100); Container* smashContainer = new Container(); smashContainer->setLayout(new DockLayout()); // This the big image that was taking during the night // it's at the same position as the day one, but further from the viewer. mUnbroken = ImageView::create("asset:///images/stockcurve/egg.png"); // Center it using dock layout info. mUnbroken->setLayoutProperties( DockLayoutProperties::create() .horizontal(HorizontalAlignment::Center) .vertical(VerticalAlignment::Center)); // Since this image is on top of the night one, we can hide the // night image with changing the opacity value of this image. mBroken = ImageView::create("asset:///images/stockcurve/broken_egg.png").opacity(0.0); // Center it using dock layout info. mBroken->setLayoutProperties( DockLayoutProperties::create() .horizontal(HorizontalAlignment::Center) .vertical(VerticalAlignment::Center)); mActivityIndicator = new ActivityIndicator(); mActivityIndicator->setPreferredSize(130, 130); smashContainer->add(mUnbroken); smashContainer->add(mActivityIndicator); smashContainer->add(mBroken); mButton = new Button(); mButton->setTopMargin(100); mButton->setText((const QString) "start cooking"); connect(mButton, SIGNAL(clicked()), this, SLOT(onClicked())); // Add the controls to the recipe Container and set it as root. recipeContainer->add(introText); recipeContainer->add(smashContainer); recipeContainer->add(mButton); setRoot(recipeContainer); }
/** Returns the i-th window in the Previously Loaded Stream */ Window* CHUImporter::GetWindow(unsigned int wid) { ieWord WindowID, XPos, YPos, Width, Height, BackGround; ieWord ControlsCount, FirstControl; ieResRef MosFile; unsigned int i; bool found = false; for (unsigned int c = 0; c < WindowCount; c++) { str->Seek( WEOffset + ( 0x1c * c ), GEM_STREAM_START ); str->ReadWord( &WindowID ); if (WindowID == wid) { found = true; break; } } if (!found) { return NULL; } str->Seek( 2, GEM_CURRENT_POS ); str->ReadWord( &XPos ); str->ReadWord( &YPos ); str->ReadWord( &Width ); str->ReadWord( &Height ); str->ReadWord( &BackGround ); str->ReadWord( &ControlsCount ); str->ReadResRef( MosFile ); str->ReadWord( &FirstControl ); Window* win = new Window( WindowID, XPos, YPos, Width, Height ); if (BackGround == 1) { ResourceHolder<ImageMgr> mos(MosFile); if (mos != NULL) { win->SetBackGround( mos->GetSprite2D(), true ); } else printMessage( "CHUImporter","Cannot Load BackGround, skipping\n",YELLOW ); } if (!core->IsAvailable( IE_BAM_CLASS_ID )) { printMessage( "CHUImporter","No BAM Importer Available, skipping controls\n",LIGHT_RED ); return win; } for (i = 0; i < ControlsCount; i++) { str->Seek( CTOffset + ( ( FirstControl + i ) * 8 ), GEM_STREAM_START ); ieDword COffset, CLength, ControlID; ieWord XPos, YPos, Width, Height; ieByte ControlType, temp; str->ReadDword( &COffset ); str->ReadDword( &CLength ); str->Seek( COffset, GEM_STREAM_START ); str->ReadDword( &ControlID ); str->ReadWord( &XPos ); str->ReadWord( &YPos ); str->ReadWord( &Width ); str->ReadWord( &Height ); str->Read( &ControlType, 1 ); str->Read( &temp, 1 ); switch (ControlType) { case IE_GUI_BUTTON: { //Button Button* btn = new Button( ); btn->ControlID = ControlID; btn->XPos = XPos; btn->YPos = YPos; btn->Width = Width; btn->Height = Height; btn->ControlType = ControlType; ieResRef BAMFile; ieWord Cycle, UnpressedIndex, PressedIndex, SelectedIndex, DisabledIndex; str->ReadResRef( BAMFile ); str->ReadWord( &Cycle ); str->ReadWord( &UnpressedIndex ); str->ReadWord( &PressedIndex ); str->ReadWord( &SelectedIndex ); str->ReadWord( &DisabledIndex ); btn->Owner = win; /** Justification comes from the .chu, other bits are set by script */ if (!Width) { btn->SetFlags(IE_GUI_BUTTON_NO_IMAGE, BM_OR); } if (core->HasFeature(GF_UPPER_BUTTON_TEXT)) { btn->SetFlags(IE_GUI_BUTTON_CAPS, BM_OR); } btn->SetFlags( Cycle&0xff00, BM_OR ); if (strnicmp( BAMFile, "guictrl\0", 8 ) == 0) { if (UnpressedIndex == 0) { printMessage("CHUImporter", "Special Button Control, Skipping Image Loading\n",GREEN ); win->AddControl( btn ); break; } } AnimationFactory* bam = ( AnimationFactory* ) gamedata->GetFactoryResource( BAMFile, IE_BAM_CLASS_ID, IE_NORMAL ); if (!bam ) { printMessage( "CHUImporter","Cannot Load Button Images, skipping control\n",LIGHT_RED ); /* IceWind Dale 2 has fake BAM ResRefs for some Buttons, this will handle bad ResRefs */ win->AddControl( btn ); break; } /** Cycle is only a byte for buttons */ Sprite2D* tspr = bam->GetFrame( UnpressedIndex, (unsigned char) Cycle ); btn->SetImage( IE_GUI_BUTTON_UNPRESSED, tspr ); tspr = bam->GetFrame( PressedIndex, (unsigned char) Cycle ); btn->SetImage( IE_GUI_BUTTON_PRESSED, tspr ); //ignorebuttonframes is a terrible hack if (core->HasFeature( GF_IGNORE_BUTTON_FRAMES) ) { if (bam->GetCycleSize( (unsigned char) Cycle) == 4 ) SelectedIndex=2; } tspr = bam->GetFrame( SelectedIndex, (unsigned char) Cycle ); btn->SetImage( IE_GUI_BUTTON_SELECTED, tspr ); if (core->HasFeature( GF_IGNORE_BUTTON_FRAMES) ) { if (bam->GetCycleSize( (unsigned char) Cycle) == 4 ) DisabledIndex=3; } tspr = bam->GetFrame( DisabledIndex, (unsigned char) Cycle ); btn->SetImage( IE_GUI_BUTTON_DISABLED, tspr ); win->AddControl( btn ); } break; case IE_GUI_PROGRESSBAR: { //GemRB specific, progressbar ieResRef MOSFile, MOSFile2; ieResRef BAMFile; ieWord KnobXPos, KnobYPos; ieWord CapXPos, CapYPos; ieWord KnobStepsCount; ieWord Cycle; str->ReadResRef( MOSFile ); str->ReadResRef( MOSFile2 ); str->ReadResRef( BAMFile ); str->ReadWord( &KnobStepsCount ); str->ReadWord( &Cycle ); str->ReadWord( &KnobXPos ); str->ReadWord( &KnobYPos ); str->ReadWord( &CapXPos ); str->ReadWord( &CapYPos ); Progressbar* pbar = new Progressbar(KnobStepsCount, true ); pbar->ControlID = ControlID; pbar->XPos = XPos; pbar->YPos = YPos; pbar->ControlType = ControlType; pbar->Width = Width; pbar->Height = Height; pbar->SetSliderPos( KnobXPos, KnobYPos, CapXPos, CapYPos ); Sprite2D* img = NULL; Sprite2D* img2 = NULL; if ( MOSFile[0] ) { ResourceHolder<ImageMgr> mos(MOSFile); img = mos->GetSprite2D(); } if ( MOSFile2[0] ) { ResourceHolder<ImageMgr> mos(MOSFile2); img2 = mos->GetSprite2D(); } pbar->SetImage( img, img2 ); if( KnobStepsCount ) { /* getting the bam */ AnimationFactory *af = (AnimationFactory *) gamedata->GetFactoryResource(BAMFile, IE_BAM_CLASS_ID ); /* Getting the Cycle of the bam */ pbar->SetAnimation(af->GetCycle( Cycle & 0xff ) ); } else { ResourceHolder<ImageMgr> mos(BAMFile); Sprite2D* img3 = mos->GetSprite2D(); pbar->SetBarCap( img3 ); } win->AddControl( pbar ); } break; case IE_GUI_SLIDER: { //Slider ieResRef MOSFile, BAMFile; ieWord Cycle, Knob, GrabbedKnob; ieWord KnobXPos, KnobYPos, KnobStep, KnobStepsCount; str->ReadResRef( MOSFile ); str->ReadResRef( BAMFile ); str->ReadWord( &Cycle ); str->ReadWord( &Knob ); str->ReadWord( &GrabbedKnob ); str->ReadWord( &KnobXPos ); str->ReadWord( &KnobYPos ); str->ReadWord( &KnobStep ); str->ReadWord( &KnobStepsCount ); Slider* sldr = new Slider( KnobXPos, KnobYPos, KnobStep, KnobStepsCount, true ); sldr->ControlID = ControlID; sldr->XPos = XPos; sldr->YPos = YPos; sldr->ControlType = ControlType; sldr->Width = Width; sldr->Height = Height; ResourceHolder<ImageMgr> mos(MOSFile); Sprite2D* img = mos->GetSprite2D(); sldr->SetImage( IE_GUI_SLIDER_BACKGROUND, img); AnimationFactory* bam = ( AnimationFactory* ) gamedata->GetFactoryResource( BAMFile, IE_BAM_CLASS_ID, IE_NORMAL ); if( bam ) { img = bam->GetFrame( Knob, 0 ); sldr->SetImage( IE_GUI_SLIDER_KNOB, img ); img = bam->GetFrame( GrabbedKnob, 0 ); sldr->SetImage( IE_GUI_SLIDER_GRABBEDKNOB, img ); } else { sldr->SetState(IE_GUI_SLIDER_BACKGROUND); } win->AddControl( sldr ); } break; case IE_GUI_EDIT: { //Text Edit ieResRef BGMos; ieResRef FontResRef, CursorResRef; ieWord maxInput; ieWord CurCycle, CurFrame; ieWord PosX, PosY; str->ReadResRef( BGMos ); str->Seek( 16, GEM_CURRENT_POS ); str->ReadResRef( CursorResRef ); str->ReadWord( &CurCycle ); str->ReadWord( &CurFrame ); str->ReadWord( &PosX ); str->ReadWord( &PosY ); str->Seek( 4, GEM_CURRENT_POS ); str->ReadResRef( FontResRef ); str->Seek( 34, GEM_CURRENT_POS ); str->ReadWord( &maxInput ); Font* fnt = core->GetFont( FontResRef ); AnimationFactory* bam = ( AnimationFactory* ) gamedata->GetFactoryResource( CursorResRef, IE_BAM_CLASS_ID, IE_NORMAL ); Sprite2D *cursor = NULL; if (bam) { cursor = bam->GetFrame( CurCycle, CurFrame ); } ResourceHolder<ImageMgr> mos(BGMos); Sprite2D *img = NULL; if(mos) { img = mos->GetSprite2D(); } TextEdit* te = new TextEdit( maxInput, PosX, PosY ); te->ControlID = ControlID; te->XPos = XPos; te->YPos = YPos; te->Width = Width; te->Height = Height; te->ControlType = ControlType; te->SetFont( fnt ); te->SetCursor( cursor ); te->SetBackGround( img ); win->AddControl( te ); } break; case IE_GUI_TEXTAREA: { //Text Area ieResRef FontResRef, InitResRef; Color fore, init, back; ieWord SBID; str->ReadResRef( FontResRef ); str->ReadResRef( InitResRef ); Font* fnt = core->GetFont( FontResRef ); Font* ini = core->GetFont( InitResRef ); str->Read( &fore, 4 ); str->Read( &init, 4 ); str->Read( &back, 4 ); str->ReadWord( &SBID ); TextArea* ta = new TextArea( fore, init, back ); ta->ControlID = ControlID; ta->XPos = XPos; ta->YPos = YPos; ta->Width = Width; ta->Height = Height; ta->ControlType = ControlType; ta->SetFonts( ini, fnt ); win->AddControl( ta ); if (SBID != 0xffff) win->Link( SBID, ( unsigned short ) ControlID ); } break; case IE_GUI_LABEL: { //Label ieResRef FontResRef; ieStrRef StrRef; RevColor fore, back; ieWord alignment; str->ReadDword( &StrRef ); str->ReadResRef( FontResRef ); Font* fnt = core->GetFont( FontResRef ); str->Read( &fore, 4 ); str->Read( &back, 4 ); str->ReadWord( &alignment ); Label* lab = new Label( fnt ); lab->ControlID = ControlID; lab->XPos = XPos; lab->YPos = YPos; lab->Width = Width; lab->Height = Height; lab->ControlType = ControlType; char* str = core->GetString( StrRef ); lab->SetText( str ); core->FreeString( str ); if (alignment & 1) { lab->useRGB = true; Color f, b; f.r = fore.b; f.g = fore.g; f.b = fore.r; f.a = 0; b.r = back.b; b.g = back.g; b.b = back.r; b.a = 0; lab->SetColor( f, b ); } int align = IE_FONT_ALIGN_CENTER; if (( alignment & 0x10 ) != 0) { align = IE_FONT_ALIGN_RIGHT; goto endvertical; } if (( alignment & 0x04 ) != 0) { goto endvertical; } if (( alignment & 0x08 ) != 0) { align = IE_FONT_ALIGN_LEFT; goto endvertical; } endvertical: if (( alignment & 0x20 ) != 0) { align |= IE_FONT_ALIGN_TOP; goto endalign; } if (( alignment & 0x80 ) != 0) { align |= IE_FONT_ALIGN_BOTTOM; } else { align |= IE_FONT_ALIGN_MIDDLE; } endalign: lab->SetAlignment( align ); win->AddControl( lab ); } break; case IE_GUI_SCROLLBAR: { //ScrollBar ieResRef BAMResRef; ieWord Cycle, Trough, Slider, TAID; ieWord UpUnPressed, UpPressed; ieWord DownUnPressed, DownPressed; str->ReadResRef( BAMResRef ); str->ReadWord( &Cycle ); str->ReadWord( &UpUnPressed ); str->ReadWord( &UpPressed ); str->ReadWord( &DownUnPressed ); str->ReadWord( &DownPressed ); str->ReadWord( &Trough ); str->ReadWord( &Slider ); str->ReadWord( &TAID ); ScrollBar* sbar = new ScrollBar(); sbar->ControlID = ControlID; sbar->XPos = XPos; sbar->YPos = YPos; sbar->Width = Width; sbar->Height = Height; sbar->ControlType = ControlType; AnimationFactory* bam = ( AnimationFactory* ) gamedata->GetFactoryResource( BAMResRef, IE_BAM_CLASS_ID, IE_NORMAL ); if (bam) { sbar->SetImage( IE_GUI_SCROLLBAR_UP_UNPRESSED, bam->GetFrame( UpUnPressed, Cycle ) ); sbar->SetImage( IE_GUI_SCROLLBAR_UP_PRESSED, bam->GetFrame( UpPressed, Cycle ) ); sbar->SetImage( IE_GUI_SCROLLBAR_DOWN_UNPRESSED, bam->GetFrame( DownUnPressed, Cycle ) ); sbar->SetImage( IE_GUI_SCROLLBAR_DOWN_PRESSED, bam->GetFrame( DownPressed, Cycle ) ); sbar->SetImage( IE_GUI_SCROLLBAR_TROUGH, bam->GetFrame( Trough, Cycle ) ); sbar->SetImage( IE_GUI_SCROLLBAR_SLIDER, bam->GetFrame( Slider, Cycle ) ); } win->AddControl( sbar ); if (TAID != 0xffff) win->Link( ( unsigned short ) ControlID, TAID ); } break; default: printMessage( "CHUImporter","Control Not Supported\n",LIGHT_RED ); } } return win; }
void SimpleForm::ShowTextArea(const TextArea &ta) { // --- Create Label this->txtLbl = new Label(); this->txtLbl->AutoSize = true; this->txtLbl->Location = Drawing::Point(8, 16); this->txtLbl->Size = Drawing::Size(28, 13); char *strLabel = new char[ta.label().length()+1]; strcpy( strLabel, ta.label().c_str() ); this->txtLbl->Text = strLabel; delete strLabel; Controls->Add(this->txtLbl); // ---- create Textbox --- txtBox = new TextBox; int xPos = this->txtLbl->get_Right() + 4; txtBox->Location = Point(xPos, 16); txtBox->Enabled = false; txtBox->BackColor = Drawing::Color::White; txtBox->ForeColor = Drawing::Color::Black; txtBox->AutoSize = true; txtBox->Text = Convert2Char(ta.value()); txtBox->Height = ta.height(); txtBox->WordWrap = true; Drawing::Font* tbf = txtBox->Font; txtBox->Width = int((double)(ta.width()+1) * (double)((tbf->SizeInPoints * ( 72.0/ 96.0)))); Controls->Add(txtBox); int xWidth = int((double)(ta.width()) * (double)((tbf->SizeInPoints * ( 72.0/ 96.0)))); Lbltxtb = new Label(); Lbltxtb->AutoSize = false; Lbltxtb->Location = Drawing::Point(xPos+200, 36); Lbltxtb->Size = Drawing::Size(xWidth, 15); Lbltxtb->Text = Convert2Char(ta.value()); Lbltxtb->Width = int((double)(ta.width()+2) * (double)((tbf->SizeInPoints * ( 72.0/ 96.0)))); Lbltxtb->BackColor = System::Drawing::Color::White; Lbltxtb->BorderStyle = System::Windows::Forms::BorderStyle::Fixed3D; Controls->Add(this->Lbltxtb); // // Setup and display attribute information // //int tmpInt; LblNumItems->Visible = false; LblNumItemsb->Visible = false; LblHeight->Visible = false; LblHeightb->Visible = false; LblSizeb->Text = ta.size().ToString(); LblMaxLengthb->Text = ta.maxlen().ToString(); LblValLenthb->Text = ta.value().length().ToString(); LblWidthb->Text = ta.width().ToString(); LblValDatab->Text = Convert2Char(ta.value()); }
void DisplayMessage::DisplayMarkupString(const String& Text) const { TextArea *ta = core->GetMessageTextArea(); if (ta) ta->AppendText( Text ); }
InputRecipe::InputRecipe(Container *parent) : CustomControl(parent) { bool connectResult; Q_UNUSED(connectResult); ScrollView *scrollView = new ScrollView(); ScrollViewProperties* scrollViewProp = scrollView->scrollViewProperties(); scrollViewProp->setScrollMode(ScrollMode::Vertical); Container *recipeContainer = Container::create().left(80).right(80); // Label used to display the entered text mInputLabel = new Label(); mInputLabel->setMultiline(true); mInputLabel->setText((const QString) " "); mInputLabel->setHorizontalAlignment(HorizontalAlignment::Fill); mInputLabel->setBottomMargin(50.0); mInputLabel->textStyle()->setBase(SystemDefaults::TextStyles::bodyText()); // A multi line text input TextArea *textArea = new TextArea(); textArea->setHintText("Enter text into multi-line TextArea"); textArea->setPreferredHeight(140); textArea->setBottomMargin(50.0); textArea->textStyle()->setBase(SystemDefaults::TextStyles::bodyText()); textArea->setHorizontalAlignment(HorizontalAlignment::Fill); // Connect the TextArea textChanging signal to the onTextChanging function to update the text. connectResult = connect(textArea, SIGNAL(textChanging(const QString &)), this, SLOT(onTextChanging(const QString &))); Q_ASSERT(connectResult); // A single line input field with a clear functionality TextField *textField = new TextField(); textField->setHintText("Enter text into a single line TextField"); textField->setHorizontalAlignment(HorizontalAlignment::Fill); textField->setBottomMargin(50.0); // Connect the TextField textChanging signal to the onTextChanging function to update the text. connectResult = connect(textField, SIGNAL(textChanging(const QString &)), this, SLOT(onTextChanging(const QString &))); Q_ASSERT(connectResult); // A disabled text field TextField *disabledTextField = new TextField(); disabledTextField->setHintText("This is a disabled text field"); disabledTextField->setEnabled(false); disabledTextField->setHorizontalAlignment(HorizontalAlignment::Fill); disabledTextField->setBottomMargin(50.0); // Add the controls to the recipe Container and ScrollView and set it as the CustomControl root. scrollView->setContent(recipeContainer); recipeContainer->add(mInputLabel); recipeContainer->add(textField); recipeContainer->add(disabledTextField); recipeContainer->add(textArea); //recipeContainer->add(inputContainer); setRoot(scrollView); }