//-------------------------------------------------------------- // constructor mgSimpleField::mgSimpleField( mgControl* parent, const char* cntlName) : mgFieldControl(parent, cntlName) { m_displayCount = 20; // default m_cursorPosn = 0; m_scrollPosn = 0; m_insertMode = true; m_changed = false; m_history = NULL; // not enabled mgStyle* style = getStyle(); // assume style has set all our format elements style->getFontAttr(MG_STYLE_FIELD, getName(), "font", m_font); style->getFrameAttr(MG_STYLE_FIELD, getName(), "upFrame", m_upFrame); style->getFrameAttr(MG_STYLE_FIELD, getName(), "hoverFrame", m_hoverFrame); style->getFrameAttr(MG_STYLE_FIELD, getName(), "downFrame", m_downFrame); style->getFrameAttr(MG_STYLE_FIELD, getName(), "disFrame", m_disFrame); style->getColorAttr(MG_STYLE_FIELD, getName(), "upColor", m_upColor); style->getColorAttr(MG_STYLE_FIELD, getName(), "hoverColor", m_hoverColor); style->getColorAttr(MG_STYLE_FIELD, getName(), "downColor", m_downColor); style->getColorAttr(MG_STYLE_FIELD, getName(), "disColor", m_disColor); m_hasMouse = false; m_changeListeners = NULL; addMouseListener((mgMouseListener*) this); addKeyListener((mgKeyListener*) this); addFocusListener((mgFocusListener*) this); }
ItemContainer::ItemContainer(Inventory *inventory, bool forceQuantity): mInventory(inventory), mGridColumns(1), mGridRows(1), mSelectedIndex(-1), mHighlightedIndex(-1), mLastUsedSlot(-1), mSelectionStatus(SEL_NONE), mForceQuantity(forceQuantity), mSwapItems(false), mDescItems(false) { mItemPopup = new ItemPopup; setFocusable(true); ResourceManager *resman = ResourceManager::getInstance(); mSelImg = resman->getImage("graphics/gui/selection.png"); if (!mSelImg) logger->error("Unable to load selection.png"); addKeyListener(this); addMouseListener(this); addWidgetListener(this); }
Viewport::Viewport(): mMap(0), mMouseX(0), mMouseY(0), mPixelViewX(0.0f), mPixelViewY(0.0f), mDebugFlags(0), mPlayerFollowMouse(false), mLocalWalkTime(-1), mHoverBeing(0), mHoverItem(0) { setOpaque(false); addMouseListener(this); mScrollLaziness = config.getIntValue("ScrollLaziness"); mScrollRadius = config.getIntValue("ScrollRadius"); mScrollCenterOffsetX = config.getIntValue("ScrollCenterOffsetX"); mScrollCenterOffsetY = config.getIntValue("ScrollCenterOffsetY"); mPopupMenu = new PopupMenu; mBeingPopup = new BeingPopup; setFocusable(true); listen(Event::ConfigChannel); listen(Event::ActorSpriteChannel); }
//-------------------------------------------------------------- // constructor mgUglyButton::mgUglyButton( mgControl* parent, const char* cntlName) : mgButtonControl(parent, cntlName) { m_mode = MG_BUTTON_UP; mgStyle* style = getStyle(); // assume style has set all our format elements style->getFontAttr(MG_STYLE_BUTTON, m_cntlName, "font", m_font); style->getFrameAttr(MG_STYLE_BUTTON, m_cntlName, "upFrame", m_upFrame); style->getFrameAttr(MG_STYLE_BUTTON, m_cntlName, "hoverFrame", m_hoverFrame); style->getFrameAttr(MG_STYLE_BUTTON, m_cntlName, "downFrame", m_downFrame); style->getFrameAttr(MG_STYLE_BUTTON, m_cntlName, "disFrame", m_disFrame); style->getColorAttr(MG_STYLE_BUTTON, m_cntlName, "upColor", m_upColor); style->getColorAttr(MG_STYLE_BUTTON, m_cntlName, "hoverColor", m_hoverColor); style->getColorAttr(MG_STYLE_BUTTON, m_cntlName, "downColor", m_downColor); style->getColorAttr(MG_STYLE_BUTTON, m_cntlName, "disColor", m_disColor); m_actionListeners = NULL; addMouseListener((mgMouseListener*) this); addFocusListener((mgFocusListener*) this); }
void Slider::init() { mAllowLogic = false; setFocusable(true); setFrameSize(1); addMouseListener(this); addKeyListener(this); setFrameSize(0); // Load resources if (mInstances == 0) { if (theme) { for (int mode = 0; mode < 2; mode ++) theme->loadRect(buttons[mode], data[mode], "slider.xml", 0, 8); } updateAlpha(); } mInstances++; if (buttons[0].grid[HGRIP]) setMarkerLength(buttons[0].grid[HGRIP]->getWidth()); }
//-------------------------------------------------------------- // constructor mgSimpleWindow::mgSimpleWindow( mgSimpleDesktop* desktop, mgControl* parent, const char* cntlName) : mgControl(parent, cntlName) { m_desktop = desktop; m_contentPane = new mgControl(this); new mgColumnLayout(m_contentPane); mgStyle* style = getStyle(); // assume style has set all our format elements style->getFontAttr(MG_STYLE_WINDOW, getName(), "font", m_font); style->getFrameAttr(MG_STYLE_WINDOW, getName(), "onFrame", m_onFrame); style->getColorAttr(MG_STYLE_WINDOW, getName(), "onColor", m_onColor); style->getFrameAttr(MG_STYLE_WINDOW, getName(), "offFrame", m_offFrame); style->getColorAttr(MG_STYLE_WINDOW, getName(), "offColor", m_offColor); addMouseListener(this); m_pressMode = PRESS_NONE; m_closeBtn = NULL; m_maxBtn = NULL; m_minBtn = NULL; m_flags = 0; m_barHeight = 0; m_iconsWidth = 0; m_iconsHeight = 0; }
TabbedArea::TabbedArea(const Widget2 *const widget) : ActionListener(), BasicContainer(widget), KeyListener(), MouseListener(), WidgetListener(), mArrowButton(), mSelectedTab(nullptr), mTabContainer(new BasicContainer2(widget)), mWidgetContainer(new BasicContainer2(widget)), mTabsToDelete(), mTabs(), mTabsWidth(0), mVisibleTabsWidth(0), mTabScrollIndex(0), mRightMargin(0), mOpaque(Opaque_false), mEnableScrollButtons(false), mFollowDownScroll(false), mBlockSwitching(true), mResizeHeight(true) { setFocusable(true); addKeyListener(this); addMouseListener(this); }
ItemContainer::ItemContainer(Inventory *inventory, bool forceQuantity): mInventory(inventory), mGridColumns(1), mGridRows(1), mSelectedIndex(-1), mHighlightedIndex(-1), mLastUsedSlot(-1), mSelectionStatus(SEL_NONE), mForceQuantity(forceQuantity), mSwapItems(false), mDescItems(false), mTag(0), mSortType(0), mItemPopup(new ItemPopup), mShowMatrix(nullptr), mClicks(1), mEquipedColor(Theme::getThemeColor(Theme::ITEM_EQUIPPED)), mUnEquipedColor(Theme::getThemeColor(Theme::ITEM_NOT_EQUIPPED)) { setFocusable(true); mSelImg = Theme::getImageFromTheme("selection.png"); if (!mSelImg) logger->log1("Error: Unable to load selection.png"); addKeyListener(this); addMouseListener(this); addWidgetListener(this); }
ItemPopup::ItemPopup(): Popup("ItemPopup"), mIcon(0) { // Item Name mItemName = new Label; mItemName->setFont(boldFont); mItemName->setPosition(getPadding(), getPadding()); // Item Description mItemDesc = new TextBox; mItemDesc->setEditable(false); // Item Effect mItemEffect = new TextBox; mItemEffect->setEditable(false); // Item Weight mItemWeight = new TextBox; mItemWeight->setEditable(false); mIcon = new Icon(0); add(mItemName); add(mItemDesc); add(mItemEffect); add(mItemWeight); add(mIcon); addMouseListener(this); }
ShortcutContainer::ShortcutContainer(Widget2 *const widget) : Widget(widget), WidgetListener(), MouseListener(), mBackgroundImg(nullptr), mMaxItems(0), mBoxWidth(1), mBoxHeight(1), mGridWidth(1), mGridHeight(1), mVertexes(new ImageCollection) { mAllowLogic = false; addMouseListener(this); addWidgetListener(this); mForegroundColor = getThemeColor(ThemeColorId::TEXT); mForegroundColor2 = getThemeColor(ThemeColorId::TEXT_OUTLINE); mBackgroundImg = Theme::getImageFromThemeXml( "item_shortcut_background.xml", "background.xml"); if (mBackgroundImg) { mBackgroundImg->setAlpha(settings.guiAlpha); mBoxHeight = mBackgroundImg->getHeight(); mBoxWidth = mBackgroundImg->getWidth(); } else { mBoxHeight = 1; mBoxWidth = 1; } }
GuiTable::GuiTable(const Widget2 *const widget, TableModel *const initial_model, const bool opacity) : Widget(widget), MouseListener(), KeyListener(), mModel(nullptr), mTopWidget(nullptr), mActionListeners2(), mHighlightColor(getThemeColor(ThemeColorId::HIGHLIGHT)), mSelectedRow(-1), mSelectedColumn(-1), mLinewiseMode(false), mWrappingEnabled(false), mOpaque(opacity), mSelectable(true) { mAllowLogic = false; mBackgroundColor = getThemeColor(ThemeColorId::BACKGROUND); setModel(initial_model); setFocusable(true); addMouseListener(this); addKeyListener(this); }
void PlayerBox::init(std::string name, std::string selectedName) { mAllowLogic = false; setFrameSize(2); addMouseListener(this); if (theme) { if (name.empty()) name = "playerbox.xml"; mSkin = theme->loadSkinRect(mBackground, name, "playerbox_background.xml"); if (mSkin) { mDrawBackground = (mSkin->getOption("drawbackground") != 0); mOffsetX = mSkin->getOption("offsetX", -mapTileSize / 2); mOffsetY = mSkin->getOption("offsetY", -mapTileSize); mFrameSize = mSkin->getOption("frameSize", 2); } if (selectedName.empty()) selectedName = "playerboxselected.xml"; mSelectedSkin = theme->loadSkinRect(mSelectedBackground, selectedName, "playerbox_background.xml"); } else { for (int f = 0; f < 9; f ++) mBackground.grid[f] = nullptr; for (int f = 0; f < 9; f ++) mSelectedBackground.grid[f] = nullptr; } }
CharacterModule::CharacterModule() : characterPortrait(NULL) { characterStats = new gcn::contrib::AdjustingContainer(); characterNameLabel = new edwt::Label(); characterHPLabel = new edwt::Label(); characterSPLabel = new edwt::Label(); characterNameLabel->setForegroundColor(0xFFFFFF); characterHPLabel->setForegroundColor(0xFFFFFF); characterSPLabel->setForegroundColor(0xFFFFFF); characterPortrait = new edwt::Icon(); characterStats->setNumberOfColumns(1); characterStats->setColumnAlignment(0, gcn::contrib::AdjustingContainer::LEFT); characterStats->add(characterNameLabel); characterStats->add(characterHPLabel); characterStats->add(characterSPLabel); characterStats->setOpaque(false); setNumberOfColumns(2); setColumnAlignment(0, gcn::contrib::AdjustingContainer::LEFT); setColumnAlignment(1, gcn::contrib::AdjustingContainer::RIGHT); setHorizontalSpacing(10); setPadding(5, 5, 5, 5); add(characterPortrait); add(characterStats); addMouseListener(this); setOpaque(false); }
void Tab::init() { addMouseListener(this); setFocusable(false); setFrameSize(0); mFlash = 0; addWidgetListener(this); if (mInstances == 0) { // Load the skin Theme *const theme = Theme::instance(); if (theme) { for (int mode = 0; mode < TAB_COUNT; mode ++) tabImg[mode] = theme->load(data[mode], "tab.xml"); } updateAlpha(); } mInstances++; add(mLabel); const Skin *const skin = tabImg[TAB_STANDARD]; if (!skin) return; const int padding = skin->getPadding(); mLabel->setPosition(padding, padding); }
ItemPopup::ItemPopup(): Popup("ItemPopup") { // Item Name mItemName = new gcn::Label; mItemName->setFont(boldFont); mItemName->setPosition(getPadding(), getPadding()); const int fontHeight = getFont()->getHeight(); // Item Description mItemDesc = new TextBox; mItemDesc->setEditable(false); mItemDesc->setPosition(getPadding(), fontHeight); // Item Effect mItemEffect = new TextBox; mItemEffect->setEditable(false); mItemEffect->setPosition(getPadding(), 2 * fontHeight + 2 * getPadding()); // Item Weight mItemWeight = new TextBox; mItemWeight->setEditable(false); mItemWeight->setPosition(getPadding(), 3 * fontHeight + 4 * getPadding()); add(mItemName); add(mItemDesc); add(mItemEffect); add(mItemWeight); addMouseListener(this); loadPopupConfiguration(); }
void ListBox::setMouseMoveSelectsRows (bool b) { mouseMoveSelects = b; if (b) addMouseListener (this, true); }
TabbedArea::TabbedArea(bool hide) : Container(), mHideWhenOneTab(hide), mSelectedTab(NULL) { setFocusable(false); addKeyListener(this); addMouseListener(this); mTabContainer = new Container(); mTabContainer->setOpaque(false); mWidgetContainer = new Container(); mWidgetContainer->setOpaque(false); add(mTabContainer); add(mWidgetContainer); mProtFocusListener = new ProtectedFocusListener(); addFocusListener(mProtFocusListener); mProtFocusListener->blockKey(SDLK_LEFT); mProtFocusListener->blockKey(SDLK_RIGHT); mProtFocusListener->blockKey(SDLK_UP); mProtFocusListener->blockKey(SDLK_DOWN); }
//-------------------------------------------------------------- // constructor mgUglyList::mgUglyList( mgControl* parent, const char* cntlName) : mgListControl(parent, cntlName) { m_selected = -1; m_displayLines = 5; m_multiSelect = false; m_hasIcons = false; m_scrollPosn = 0; m_hover = -1; mgStyle* style = getStyle(); style->getFontAttr(MG_STYLE_LIST, m_cntlName, "font", m_font); style->getFrameAttr(MG_STYLE_LIST, m_cntlName, "upFrame", m_upFrame); style->getFrameAttr(MG_STYLE_LIST, m_cntlName, "disFrame", m_disFrame); style->getFrameAttr(MG_STYLE_LIST, m_cntlName, "itemUpFrame", m_itemUpFrame); style->getFrameAttr(MG_STYLE_LIST, m_cntlName, "itemHoverFrame", m_itemHoverFrame); style->getFrameAttr(MG_STYLE_LIST, m_cntlName, "itemDownFrame", m_itemDownFrame); style->getFrameAttr(MG_STYLE_LIST, m_cntlName, "itemDisFrame", m_itemDisFrame); style->getColorAttr(MG_STYLE_LIST, m_cntlName, "itemUpColor", m_itemUpColor); style->getColorAttr(MG_STYLE_LIST, m_cntlName, "itemHoverColor", m_itemHoverColor); style->getColorAttr(MG_STYLE_LIST, m_cntlName, "itemDownColor", m_itemDownColor); style->getColorAttr(MG_STYLE_LIST, m_cntlName, "itemDisColor", m_itemDisColor); // set icon height to 80% line height m_iconHeight = (m_font->getHeight()*8)/10; m_lineHeight = max(m_iconHeight, m_font->getHeight()); // add any item framing -- all frames should be same size as itemUpFrame if (m_itemUpFrame != NULL) { mgDimension size; m_itemUpFrame->getOutsideSize(mgDimension(0, m_lineHeight), size); m_lineHeight = size.m_height; } // create the scrollbars, so we can get preferred size correct m_vertScroller = new mgUglyScrollbar(this); m_vertScroller->setHorizontal(false); m_vertScroller->setVisible(false); m_vertScroller->addScrollListener(this); m_horzScroller = NULL; /* =-= not used or laid out correctly m_horzScroller = new mgUglyScrollbar(this); m_horzScroller->setHorizontal(true); m_horzScroller->setVisible(false); m_horzScroller->addScrollListener(this); */ m_selectListeners = NULL; addMouseListener(this); addFocusListener(this); }
CheckBox::CheckBox() { setSelected(false); SetFocusable(true); addMouseListener(this); addKeyListener(this); }
//-------------------------------------------------------------- // constructor mgSimpleDesktop::mgSimpleDesktop( mgControl* parent, const char* cntlName) : mgDesktopControl(parent, cntlName) { addMouseListener(this); addTimeListener(this); }
void Button::init(Icon *icon,const std::string &label) { setThemeName("Button"); setDefaultIcon(icon); addMouseListener(this); addFocusListener(this); setText(label); }
RadioButton::RadioButton() { setSelected(false); setFocusable(true); addMouseListener(this); addKeyListener(this); }
CheckBox::CheckBox() { setMarked(false); setFocusable(true); addMouseListener(this); addKeyListener(this); }
Gui::Gui(HINSTANCE instance, CameraTranslator* frontCameraTranslator, CameraTranslator* rearCameraTranslator, Blobber* blobberFront, Blobber* blobberRear, int width, int height) : instance(instance), frontCameraTranslator(frontCameraTranslator), rearCameraTranslator(rearCameraTranslator), blobberFront(blobberFront), blobberRear(blobberRear), width(width), height(height), activeWindow(NULL), quitRequested(false) { WNDCLASSEX wClass; ZeroMemory(&wClass, sizeof(WNDCLASSEX)); wClass.cbClsExtra = NULL; wClass.cbSize = sizeof(WNDCLASSEX); wClass.cbWndExtra = NULL; wClass.hbrBackground = (HBRUSH)COLOR_WINDOW; wClass.hCursor = LoadCursor(NULL, IDC_ARROW); wClass.hIcon = LoadIcon(NULL, IDI_APPLICATION); wClass.hIconSm = LoadIcon(NULL, IDI_APPLICATION); wClass.hInstance = instance; wClass.lpfnWndProc = (WNDPROC)WinProc; wClass.lpszClassName = "Window Class"; wClass.lpszMenuName = NULL; wClass.style = CS_HREDRAW | CS_VREDRAW; if (!RegisterClassEx(&wClass)) { int nResult = GetLastError(); MessageBox( NULL, "Window class creation failed", "Window Class Failed", MB_ICONERROR ); } ZeroMemory(&msg, sizeof(MSG)); addMouseListener(this); mouseX = 0; mouseY = 0; mouseDown = false; mouseBtn = MouseListener::MouseBtn::LEFT; brushRadius = 50; frontRGB = createWindow(width, height, "Camera 1 RGB"); rearRGB = createWindow(width, height, "Camera 2 RGB"); frontClassification = createWindow(width, height, "Camera 1 classification"); rearClassification = createWindow(width, height, "Camera 2 classification"); selectedColorName = ""; Blobber::Color* color; for (int i = 0; i < blobberFront->getColorCount(); i++) { color = blobberFront->getColor(i); createButton(color->name, 20, 40 + i * 18, 160, 1); } createButton("Clear all", 20 + 160 + 10, 40, 100, 2); clearSelectedBtn = createButton("Clear selected", 20 + 280 + 10, 40, 140, 3, false); createButton("Quit", Config::cameraWidth - 80, 20, 60, 4); }
GlassCanvas::GlassCanvas() : GlassContainer(), GlassWidget(this) { setOpaque(false); //for GlassWidget addActionListener(this); addMouseListener(this); addFocusListener(this); addKeyListener(this); }
Tab::Tab() :mHasMouse(false), mTabbedArea(NULL) { mLabel = new Label(); mLabel->setPosition(6, 6); add(mLabel); addMouseListener(this); }
MiniMap::MiniMap(Map *map, Camera *camera) : gcn::Widget() { setWidth((map->getWidth() + map->getHeight() - 1) * 2); setHeight(map->getWidth() + map->getHeight() - 1); this->map = map; this->camera = camera; addMouseListener(this); }
Gui::Button* Gui::createButton(std::string text, int x, int y, int width, int type, bool visible, void* data) { Button* button = new Button(text, x, y, width, type, visible, data); addMouseListener(button); elements.push_back(button); return button; }
ListBox::ListBox(ListModel *listModel) { mSelected = -1; setWidth(100); setListModel(listModel); setFocusable(true); addMouseListener(this); addKeyListener(this); }
ClickLabel::ClickLabel() { mGuiFont = static_cast<FIFE::GuiFont*> (getFont()); // setAlignment(Graphics::LEFT); setTextWrapping(false); setFrameSize(0); addMouseListener(this); addKeyListener(this); addFocusListener(this); }