diff --git a/src/app/widget_loader.cpp b/src/app/widget_loader.cpp index 00e5c5e22..afcaf5c8f 100644 --- a/src/app/widget_loader.cpp +++ b/src/app/widget_loader.cpp @@ -215,7 +215,7 @@ Widget* WidgetLoader::convertXmlElementToWidget(const TiXmlElement* elem, Widget text = (text ? TRANSLATE_ATTR(text): NULL); if (looklike != NULL && strcmp(looklike, "button") == 0) { - widget = new CheckBox(text, JI_BUTTON); + widget = new CheckBox(text, kButtonWidget); } else { widget = new CheckBox(text); @@ -324,7 +324,7 @@ Widget* WidgetLoader::convertXmlElementToWidget(const TiXmlElement* elem, Widget int radio_group = (group ? ustrtol(group, NULL, 10): 1); if (looklike != NULL && strcmp(looklike, "button") == 0) { - widget = new RadioButton(text, radio_group, JI_BUTTON); + widget = new RadioButton(text, radio_group, kButtonWidget); } else { widget = new RadioButton(text, radio_group); @@ -466,12 +466,12 @@ Widget* WidgetLoader::convertXmlElementToWidget(const TiXmlElement* elem, Widget child = convertXmlElementToWidget(childElem, root); if (child) { // Attach the child in the view - if (widget->type == JI_VIEW) { + if (widget->type == kViewWidget) { static_cast(widget)->attachToView(child); break; } // Add the child in the grid - else if (widget->type == JI_GRID) { + else if (widget->type == kGridWidget) { const char* cell_hspan = childElem->Attribute("cell_hspan"); const char* cell_vspan = childElem->Attribute("cell_vspan"); const char* cell_align = childElem->Attribute("cell_align"); @@ -490,7 +490,7 @@ Widget* WidgetLoader::convertXmlElementToWidget(const TiXmlElement* elem, Widget childElem = childElem->NextSiblingElement(); } - if (widget->type == JI_VIEW) { + if (widget->type == kViewWidget) { bool maxsize = bool_attr_is_true(elem, "maxsize"); if (maxsize) static_cast(widget)->makeVisibleAllScrollableArea(); diff --git a/src/app_menus.cpp b/src/app_menus.cpp index 402948875..b70581a5e 100644 --- a/src/app_menus.cpp +++ b/src/app_menus.cpp @@ -369,7 +369,7 @@ void AppMenus::applyShortcutToMenuitemsWithCommand(Menu* menu, Command *command, UI_FOREACH_WIDGET(menu->getChildren(), it) { Widget* child = *it; - if (child->getType() == JI_MENUITEM) { + if (child->getType() == kMenuItemWidget) { ASSERT(dynamic_cast(child) != NULL); MenuItem2* menuitem = static_cast(child); diff --git a/src/commands/cmd_palette_editor.cpp b/src/commands/cmd_palette_editor.cpp index 7eb41145a..dc2ad5ec1 100644 --- a/src/commands/cmd_palette_editor.cpp +++ b/src/commands/cmd_palette_editor.cpp @@ -249,8 +249,8 @@ PaletteEntryEditor::PaletteEntryEditor() , m_vbox(JI_VERTICAL) , m_topBox(JI_HORIZONTAL) , m_bottomBox(JI_HORIZONTAL) - , m_rgbButton("RGB", 1, JI_BUTTON) - , m_hsvButton("HSB", 1, JI_BUTTON) + , m_rgbButton("RGB", 1, kButtonWidget) + , m_hsvButton("HSB", 1, kButtonWidget) , m_entryLabel("") , m_moreOptions("+") , m_copyButton("Copy") diff --git a/src/commands/filters/color_curve_editor.cpp b/src/commands/filters/color_curve_editor.cpp index 0672692f6..955d8c8c5 100644 --- a/src/commands/filters/color_curve_editor.cpp +++ b/src/commands/filters/color_curve_editor.cpp @@ -75,7 +75,7 @@ enum { using namespace ui; ColorCurveEditor::ColorCurveEditor(ColorCurve* curve, int x1, int y1, int x2, int y2) - : Widget(JI_WIDGET) + : Widget(kGenericWidget) , m_curve(curve) { this->setFocusStop(true); diff --git a/src/commands/filters/filter_preview.cpp b/src/commands/filters/filter_preview.cpp index 063327d01..68b82c496 100644 --- a/src/commands/filters/filter_preview.cpp +++ b/src/commands/filters/filter_preview.cpp @@ -30,7 +30,7 @@ using namespace ui; FilterPreview::FilterPreview(FilterManagerImpl* filterMgr) - : Widget(JI_WIDGET) + : Widget(kGenericWidget) , m_filterMgr(filterMgr) , m_timer(1, this) { diff --git a/src/dialogs/aniedit.cpp b/src/dialogs/aniedit.cpp index d1f041034..ad2c75298 100644 --- a/src/dialogs/aniedit.cpp +++ b/src/dialogs/aniedit.cpp @@ -236,7 +236,7 @@ void switch_between_animation_and_sprite_editor(Context* context) // The Animation Editor AnimationEditor::AnimationEditor(Context* context) - : Widget(JI_WIDGET) + : Widget(kGenericWidget) , m_context(context) { DocumentLocation location = context->getActiveLocation(); diff --git a/src/modules/gui.cpp b/src/modules/gui.cpp index 8d248127d..a9ba229c7 100644 --- a/src/modules/gui.cpp +++ b/src/modules/gui.cpp @@ -451,7 +451,7 @@ void set_gfxicon_to_button(ButtonBase* button, CheckBox* check_button_new(const char *text, int b1, int b2, int b3, int b4) { - CheckBox* widget = new CheckBox(text, JI_BUTTON); + CheckBox* widget = new CheckBox(text, kButtonWidget); widget->setAlign(JI_CENTER | JI_MIDDLE); diff --git a/src/skin/skin_theme.cpp b/src/skin/skin_theme.cpp index 61a7d6ecf..2b1fb828f 100644 --- a/src/skin/skin_theme.cpp +++ b/src/skin/skin_theme.cpp @@ -609,12 +609,12 @@ void SkinTheme::initWidget(Widget* widget) switch (widget->type) { - case JI_BOX: + case kBoxWidget: BORDER(0); widget->child_spacing = 4 * scale; break; - case JI_BUTTON: + case kButtonWidget: BORDER4(m_part[PART_BUTTON_NORMAL_W]->w, m_part[PART_BUTTON_NORMAL_N]->h, m_part[PART_BUTTON_NORMAL_E]->w, @@ -622,7 +622,7 @@ void SkinTheme::initWidget(Widget* widget) widget->child_spacing = 0; break; - case JI_CHECK: + case kCheckWidget: BORDER(2 * scale); widget->child_spacing = 4 * scale; @@ -634,33 +634,33 @@ void SkinTheme::initWidget(Widget* widget) JI_LEFT | JI_MIDDLE)); break; - case JI_ENTRY: + case kEntryWidget: BORDER4(m_part[PART_SUNKEN_NORMAL_W]->w, m_part[PART_SUNKEN_NORMAL_N]->h, m_part[PART_SUNKEN_NORMAL_E]->w, m_part[PART_SUNKEN_NORMAL_S]->h); break; - case JI_GRID: + case kGridWidget: BORDER(0); widget->child_spacing = 4 * scale; break; - case JI_LABEL: + case kLabelWidget: BORDER(1 * scale); static_cast(widget)->setTextColor(getColor(ThemeColor::Text)); break; - case JI_LISTBOX: + case kListBoxWidget: BORDER(0); widget->child_spacing = 0; break; - case JI_LISTITEM: + case kListItemWidget: BORDER(1 * scale); break; - case JI_COMBOBOX: + case kComboBoxWidget: { ComboBox* combobox = dynamic_cast(widget); ASSERT(combobox != NULL); @@ -684,24 +684,24 @@ void SkinTheme::initWidget(Widget* widget) } break; - case JI_MENU: - case JI_MENUBAR: - case JI_MENUBOX: + case kMenuWidget: + case kMenuBarWidget: + case kMenuBoxWidget: BORDER(0); widget->child_spacing = 0; break; - case JI_MENUITEM: + case kMenuItemWidget: BORDER(2 * scale); widget->child_spacing = 18 * scale; break; - case JI_SPLITTER: + case kSplitterWidget: BORDER(0); widget->child_spacing = 3 * scale; break; - case JI_RADIO: + case kRadioWidget: BORDER(2 * scale); widget->child_spacing = 4 * scale; @@ -713,7 +713,7 @@ void SkinTheme::initWidget(Widget* widget) JI_LEFT | JI_MIDDLE)); break; - case JI_SEPARATOR: + case kSeparatorWidget: /* frame */ if ((widget->getAlign() & JI_HORIZONTAL) && (widget->getAlign() & JI_VERTICAL)) { @@ -736,7 +736,7 @@ void SkinTheme::initWidget(Widget* widget) } break; - case JI_SLIDER: + case kSliderWidget: BORDER4(m_part[PART_SLIDER_EMPTY_W]->w-1*scale, m_part[PART_SLIDER_EMPTY_N]->h, m_part[PART_SLIDER_EMPTY_E]->w-1*scale, @@ -745,12 +745,12 @@ void SkinTheme::initWidget(Widget* widget) widget->setAlign(JI_CENTER | JI_MIDDLE); break; - case JI_TEXTBOX: + case kTextBoxWidget: BORDER(0); widget->child_spacing = 0; break; - case JI_VIEW: + case kViewWidget: BORDER4(m_part[PART_SUNKEN_NORMAL_W]->w-1*scale, m_part[PART_SUNKEN_NORMAL_N]->h, m_part[PART_SUNKEN_NORMAL_E]->w-1*scale, @@ -758,17 +758,17 @@ void SkinTheme::initWidget(Widget* widget) widget->child_spacing = 0; break; - case JI_VIEW_SCROLLBAR: + case kViewScrollbarWidget: BORDER(1 * scale); widget->child_spacing = 0; break; - case JI_VIEW_VIEWPORT: + case kViewViewportWidget: BORDER(0); widget->child_spacing = 0; break; - case JI_WINDOW: + case kWindowWidget: if (!static_cast(widget)->isDesktop()) { if (widget->hasText()) { BORDER4(6 * scale, (4+6) * scale, 6 * scale, 6 * scale); @@ -1166,7 +1166,7 @@ void SkinTheme::draw_menuitem(MenuItem* widget, JRect clip) if (!widget->getParent()->getParent()) return; - bar = (widget->getParent()->getParent()->type == JI_MENUBAR); + bar = (widget->getParent()->getParent()->type == kMenuBarWidget); // Colors if (!widget->isEnabled()) { diff --git a/src/ui/base.h b/src/ui/base.h index ecb61cef2..f6ceac706 100644 --- a/src/ui/base.h +++ b/src/ui/base.h @@ -60,41 +60,6 @@ namespace ui { #define JI_NOTEXT 0x0800 // The widget does not have text. #define JI_DIRTY 0x1000 // The widget (or one child) is dirty (update_region != empty). - // Widget types. - enum { - // Undefined (or anonymous) widget type. - JI_WIDGET, - - // Known widgets. - JI_BOX, - JI_BUTTON, - JI_CHECK, - JI_COMBOBOX, - JI_ENTRY, - JI_GRID, - JI_IMAGE_VIEW, - JI_LABEL, - JI_LISTBOX, - JI_LISTITEM, - JI_MANAGER, - JI_MENU, - JI_MENUBAR, - JI_MENUBOX, - JI_MENUITEM, - JI_SPLITTER, - JI_RADIO, - JI_SEPARATOR, - JI_SLIDER, - JI_TEXTBOX, - JI_VIEW, - JI_VIEW_SCROLLBAR, - JI_VIEW_VIEWPORT, - JI_WINDOW, - - // User widgets. - JI_USER_WIDGET, - }; - // JINETE Message types. enum { // General messages. diff --git a/src/ui/box.cpp b/src/ui/box.cpp index b5ee24e84..c37cffe5a 100644 --- a/src/ui/box.cpp +++ b/src/ui/box.cpp @@ -20,7 +20,7 @@ using namespace gfx; namespace ui { Box::Box(int align) - : Widget(JI_BOX) + : Widget(kBoxWidget) { setAlign(align); initTheme(); diff --git a/src/ui/button.cpp b/src/ui/button.cpp index 9d717022e..e4dae0fd0 100644 --- a/src/ui/button.cpp +++ b/src/ui/button.cpp @@ -23,7 +23,10 @@ namespace ui { -ButtonBase::ButtonBase(const char* text, int type, int behaviorType, int drawType) +ButtonBase::ButtonBase(const char* text, + WidgetType type, + WidgetType behaviorType, + WidgetType drawType) : Widget(type) , m_pressedStatus(false) , m_handleSelect(true) @@ -47,12 +50,12 @@ ButtonBase::~ButtonBase() m_iconInterface->destroy(); } -int ButtonBase::getBehaviorType() const +WidgetType ButtonBase::getBehaviorType() const { return m_behaviorType; } -int ButtonBase::getDrawType() const +WidgetType ButtonBase::getDrawType() const { return m_drawType; } @@ -80,7 +83,7 @@ bool ButtonBase::onProcessMessage(Message* msg) case JM_FOCUSENTER: case JM_FOCUSLEAVE: if (isEnabled()) { - if (m_behaviorType == JI_BUTTON) { + if (m_behaviorType == kButtonWidget) { // Deselect the widget (maybe the user press the key, but // before release it, changes the focus). if (isSelected()) @@ -95,8 +98,8 @@ bool ButtonBase::onProcessMessage(Message* msg) case JM_KEYPRESSED: // If the button is enabled. if (isEnabled()) { - // For JI_BUTTON - if (m_behaviorType == JI_BUTTON) { + // For kButtonWidget + if (m_behaviorType == kButtonWidget) { // Has focus and press enter/space if (hasFocus()) { if ((msg->key.scancode == KEY_ENTER) || @@ -126,7 +129,7 @@ bool ButtonBase::onProcessMessage(Message* msg) return true; } } - // For JI_CHECK or JI_RADIO + // For kCheckWidget or kRadioWidget else { /* if the widget has the focus and the user press space or if the user press Alt+the underscored letter of the button */ @@ -134,13 +137,13 @@ bool ButtonBase::onProcessMessage(Message* msg) (msg->key.scancode == KEY_SPACE)) || ((msg->any.shifts & KB_ALT_FLAG) && (isScancodeMnemonic(msg->key.scancode)))) { - if (m_behaviorType == JI_CHECK) { + if (m_behaviorType == kCheckWidget) { // Swap the select status setSelected(!isSelected()); invalidate(); } - else if (m_behaviorType == JI_RADIO) { + else if (m_behaviorType == kRadioWidget) { if (!isSelected()) { setSelected(true); } @@ -153,7 +156,7 @@ bool ButtonBase::onProcessMessage(Message* msg) case JM_KEYRELEASED: if (isEnabled()) { - if (m_behaviorType == JI_BUTTON) { + if (m_behaviorType == kButtonWidget) { if (isSelected()) { generateButtonSelectSignal(); return true; @@ -165,7 +168,7 @@ bool ButtonBase::onProcessMessage(Message* msg) case JM_BUTTONPRESSED: switch (m_behaviorType) { - case JI_BUTTON: + case kButtonWidget: if (isEnabled()) { setSelected(true); @@ -174,7 +177,7 @@ bool ButtonBase::onProcessMessage(Message* msg) } return true; - case JI_CHECK: + case kCheckWidget: if (isEnabled()) { setSelected(!isSelected()); @@ -183,7 +186,7 @@ bool ButtonBase::onProcessMessage(Message* msg) } return true; - case JI_RADIO: + case kRadioWidget: if (isEnabled()) { if (!isSelected()) { m_handleSelect = false; @@ -205,11 +208,11 @@ bool ButtonBase::onProcessMessage(Message* msg) if (hasMouseOver()) { switch (m_behaviorType) { - case JI_BUTTON: + case kButtonWidget: generateButtonSelectSignal(); break; - case JI_CHECK: + case kCheckWidget: { // Fire onClick() event Event ev(this); @@ -219,7 +222,7 @@ bool ButtonBase::onProcessMessage(Message* msg) } break; - case JI_RADIO: + case kRadioWidget: { setSelected(false); setSelected(true); @@ -281,9 +284,9 @@ void ButtonBase::onPreferredSize(PreferredSizeEvent& ev) void ButtonBase::onPaint(PaintEvent& ev) { switch (m_drawType) { - case JI_BUTTON: getTheme()->paintButton(ev); break; - case JI_CHECK: getTheme()->paintCheckBox(ev); break; - case JI_RADIO: getTheme()->paintRadioButton(ev); break; + case kButtonWidget: getTheme()->paintButton(ev); break; + case kCheckWidget: getTheme()->paintCheckBox(ev); break; + case kRadioWidget: getTheme()->paintRadioButton(ev); break; } } @@ -302,7 +305,7 @@ void ButtonBase::generateButtonSelectSignal() // ====================================================================== Button::Button(const char *text) - : ButtonBase(text, JI_BUTTON, JI_BUTTON, JI_BUTTON) + : ButtonBase(text, kButtonWidget, kButtonWidget, kButtonWidget) { setAlign(JI_CENTER | JI_MIDDLE); } @@ -311,8 +314,8 @@ Button::Button(const char *text) // CheckBox class // ====================================================================== -CheckBox::CheckBox(const char *text, int drawType) - : ButtonBase(text, JI_CHECK, JI_CHECK, drawType) +CheckBox::CheckBox(const char *text, WidgetType drawType) + : ButtonBase(text, kCheckWidget, kCheckWidget, drawType) { setAlign(JI_LEFT | JI_MIDDLE); } @@ -321,8 +324,8 @@ CheckBox::CheckBox(const char *text, int drawType) // RadioButton class // ====================================================================== -RadioButton::RadioButton(const char *text, int radioGroup, int drawType) - : ButtonBase(text, JI_RADIO, JI_RADIO, drawType) +RadioButton::RadioButton(const char *text, int radioGroup, WidgetType drawType) + : ButtonBase(text, kRadioWidget, kRadioWidget, drawType) { setAlign(JI_LEFT | JI_MIDDLE); setRadioGroup(radioGroup); @@ -371,7 +374,7 @@ void RadioButton::onSelect() if (!m_handleSelect) return; - if (getBehaviorType() == JI_RADIO) { + if (getBehaviorType() == kRadioWidget) { deselectRadioGroup(); m_handleSelect = false; diff --git a/src/ui/button.h b/src/ui/button.h index 8f43cc07a..fca340b1a 100644 --- a/src/ui/button.h +++ b/src/ui/button.h @@ -37,13 +37,13 @@ namespace ui { { public: ButtonBase(const char* text, - int type, - int behaviorType, - int drawType); + WidgetType type, + WidgetType behaviorType, + WidgetType drawType); virtual ~ButtonBase(); - int getBehaviorType() const; - int getDrawType() const; + WidgetType getBehaviorType() const; + WidgetType getDrawType() const; // Sets the interface used to get icons for the button depending its // state. This interface is deleted automatically in the ButtonBase dtor. @@ -68,8 +68,8 @@ namespace ui { void generateButtonSelectSignal(); bool m_pressedStatus; - int m_behaviorType; - int m_drawType; + WidgetType m_behaviorType; + WidgetType m_drawType; IButtonIcon* m_iconInterface; protected: @@ -87,14 +87,14 @@ namespace ui { class CheckBox : public ButtonBase { public: - CheckBox(const char* text, int drawType = JI_CHECK); + CheckBox(const char* text, WidgetType drawType = kCheckWidget); }; // Radio buttons class RadioButton : public ButtonBase { public: - RadioButton(const char* text, int radioGroup, int drawType = JI_RADIO); + RadioButton(const char* text, int radioGroup, WidgetType drawType = kRadioWidget); int getRadioGroup() const; void setRadioGroup(int radioGroup); diff --git a/src/ui/combobox.cpp b/src/ui/combobox.cpp index 935089fa5..5005cd4af 100644 --- a/src/ui/combobox.cpp +++ b/src/ui/combobox.cpp @@ -78,7 +78,7 @@ private: }; ComboBox::ComboBox() - : Widget(JI_COMBOBOX) + : Widget(kComboBoxWidget) { m_entry = new ComboBoxEntry(this); m_button = new ComboBoxButton(); diff --git a/src/ui/entry.cpp b/src/ui/entry.cpp index 541946a93..8dacbb9b3 100644 --- a/src/ui/entry.cpp +++ b/src/ui/entry.cpp @@ -28,7 +28,7 @@ namespace ui { Entry::Entry(size_t maxsize, const char *format, ...) - : Widget(JI_ENTRY) + : Widget(kEntryWidget) , m_timer(500, this) { char buf[4096]; diff --git a/src/ui/grid.cpp b/src/ui/grid.cpp index 2f2b69474..2b24a579c 100644 --- a/src/ui/grid.cpp +++ b/src/ui/grid.cpp @@ -35,7 +35,7 @@ Grid::Cell::Cell() } Grid::Grid(int columns, bool same_width_columns) - : Widget(JI_GRID) + : Widget(kGridWidget) , m_colstrip(columns) { ASSERT(columns > 0); diff --git a/src/ui/grid_ui_unittest.cpp b/src/ui/grid_ui_unittest.cpp index 3509a9f71..7ad30032f 100644 --- a/src/ui/grid_ui_unittest.cpp +++ b/src/ui/grid_ui_unittest.cpp @@ -27,8 +27,8 @@ using namespace ui; TEST(JGrid, Simple2x1Grid) { Grid* grid = new Grid(2, false); - Widget* w1 = new Widget(JI_WIDGET); - Widget* w2 = new Widget(JI_WIDGET); + Widget* w1 = new Widget(kGenericWidget); + Widget* w2 = new Widget(kGenericWidget); jwidget_set_min_size(w1, 10, 10); jwidget_set_min_size(w2, 10, 10); @@ -66,8 +66,8 @@ TEST(JGrid, Simple2x1Grid) TEST(JGrid, Expand2ndWidget) { Grid* grid = new Grid(2, false); - Widget* w1 = new Widget(JI_WIDGET); - Widget* w2 = new Widget(JI_WIDGET); + Widget* w1 = new Widget(kGenericWidget); + Widget* w2 = new Widget(kGenericWidget); JRect rect; jwidget_set_min_size(w1, 20, 20); @@ -102,8 +102,8 @@ TEST(JGrid, Expand2ndWidget) TEST(JGrid, SameWidth2x1Grid) { Grid* grid = new Grid(2, true); - Widget* w1 = new Widget(JI_WIDGET); - Widget* w2 = new Widget(JI_WIDGET); + Widget* w1 = new Widget(kGenericWidget); + Widget* w2 = new Widget(kGenericWidget); JRect rect; jwidget_set_min_size(w1, 20, 20); @@ -167,10 +167,10 @@ TEST(JGrid, SameWidth2x1Grid) TEST(JGrid, Intrincate3x3Grid) { Grid* grid = new Grid(3, false); - Widget* w1 = new Widget(JI_WIDGET); - Widget* w2 = new Widget(JI_WIDGET); - Widget* w3 = new Widget(JI_WIDGET); - Widget* w4 = new Widget(JI_WIDGET); + Widget* w1 = new Widget(kGenericWidget); + Widget* w2 = new Widget(kGenericWidget); + Widget* w3 = new Widget(kGenericWidget); + Widget* w4 = new Widget(kGenericWidget); JRect rect; jwidget_set_min_size(w1, 10, 10); diff --git a/src/ui/gui.h b/src/ui/gui.h index 1812e0431..bb9b56546 100644 --- a/src/ui/gui.h +++ b/src/ui/gui.h @@ -58,6 +58,7 @@ #include "ui/view.h" #include "ui/viewport.h" #include "ui/widget.h" +#include "ui/widget_type.h" #include "ui/widgets_list.h" #include "ui/window.h" diff --git a/src/ui/image_view.cpp b/src/ui/image_view.cpp index 73d3a8c9a..68697b847 100644 --- a/src/ui/image_view.cpp +++ b/src/ui/image_view.cpp @@ -20,7 +20,7 @@ namespace ui { ImageView::ImageView(BITMAP* bmp, int align) - : Widget(JI_IMAGE_VIEW) + : Widget(kImageViewWidget) { setAlign(align); } diff --git a/src/ui/intern.cpp b/src/ui/intern.cpp index c6509ba1b..609ead773 100644 --- a/src/ui/intern.cpp +++ b/src/ui/intern.cpp @@ -62,7 +62,7 @@ void reinitThemeForAllWidgets() // Remap the windows for (std::list::iterator it=widgets->begin(), end=widgets->end(); it != end; ++it) { - if ((*it)->type == JI_WINDOW) + if ((*it)->type == kWindowWidget) static_cast(*it)->remapWindow(); } diff --git a/src/ui/label.cpp b/src/ui/label.cpp index 85bb1b9a8..0bb9c3f2a 100644 --- a/src/ui/label.cpp +++ b/src/ui/label.cpp @@ -14,7 +14,7 @@ namespace ui { Label::Label(const char *text) - : Widget(JI_LABEL) + : Widget(kLabelWidget) { setAlign(JI_LEFT | JI_MIDDLE); setText(text); diff --git a/src/ui/listbox.cpp b/src/ui/listbox.cpp index a788a5548..1bfacf264 100644 --- a/src/ui/listbox.cpp +++ b/src/ui/listbox.cpp @@ -22,7 +22,7 @@ using namespace gfx; namespace ui { ListBox::ListBox() - : Widget(JI_LISTBOX) + : Widget(kListBoxWidget) { setFocusStop(true); initTheme(); diff --git a/src/ui/listitem.cpp b/src/ui/listitem.cpp index f6e59b2e8..328a121aa 100644 --- a/src/ui/listitem.cpp +++ b/src/ui/listitem.cpp @@ -18,7 +18,7 @@ using namespace gfx; namespace ui { ListItem::ListItem(const char* text) - : Widget(JI_LISTITEM) + : Widget(kListItemWidget) { setAlign(JI_LEFT | JI_MIDDLE); setText(text); diff --git a/src/ui/manager.cpp b/src/ui/manager.cpp index 0fa7460f9..f82dbd68f 100644 --- a/src/ui/manager.cpp +++ b/src/ui/manager.cpp @@ -109,7 +109,7 @@ Manager* Manager::getDefault() } Manager::Manager() - : Widget(JI_MANAGER) + : Widget(kManagerWidget) { if (!m_defaultManager) { // Hook the window close message @@ -1399,7 +1399,7 @@ static Widget* next_widget(Widget* widget) if (!widget->getChildren().empty()) return UI_FIRST_WIDGET(widget->getChildren()); - while (widget->getParent()->type != JI_MANAGER) { + while (widget->getParent()->type != kManagerWidget) { WidgetsList::const_iterator begin = widget->getParent()->getChildren().begin(); WidgetsList::const_iterator end = widget->getParent()->getChildren().end(); WidgetsList::const_iterator it = std::find(begin, end, widget); diff --git a/src/ui/menu.cpp b/src/ui/menu.cpp index d29d6233a..ff4fdc34e 100644 --- a/src/ui/menu.cpp +++ b/src/ui/menu.cpp @@ -110,7 +110,7 @@ static MenuItem* find_nextitem(Menu* menu, MenuItem* menuitem); static MenuItem* find_previtem(Menu* menu, MenuItem* menuitem); Menu::Menu() - : Widget(JI_MENU) + : Widget(kMenuWidget) , m_menuitem(NULL) { initTheme(); @@ -128,7 +128,7 @@ Menu::~Menu() } } -MenuBox::MenuBox(int type) +MenuBox::MenuBox(WidgetType type) : Widget(type) , m_base(NULL) { @@ -147,13 +147,13 @@ MenuBox::~MenuBox() } MenuBar::MenuBar() - : MenuBox(JI_MENUBAR) + : MenuBox(kMenuBarWidget) { createBase(); } MenuItem::MenuItem(const char *text) - : Widget(JI_MENUITEM) + : Widget(kMenuItemWidget) { m_accel = NULL; m_highlighted = false; @@ -320,7 +320,7 @@ void Menu::onPreferredSize(PreferredSizeEvent& ev) UI_FOREACH_WIDGET_WITH_END(getChildren(), it, end) { reqSize = (*it)->getPreferredSize(); - if (this->getParent()->type == JI_MENUBAR) { + if (this->getParent()->type == kMenuBarWidget) { size.w += reqSize.w + ((it+1 != end) ? this->child_spacing: 0); size.h = MAX(size.h, reqSize.h); } @@ -350,14 +350,14 @@ void Menu::set_position(JRect rect) reqSize = child->getPreferredSize(); - if (this->getParent()->type == JI_MENUBAR) + if (this->getParent()->type == kMenuBarWidget) cpos->x2 = cpos->x1+reqSize.w; else cpos->y2 = cpos->y1+reqSize.h; jwidget_set_rect(child, cpos); - if (this->getParent()->type == JI_MENUBAR) + if (this->getParent()->type == kMenuBarWidget) cpos->x1 += jrect_w(cpos); else cpos->y1 += jrect_h(cpos); @@ -400,9 +400,9 @@ bool MenuBox::onProcessMessage(Message* msg) if (picked == NULL || // If the button was clicked nowhere picked == this || // If the button was clicked in this menubox // The picked widget isn't menu-related - (picked->type != JI_MENUBOX && - picked->type != JI_MENUBAR && - picked->type != JI_MENUITEM) || + (picked->type != kMenuBoxWidget && + picked->type != kMenuBarWidget && + picked->type != kMenuItemWidget) || // The picked widget (that is menu-related) isn't from // the same tree of menus (get_base_menubox(picked) != this)) { @@ -416,7 +416,7 @@ bool MenuBox::onProcessMessage(Message* msg) // Get the widget below the mouse cursor Widget* picked = menu->pick(msg->mouse.x, msg->mouse.y); if (picked) { - if ((picked->type == JI_MENUITEM) && + if ((picked->type == kMenuItemWidget) && !(picked->flags & JI_DISABLED)) { // If the picked menu-item is not highlighted... @@ -424,7 +424,7 @@ bool MenuBox::onProcessMessage(Message* msg) // In menu-bar always open the submenu, in other popup-menus // open the submenu only if the user does click bool open_submenu = - (this->type == JI_MENUBAR) || + (this->type == kMenuBarWidget) || (msg->type == JM_BUTTONPRESSED); menu->highlightItem(static_cast(picked), false, open_submenu, false); @@ -485,9 +485,9 @@ bool MenuBox::onProcessMessage(Message* msg) get_base(this)->was_clicked = false; // Check for ALT+some underlined letter - if (((this->type == JI_MENUBOX) && (msg->any.shifts == 0 || // Inside menu-boxes we can use letters without Alt modifier pressed - msg->any.shifts == KB_ALT_FLAG)) || - ((this->type == JI_MENUBAR) && (msg->any.shifts == KB_ALT_FLAG))) { + if (((this->type == kMenuBoxWidget) && (msg->any.shifts == 0 || // Inside menu-boxes we can use letters without Alt modifier pressed + msg->any.shifts == KB_ALT_FLAG)) || + ((this->type == kMenuBarWidget) && (msg->any.shifts == KB_ALT_FLAG))) { selected = check_for_letter(menu, scancode_to_ascii(msg->key.scancode)); if (selected) { menu->highlightItem(selected, true, true, true); @@ -504,7 +504,7 @@ bool MenuBox::onProcessMessage(Message* msg) // Search a child with highlight or the submenu opened UI_FOREACH_WIDGET(menu->getChildren(), it) { Widget* child = *it; - if (child->type != JI_MENUITEM) + if (child->type != kMenuItemWidget) continue; if (static_cast(child)->hasSubmenuOpened()) @@ -518,7 +518,7 @@ bool MenuBox::onProcessMessage(Message* msg) case KEY_ESC: // In menu-bar - if (this->type == JI_MENUBAR) { + if (this->type == kMenuBarWidget) { if (highlight) { cancelMenuLoop(); used = true; @@ -541,7 +541,7 @@ bool MenuBox::onProcessMessage(Message* msg) case KEY_UP: // In menu-bar - if (this->type == JI_MENUBAR) { + if (this->type == kMenuBarWidget) { if (child_with_submenu_opened) child_with_submenu_opened->closeSubmenu(true); } @@ -556,7 +556,7 @@ bool MenuBox::onProcessMessage(Message* msg) case KEY_DOWN: // In menu-bar - if (this->type == JI_MENUBAR) { + if (this->type == kMenuBarWidget) { // Select the active menu menu->highlightItem(highlight, true, true, true); } @@ -571,7 +571,7 @@ bool MenuBox::onProcessMessage(Message* msg) case KEY_LEFT: // In menu-bar - if (this->type == JI_MENUBAR) { + if (this->type == kMenuBarWidget) { // Go to previous highlight = find_previtem(menu, highlight); menu->highlightItem(highlight, false, false, false); @@ -585,7 +585,7 @@ bool MenuBox::onProcessMessage(Message* msg) // Go to the previous item in the parent // If the parent is the menu-bar - if (parent->type == JI_MENUBAR) { + if (parent->type == kMenuBarWidget) { menu = static_cast(parent)->getMenu(); MenuItem* menuitem = find_previtem(menu, menu->getHighlightedItem()); @@ -604,7 +604,7 @@ bool MenuBox::onProcessMessage(Message* msg) case KEY_RIGHT: // In menu-bar - if (this->type == JI_MENUBAR) { + if (this->type == kMenuBarWidget) { // Go to next highlight = find_nextitem(menu, highlight); menu->highlightItem(highlight, false, false, false); @@ -733,7 +733,7 @@ bool MenuItem::onProcessMessage(Message* msg) // Menubox position pos = jwidget_get_rect(window); - if (this->getParent()->getParent()->type == JI_MENUBAR) { + if (this->getParent()->getParent()->type == kMenuBarWidget) { jrect_moveto(pos, MID(0, this->rc->x1, JI_SCREEN_W-jrect_w(pos)), MID(0, this->rc->y2, JI_SCREEN_H-jrect_h(pos))); @@ -785,7 +785,7 @@ bool MenuItem::onProcessMessage(Message* msg) UI_FOREACH_WIDGET(m_submenu->getChildren(), it) { Widget* child = *it; - if (child->type != JI_MENUITEM) + if (child->type != kMenuItemWidget) continue; if (child->isEnabled()) { @@ -824,7 +824,7 @@ bool MenuItem::onProcessMessage(Message* msg) ASSERT(menubox != NULL); window = (Window*)menubox->getParent(); - ASSERT(window && window->type == JI_WINDOW); + ASSERT(window && window->type == kWindowWidget); // Fetch the "menu" to avoid destroy it with 'delete'. menubox->setMenu(NULL); @@ -886,7 +886,7 @@ void MenuItem::onClick() void MenuItem::onPreferredSize(PreferredSizeEvent& ev) { Size size(0, 0); - int bar = (this->getParent()->getParent()->type == JI_MENUBAR); + int bar = (this->getParent()->getParent()->type == kMenuBarWidget); if (this->hasText()) { size.w = @@ -915,7 +915,7 @@ static MenuBox* get_base_menubox(Widget* widget) ASSERT_VALID_WIDGET(widget); // We are in a menubox - if (widget->type == JI_MENUBOX || widget->type == JI_MENUBAR) { + if (widget->type == kMenuBoxWidget || widget->type == kMenuBarWidget) { if (static_cast(widget)->getBase()) { return static_cast(widget); } @@ -930,9 +930,9 @@ static MenuBox* get_base_menubox(Widget* widget) } // We are in a menuitem else { - ASSERT(widget->type == JI_MENUITEM); + ASSERT(widget->type == kMenuItemWidget); ASSERT(widget->getParent() != NULL); - ASSERT(widget->getParent()->type == JI_MENU); + ASSERT(widget->getParent()->type == kMenuWidget); widget = widget->getParent()->getParent(); } @@ -952,7 +952,7 @@ MenuItem* Menu::getHighlightedItem() { UI_FOREACH_WIDGET(getChildren(), it) { Widget* child = *it; - if (child->type != JI_MENUITEM) + if (child->type != kMenuItemWidget) continue; MenuItem* menuitem = static_cast(child); @@ -967,7 +967,7 @@ void Menu::highlightItem(MenuItem* menuitem, bool click, bool open_submenu, bool // Find the menuitem with the highlight UI_FOREACH_WIDGET(getChildren(), it) { Widget* child = *it; - if (child->type != JI_MENUITEM) + if (child->type != kMenuItemWidget) continue; if (child != menuitem) { @@ -1033,7 +1033,7 @@ void MenuItem::openSubmenu(bool select_first) if (menu->getParent()) { UI_FOREACH_WIDGET(menu->getChildren(), it) { Widget* child = *it; - if (child->type != JI_MENUITEM) + if (child->type != kMenuItemWidget) continue; MenuItem* childMenuItem = static_cast(child); @@ -1081,7 +1081,7 @@ void MenuItem::closeSubmenu(bool last_of_close_chain) UI_FOREACH_WIDGET(menu->getChildren(), it) { Widget* child = *it; - if (child->type != JI_MENUITEM) + if (child->type != kMenuItemWidget) continue; if (static_cast(child)->hasSubmenuOpened()) @@ -1149,7 +1149,7 @@ void Menu::closeAll() else { UI_FOREACH_WIDGET(menu->getChildren(), it) { Widget* child = *it; - if (child->type != JI_MENUITEM) + if (child->type != kMenuItemWidget) continue; menuitem = static_cast(child); @@ -1159,7 +1159,7 @@ void Menu::closeAll() } // For popuped menus - if (base_menubox->type == JI_MENUBOX) + if (base_menubox->type == kMenuBoxWidget) base_menubox->closePopup(); } @@ -1198,7 +1198,7 @@ static MenuItem* check_for_letter(Menu* menu, int ascii) { UI_FOREACH_WIDGET(menu->getChildren(), it) { Widget* child = *it; - if (child->type != JI_MENUITEM) + if (child->type != kMenuItemWidget) continue; MenuItem* menuitem = static_cast(child); @@ -1213,7 +1213,7 @@ static MenuItem* check_for_accel(Menu* menu, Message* msg) { UI_FOREACH_WIDGET(menu->getChildren(), it) { Widget* child = *it; - if (child->type != JI_MENUITEM) + if (child->type != kMenuItemWidget) continue; MenuItem* menuitem = static_cast(child); @@ -1250,7 +1250,7 @@ static MenuItem* find_nextitem(Menu* menu, MenuItem* menuitem) for (; it != end; ++it) { Widget* nextitem = *it; - if ((nextitem->type == JI_MENUITEM) && nextitem->isEnabled()) + if ((nextitem->type == kMenuItemWidget) && nextitem->isEnabled()) return static_cast(nextitem); } @@ -1275,7 +1275,7 @@ static MenuItem* find_previtem(Menu* menu, MenuItem* menuitem) for (; it != end; ++it) { Widget* nextitem = *it; - if ((nextitem->type == JI_MENUITEM) && nextitem->isEnabled()) + if ((nextitem->type == kMenuItemWidget) && nextitem->isEnabled()) return static_cast(nextitem); } diff --git a/src/ui/menu.h b/src/ui/menu.h index dd412da00..b64274ca8 100644 --- a/src/ui/menu.h +++ b/src/ui/menu.h @@ -57,7 +57,7 @@ namespace ui { class MenuBox : public Widget { public: - MenuBox(int type = JI_MENUBOX); + MenuBox(WidgetType type = kMenuBoxWidget); ~MenuBox(); Menu* getMenu(); diff --git a/src/ui/message.cpp b/src/ui/message.cpp index 30d5df6ad..11a7d6b5b 100644 --- a/src/ui/message.cpp +++ b/src/ui/message.cpp @@ -140,7 +140,7 @@ void jmessage_broadcast_to_parents(Message* msg, Widget* widget) ASSERT(msg != NULL); ASSERT_VALID_WIDGET(widget); - if (widget && widget->type != JI_MANAGER) { + if (widget && widget->type != kManagerWidget) { jmessage_add_dest(msg, widget); jmessage_broadcast_to_parents(msg, widget->getParent()); } diff --git a/src/ui/scroll_bar.cpp b/src/ui/scroll_bar.cpp index d73a0e7b6..9a82af6ef 100644 --- a/src/ui/scroll_bar.cpp +++ b/src/ui/scroll_bar.cpp @@ -22,7 +22,7 @@ int ScrollBar::m_wherepos = 0; int ScrollBar::m_whereclick = 0; ScrollBar::ScrollBar(int align) - : Widget(JI_VIEW_SCROLLBAR) + : Widget(kViewScrollbarWidget) , m_pos(0) , m_size(0) { diff --git a/src/ui/separator.cpp b/src/ui/separator.cpp index 3a5e1cf80..8120be7ad 100644 --- a/src/ui/separator.cpp +++ b/src/ui/separator.cpp @@ -18,7 +18,7 @@ using namespace gfx; namespace ui { Separator::Separator(const char* text, int align) - : Widget(JI_SEPARATOR) + : Widget(kSeparatorWidget) { setAlign(align); setText(text); diff --git a/src/ui/slider.cpp b/src/ui/slider.cpp index c4009ce7f..7272bd1d0 100644 --- a/src/ui/slider.cpp +++ b/src/ui/slider.cpp @@ -25,7 +25,7 @@ static int slider_press_value; static int slider_press_left; Slider::Slider(int min, int max, int value) - : Widget(JI_SLIDER) + : Widget(kSliderWidget) { m_min = min; m_max = max; diff --git a/src/ui/splitter.cpp b/src/ui/splitter.cpp index aee50cff9..1efa08af8 100644 --- a/src/ui/splitter.cpp +++ b/src/ui/splitter.cpp @@ -22,7 +22,7 @@ using namespace gfx; namespace ui { Splitter::Splitter(Type type, int align) - : Widget(JI_SPLITTER) + : Widget(kSplitterWidget) , m_type(type) , m_pos(50) { diff --git a/src/ui/textbox.cpp b/src/ui/textbox.cpp index a95201aa2..ec901fa1e 100644 --- a/src/ui/textbox.cpp +++ b/src/ui/textbox.cpp @@ -21,7 +21,7 @@ namespace ui { TextBox::TextBox(const char* text, int align) - : Widget(JI_TEXTBOX) + : Widget(kTextBoxWidget) { setFocusStop(true); setAlign(align); diff --git a/src/ui/tooltips.cpp b/src/ui/tooltips.cpp index 67871e498..d3babd1fa 100644 --- a/src/ui/tooltips.cpp +++ b/src/ui/tooltips.cpp @@ -24,7 +24,7 @@ using namespace gfx; namespace ui { TooltipManager::TooltipManager() - : Widget(JI_WIDGET) + : Widget(kGenericWidget) { Manager* manager = Manager::getDefault(); manager->addMessageFilter(JM_MOUSEENTER, this); diff --git a/src/ui/view.cpp b/src/ui/view.cpp index 72b035c1c..72138cc09 100644 --- a/src/ui/view.cpp +++ b/src/ui/view.cpp @@ -23,7 +23,7 @@ using namespace gfx; namespace ui { View::View() - : Widget(JI_VIEW) + : Widget(kViewWidget) , m_scrollbar_h(JI_HORIZONTAL) , m_scrollbar_v(JI_VERTICAL) { @@ -227,9 +227,9 @@ Rect View::getViewportBounds() View* View::getView(Widget* widget) { if ((widget->getParent()) && - (widget->getParent()->type == JI_VIEW_VIEWPORT) && + (widget->getParent()->type == kViewViewportWidget) && (widget->getParent()->getParent()) && - (widget->getParent()->getParent()->type == JI_VIEW)) + (widget->getParent()->getParent()->type == kViewWidget)) return static_cast(widget->getParent()->getParent()); else return 0; diff --git a/src/ui/viewport.cpp b/src/ui/viewport.cpp index 3085b4eb0..5e8131cd8 100644 --- a/src/ui/viewport.cpp +++ b/src/ui/viewport.cpp @@ -19,7 +19,7 @@ using namespace gfx; namespace ui { Viewport::Viewport() - : Widget(JI_VIEW_VIEWPORT) + : Widget(kViewViewportWidget) { initTheme(); } diff --git a/src/ui/widget.cpp b/src/ui/widget.cpp index f97942b9e..99ac9a0f2 100644 --- a/src/ui/widget.cpp +++ b/src/ui/widget.cpp @@ -33,13 +33,13 @@ static inline void mark_dirty_flag(Widget* widget) } } -int ji_register_widget_type() +WidgetType register_widget_type() { - static int type = JI_USER_WIDGET; - return type++; + static int type = (int)kFirstUserWidget; + return (WidgetType)type++; } -Widget::Widget(int type) +Widget::Widget(WidgetType type) { addWidget(this); @@ -80,7 +80,7 @@ Widget::Widget(int type) Widget::~Widget() { // Break relationship with the manager. - if (this->type != JI_MANAGER) { + if (this->type != kManagerWidget) { Manager* manager = getManager(); manager->freeWidget(this); manager->removeMessagesFor(this); @@ -341,7 +341,7 @@ Window* Widget::getRoot() Widget* widget = this; while (widget) { - if (widget->type == JI_WINDOW) + if (widget->type == kWindowWidget) return dynamic_cast(widget); widget = widget->m_parent; @@ -355,7 +355,7 @@ Manager* Widget::getManager() Widget* widget = this; while (widget) { - if (widget->type == JI_MANAGER) + if (widget->type == kManagerWidget) return static_cast(widget); widget = widget->m_parent; @@ -609,7 +609,7 @@ void Widget::setBorder(const Border& br) void Widget::getRegion(gfx::Region& region) { - if (this->type == JI_WINDOW) + if (this->type == kWindowWidget) getTheme()->getWindowMask(this, region); else region = getBounds(); diff --git a/src/ui/widget.h b/src/ui/widget.h index d55dcec87..48f9c5498 100644 --- a/src/ui/widget.h +++ b/src/ui/widget.h @@ -17,6 +17,7 @@ #include "ui/color.h" #include "ui/component.h" #include "ui/rect.h" +#include "ui/widget_type.h" #include "ui/widgets_list.h" #define ASSERT_VALID_WIDGET(widget) ASSERT((widget) != NULL) @@ -37,7 +38,7 @@ namespace ui { class Theme; class Window; - int ji_register_widget_type(); + WidgetType register_widget_type(); // Position and geometry @@ -61,7 +62,7 @@ namespace ui { class Widget : public Component { public: - int type; /* widget's type */ + WidgetType type; // widget's type JRect rc; /* position rectangle */ struct { @@ -87,7 +88,7 @@ namespace ui { // CTOR & DTOR // =============================================================== - Widget(int type); + Widget(WidgetType type); virtual ~Widget(); // Safe way to delete a widget when it is not in the manager message @@ -96,7 +97,7 @@ namespace ui { // Main properties. - int getType() const { return this->type; } + WidgetType getType() const { return this->type; } const std::string& getId() const { return m_id; } void setId(const char* id) { m_id = id; } diff --git a/src/ui/widget_type.h b/src/ui/widget_type.h new file mode 100644 index 000000000..062bf7f8a --- /dev/null +++ b/src/ui/widget_type.h @@ -0,0 +1,50 @@ +// ASEPRITE gui library +// Copyright (C) 2001-2013 David Capello +// +// This source file is distributed under a BSD-like license, please +// read LICENSE.txt for more information. + +#ifndef UI_WIDGET_TYPE_H_INCLUDED +#define UI_WIDGET_TYPE_H_INCLUDED + +namespace ui { + + // Widget types. + enum WidgetType { + // Undefined (or anonymous) widget type. + kGenericWidget, + + // Known widgets. + kBoxWidget, + kButtonWidget, + kCheckWidget, + kComboBoxWidget, + kEntryWidget, + kGridWidget, + kImageViewWidget, + kLabelWidget, + kListBoxWidget, + kListItemWidget, + kManagerWidget, + kMenuWidget, + kMenuBarWidget, + kMenuBoxWidget, + kMenuItemWidget, + kSplitterWidget, + kRadioWidget, + kSeparatorWidget, + kSliderWidget, + kTextBoxWidget, + kViewWidget, + kViewScrollbarWidget, + kViewViewportWidget, + kWindowWidget, + + // User widgets. + kFirstUserWidget, + kLastUserWidget = 0x7fffffff + }; + +} // namespace ui + +#endif // UI_WIDGET_TYPE_H_INCLUDED diff --git a/src/ui/window.cpp b/src/ui/window.cpp index 80552fdaf..0841fd5fc 100644 --- a/src/ui/window.cpp +++ b/src/ui/window.cpp @@ -34,7 +34,7 @@ static int press_x, press_y; static void displace_widgets(Widget* widget, int x, int y); Window::Window(bool desktop, const char* text) - : Widget(JI_WINDOW) + : Widget(kWindowWidget) { m_killer = NULL; m_isDesktop = desktop; diff --git a/src/widgets/button_set.cpp b/src/widgets/button_set.cpp index 101eea906..d288280fc 100644 --- a/src/widgets/button_set.cpp +++ b/src/widgets/button_set.cpp @@ -39,7 +39,7 @@ class ButtonSet::Item : public RadioButton { public: Item(int index, int radioGroup, int b1, int b2, int b3, int b4) - : RadioButton(NULL, radioGroup, JI_BUTTON) + : RadioButton(NULL, radioGroup, kButtonWidget) , m_index(index) { setRadioGroup(radioGroup); diff --git a/src/widgets/color_bar.cpp b/src/widgets/color_bar.cpp index 6111b9765..70acd4ce0 100644 --- a/src/widgets/color_bar.cpp +++ b/src/widgets/color_bar.cpp @@ -77,7 +77,7 @@ ColorBar* ColorBar::m_instance = NULL; ColorBar::ColorBar(int align) : Box(align) - , m_paletteButton("Edit Palette", JI_BUTTON) + , m_paletteButton("Edit Palette", kButtonWidget) , m_paletteView(false) , m_fgColor(app::Color::fromIndex(15), IMAGE_INDEXED) , m_bgColor(app::Color::fromIndex(0), IMAGE_INDEXED) diff --git a/src/widgets/color_button.cpp b/src/widgets/color_button.cpp index aa1d6a957..d8ecd5f95 100644 --- a/src/widgets/color_button.cpp +++ b/src/widgets/color_button.cpp @@ -37,16 +37,16 @@ using namespace ui; -static int colorbutton_type() +static WidgetType colorbutton_type() { - static int type = 0; - if (!type) - type = ji_register_widget_type(); + static WidgetType type = kGenericWidget; + if (type == kGenericWidget) + type = register_widget_type(); return type; } ColorButton::ColorButton(const app::Color& color, PixelFormat pixelFormat) - : ButtonBase("", colorbutton_type(), JI_BUTTON, JI_BUTTON) + : ButtonBase("", colorbutton_type(), kButtonWidget, kButtonWidget) , m_color(color) , m_pixelFormat(pixelFormat) , m_window(NULL) diff --git a/src/widgets/color_selector.cpp b/src/widgets/color_selector.cpp index e584b727c..8800d018f 100644 --- a/src/widgets/color_selector.cpp +++ b/src/widgets/color_selector.cpp @@ -43,11 +43,11 @@ ColorSelector::ColorSelector() , m_vbox(JI_VERTICAL) , m_topBox(JI_HORIZONTAL) , m_colorPalette(false) - , m_indexButton("Index", 1, JI_BUTTON) - , m_rgbButton("RGB", 1, JI_BUTTON) - , m_hsvButton("HSB", 1, JI_BUTTON) - , m_grayButton("Gray", 1, JI_BUTTON) - , m_maskButton("Mask", 1, JI_BUTTON) + , m_indexButton("Index", 1, kButtonWidget) + , m_rgbButton("RGB", 1, kButtonWidget) + , m_hsvButton("HSB", 1, kButtonWidget) + , m_grayButton("Gray", 1, kButtonWidget) + , m_maskButton("Mask", 1, kButtonWidget) , m_maskLabel("Transparent Color Selected") , m_disableHexUpdate(false) { diff --git a/src/widgets/color_sliders.cpp b/src/widgets/color_sliders.cpp index 2dbea2c35..506a9bd96 100644 --- a/src/widgets/color_sliders.cpp +++ b/src/widgets/color_sliders.cpp @@ -91,7 +91,7 @@ namespace { // ColorSliders ColorSliders::ColorSliders() - : Widget(JI_WIDGET) + : Widget(kGenericWidget) , m_grid(3, false) { addChild(&m_grid); diff --git a/src/widgets/editor/editor.cpp b/src/widgets/editor/editor.cpp index e1fff10fb..acba1971a 100644 --- a/src/widgets/editor/editor.cpp +++ b/src/widgets/editor/editor.cpp @@ -175,11 +175,11 @@ Editor::~Editor() delete m_fgColorChangeSlot; } -int editor_type() +WidgetType editor_type() { - static int type = 0; - if (!type) - type = ji_register_widget_type(); + static WidgetType type = kGenericWidget; + if (type == kGenericWidget) + type = register_widget_type(); return type; } diff --git a/src/widgets/editor/editor.h b/src/widgets/editor/editor.h index f10c66937..f3277f439 100644 --- a/src/widgets/editor/editor.h +++ b/src/widgets/editor/editor.h @@ -236,6 +236,6 @@ private: widgets::DocumentView* m_docView; }; -int editor_type(); +ui::WidgetType editor_type(); #endif diff --git a/src/widgets/file_list.cpp b/src/widgets/file_list.cpp index 718bb16a2..2a4c4328e 100644 --- a/src/widgets/file_list.cpp +++ b/src/widgets/file_list.cpp @@ -36,7 +36,7 @@ using namespace ui; namespace widgets { FileList::FileList() - : Widget(JI_WIDGET) + : Widget(kGenericWidget) , m_generateThumbnailTimer(200, this) , m_monitoringTimer(50, this) { diff --git a/src/widgets/palette_view.cpp b/src/widgets/palette_view.cpp index cd126544f..68ea91c04 100644 --- a/src/widgets/palette_view.cpp +++ b/src/widgets/palette_view.cpp @@ -43,11 +43,11 @@ using namespace ui; -int palette_view_type() +WidgetType palette_view_type() { - static int type = 0; - if (!type) - type = ji_register_widget_type(); + static WidgetType type = kGenericWidget; + if (type == kGenericWidget) + type = register_widget_type(); return type; } diff --git a/src/widgets/palette_view.h b/src/widgets/palette_view.h index 52e9a639f..5a5373a7f 100644 --- a/src/widgets/palette_view.h +++ b/src/widgets/palette_view.h @@ -67,6 +67,6 @@ private: bool m_isUpdatingColumns; }; -int palette_view_type(); +ui::WidgetType palette_view_type(); #endif diff --git a/src/widgets/status_bar.cpp b/src/widgets/status_bar.cpp index fb3e42693..ae72bdb56 100644 --- a/src/widgets/status_bar.cpp +++ b/src/widgets/status_bar.cpp @@ -90,11 +90,11 @@ private: static void slider_change_hook(Slider* slider); static void ani_button_command(Button* widget, AniAction action); -static int statusbar_type() +static WidgetType statusbar_type() { - static int type = 0; - if (!type) - type = ji_register_widget_type(); + static WidgetType type = kGenericWidget; + if (type == kGenericWidget) + type = register_widget_type(); return type; } diff --git a/src/widgets/tabs.cpp b/src/widgets/tabs.cpp index 6accd3e00..b6b2044ad 100644 --- a/src/widgets/tabs.cpp +++ b/src/widgets/tabs.cpp @@ -39,11 +39,11 @@ using namespace ui; #define HAS_ARROWS(tabs) ((m_button_left->getParent() == (tabs))) -static int tabs_type() +static WidgetType tabs_type() { - static int type = 0; - if (!type) - type = ji_register_widget_type(); + static WidgetType type = kGenericWidget; + if (type == kGenericWidget) + type = register_widget_type(); return type; } diff --git a/src/widgets/toolbar.cpp b/src/widgets/toolbar.cpp index 43863a104..80017df31 100644 --- a/src/widgets/toolbar.cpp +++ b/src/widgets/toolbar.cpp @@ -86,7 +86,7 @@ static Size getToolIconSize(Widget* widget) ToolBar* ToolBar::m_instance = NULL; ToolBar::ToolBar() - : Widget(JI_WIDGET) + : Widget(kGenericWidget) , m_tipTimer(300, this) { m_instance = this; @@ -576,7 +576,7 @@ void ToolBar::onClosePopup() ////////////////////////////////////////////////////////////////////// ToolStrip::ToolStrip(ToolGroup* group, ToolBar* toolbar) - : Widget(JI_WIDGET) + : Widget(kGenericWidget) { m_group = group; m_hot_tool = NULL;