diff --git a/src/app.cpp b/src/app.cpp index 6a03b1ae8..3e42c1ca1 100644 --- a/src/app.cpp +++ b/src/app.cpp @@ -207,12 +207,12 @@ int App::run() app_default_statusbar_message(); /* add the widgets in the boxes */ - if (box_menubar) jwidget_add_child(box_menubar, menubar); - if (box_editors) jwidget_add_child(box_editors, view); - if (box_colorbar) jwidget_add_child(box_colorbar, colorbar); - if (box_toolbar) jwidget_add_child(box_toolbar, toolbar); - if (box_statusbar) jwidget_add_child(box_statusbar, statusbar); - if (box_tabsbar) jwidget_add_child(box_tabsbar, tabsbar); + if (box_menubar) box_menubar->addChild(menubar); + if (box_editors) box_editors->addChild(view); + if (box_colorbar) box_colorbar->addChild(colorbar); + if (box_toolbar) box_toolbar->addChild(toolbar); + if (box_statusbar) box_statusbar->addChild(statusbar); + if (box_tabsbar) box_tabsbar->addChild(tabsbar); /* prepare the window */ top_window->remap_window(); @@ -435,13 +435,13 @@ bool app_realloc_recent_list() params.set("filename", filename); menuitem = menuitem_new(get_filename(filename), cmd_open_file, ¶ms); - jwidget_add_child(submenu, menuitem); + submenu->addChild(menuitem); } } else { menuitem = menuitem_new("Nothing", NULL, NULL); menuitem->setEnabled(false); - jwidget_add_child(submenu, menuitem); + submenu->addChild(menuitem); } } diff --git a/src/commands/cmd_about.cpp b/src/commands/cmd_about.cpp index 8a5e489c1..68a4919af 100644 --- a/src/commands/cmd_about.cpp +++ b/src/commands/cmd_about.cpp @@ -87,9 +87,12 @@ void AboutCommand::onExecute(Context* context) jwidget_expansive(bottom_box2, true); jwidget_expansive(bottom_box3, true); - jwidget_add_children(bottom_box1, bottom_box2, close_button, bottom_box3, NULL); - jwidget_add_child(box1, grid); - jwidget_add_child(frame, box1); + bottom_box1->addChild(bottom_box2); + bottom_box1->addChild(close_button); + bottom_box1->addChild(bottom_box3); + + box1->addChild(grid); + frame->addChild(box1); jwidget_set_border(close_button, close_button->border_width.l + 16*jguiscale(), diff --git a/src/commands/cmd_configure_tools.cpp b/src/commands/cmd_configure_tools.cpp index 19c8ac73e..8bda57cef 100644 --- a/src/commands/cmd_configure_tools.cpp +++ b/src/commands/cmd_configure_tools.cpp @@ -300,8 +300,8 @@ void ConfigureTools::onExecute(Context* context) if (first_time) { // Append children - jwidget_add_child(brush_preview_box, brush_preview); - jwidget_add_child(brush_type_box, brush_type); + brush_preview_box->addChild(brush_preview); + brush_type_box->addChild(brush_type); // Slots window->Close.connect(Bind(&window_close_hook, (JWidget)window, (void*)0)); diff --git a/src/commands/cmd_developer_console.cpp b/src/commands/cmd_developer_console.cpp index b4db118af..c3d903add 100644 --- a/src/commands/cmd_developer_console.cpp +++ b/src/commands/cmd_developer_console.cpp @@ -34,8 +34,8 @@ public: : Frame(false, "Developer Console") , m_vbox(JI_VERTICAL) { - jwidget_add_child(&m_vbox, &m_docs); - jwidget_add_child(this, &m_vbox); + m_vbox.addChild(&m_docs); + addChild(&m_vbox); remap_window(); center_window(); diff --git a/src/commands/cmd_layer_properties.cpp b/src/commands/cmd_layer_properties.cpp index 4c716f2ec..c3bc27a40 100644 --- a/src/commands/cmd_layer_properties.cpp +++ b/src/commands/cmd_layer_properties.cpp @@ -77,13 +77,13 @@ void LayerPropertiesCommand::onExecute(Context* context) jwidget_set_min_size(entry_name, 128, 0); jwidget_expansive(entry_name, true); - jwidget_add_child(box2, label_name); - jwidget_add_child(box2, entry_name); - jwidget_add_child(box1, box2); - jwidget_add_child(box3, button_ok); - jwidget_add_child(box3, button_cancel); - jwidget_add_child(box1, box3); - jwidget_add_child(window, box1); + box2->addChild(label_name); + box2->addChild(entry_name); + box1->addChild(box2); + box3->addChild(button_ok); + box3->addChild(button_cancel); + box1->addChild(box3); + window->addChild(box1); jwidget_magnetic(entry_name, true); jwidget_magnetic(button_ok, true); diff --git a/src/commands/cmd_options.cpp b/src/commands/cmd_options.cpp index b2b96f2dd..724a76721 100644 --- a/src/commands/cmd_options.cpp +++ b/src/commands/cmd_options.cpp @@ -97,17 +97,17 @@ void OptionsCommand::onExecute(Context* context) // Cursor color cursor_color = new ColorButton(Editor::get_cursor_color(), IMAGE_RGB); cursor_color->setName("cursor_color"); - jwidget_add_child(cursor_color_box, cursor_color); + cursor_color_box->addChild(cursor_color); // Grid color grid_color = new ColorButton(context->getSettings()->getGridColor(), IMAGE_RGB); grid_color->setName("grid_color"); - jwidget_add_child(grid_color_box, grid_color); + grid_color_box->addChild(grid_color); // Pixel grid color pixel_grid_color = new ColorButton(context->getSettings()->getPixelGridColor(), IMAGE_RGB); pixel_grid_color->setName("pixel_grid_color"); - jwidget_add_child(pixel_grid_color_box, pixel_grid_color); + pixel_grid_color_box->addChild(pixel_grid_color); // Others if (get_config_bool("Options", "MoveClick2", false)) @@ -134,8 +134,8 @@ void OptionsCommand::onExecute(Context* context) m_checked_bg_color1 = new ColorButton(RenderEngine::getCheckedBgColor1(), IMAGE_RGB); m_checked_bg_color2 = new ColorButton(RenderEngine::getCheckedBgColor2(), IMAGE_RGB); - jwidget_add_child(checked_bg_color1_box, m_checked_bg_color1); - jwidget_add_child(checked_bg_color2_box, m_checked_bg_color2); + checked_bg_color1_box->addChild(m_checked_bg_color1); + checked_bg_color2_box->addChild(m_checked_bg_color2); // Reset button checked_bg_reset->Click.connect(Bind(&OptionsCommand::onResetCheckedBg, this)); diff --git a/src/commands/cmd_palette_editor.cpp b/src/commands/cmd_palette_editor.cpp index a4d65251e..9b22ac694 100644 --- a/src/commands/cmd_palette_editor.cpp +++ b/src/commands/cmd_palette_editor.cpp @@ -248,33 +248,29 @@ PaletteEntryEditor::PaletteEntryEditor() setup_mini_look(&m_quantizeButton); // Top box - jwidget_add_child(&m_topBox, &m_rgbButton); - jwidget_add_child(&m_topBox, &m_hsvButton); - jwidget_add_child(&m_topBox, &m_hexColorEntry); - { - Box* filler = new Box(JI_HORIZONTAL); - jwidget_expansive(filler, true); - jwidget_add_child(&m_topBox, filler); - } - jwidget_add_child(&m_topBox, &m_moreOptions); + m_topBox.addChild(&m_rgbButton); + m_topBox.addChild(&m_hsvButton); + m_topBox.addChild(&m_hexColorEntry); + m_topBox.addChild(new BoxFiller); + m_topBox.addChild(&m_moreOptions); // Bottom box { Box* box = new Box(JI_HORIZONTAL); box->child_spacing = 0; - jwidget_add_child(box, &m_loadButton); - jwidget_add_child(box, &m_saveButton); - jwidget_add_child(&m_bottomBox, box); + box->addChild(&m_loadButton); + box->addChild(&m_saveButton); + m_bottomBox.addChild(box); } - jwidget_add_child(&m_bottomBox, &m_rampButton); - jwidget_add_child(&m_bottomBox, &m_quantizeButton); + m_bottomBox.addChild(&m_rampButton); + m_bottomBox.addChild(&m_quantizeButton); // Main vertical box - jwidget_add_child(&m_vbox, &m_topBox); - jwidget_add_child(&m_vbox, &m_rgbSliders); - jwidget_add_child(&m_vbox, &m_hsvSliders); - jwidget_add_child(&m_vbox, &m_bottomBox); - jwidget_add_child(this, &m_vbox); + m_vbox.addChild(&m_topBox); + m_vbox.addChild(&m_rgbSliders); + m_vbox.addChild(&m_hsvSliders); + m_vbox.addChild(&m_bottomBox); + addChild(&m_vbox); // Hide (or show) the "More Options" depending the saved value in .cfg file m_bottomBox.setVisible(get_config_bool("PaletteEditor", "ShowMoreOptions", false)); diff --git a/src/commands/cmd_sprite_properties.cpp b/src/commands/cmd_sprite_properties.cpp index 219f16fe0..52dee9956 100644 --- a/src/commands/cmd_sprite_properties.cpp +++ b/src/commands/cmd_sprite_properties.cpp @@ -121,10 +121,10 @@ void SpritePropertiesCommand::onExecute(Context* context) color_button = new ColorButton(Color::fromIndex(sprite->getTransparentColor()), IMAGE_INDEXED); - jwidget_add_child(box_transparent, color_button); + box_transparent->addChild(color_button); } else { - jwidget_add_child(box_transparent, new Label("(only for indexed images)")); + box_transparent->addChild(new Label("(only for indexed images)")); } } diff --git a/src/commands/filters/cmd_color_curve.cpp b/src/commands/filters/cmd_color_curve.cpp index 8ac15dda1..f498f0ff7 100644 --- a/src/commands/filters/cmd_color_curve.cpp +++ b/src/commands/filters/cmd_color_curve.cpp @@ -60,7 +60,7 @@ public: jwidget_expansive(&m_view, true); jwidget_set_min_size(&m_view, 128, 64); - jwidget_add_child(getContainer(), &m_view); + getContainer()->addChild(&m_view); m_editor.CurveEditorChange.connect(&ColorCurveWindow::onCurveChange, this); } diff --git a/src/commands/filters/cmd_convolution_matrix.cpp b/src/commands/filters/cmd_convolution_matrix.cpp index 149ca9fc6..fa2f0a9b3 100644 --- a/src/commands/filters/cmd_convolution_matrix.cpp +++ b/src/commands/filters/cmd_convolution_matrix.cpp @@ -64,7 +64,7 @@ public: "stock", &m_stockListBox, "reload", &m_reloadButton, NULL); - jwidget_add_child(getContainer(), m_controlsWidget); + getContainer()->addChild(m_controlsWidget); m_reloadButton->Click.connect(&ConvolutionMatrixWindow::onReloadStock, this); // TODO convert listbox to c++ class ListBox @@ -94,7 +94,7 @@ private: // Clean the list JI_LIST_FOR_EACH_SAFE(m_stockListBox->children, link, next) { Widget* listitem = reinterpret_cast(link->data); - jwidget_remove_child(m_stockListBox, listitem); + m_stockListBox->removeChild(listitem); jwidget_free(listitem); } @@ -102,7 +102,7 @@ private: it != end; ++it) { SharedPtr matrix = *it; Widget* listitem = jlistitem_new(matrix->getName()); // TODO convert listitem to a class - jwidget_add_child(m_stockListBox, listitem); + m_stockListBox->addChild(listitem); } selectMatrixByName(oldSelected); diff --git a/src/commands/filters/cmd_despeckle.cpp b/src/commands/filters/cmd_despeckle.cpp index 03738a3df..8bc725f30 100644 --- a/src/commands/filters/cmd_despeckle.cpp +++ b/src/commands/filters/cmd_despeckle.cpp @@ -57,7 +57,7 @@ public: "width", &m_widthEntry, "height", &m_heightEntry, NULL); - jwidget_add_child(getContainer(), m_controlsWidget); + getContainer()->addChild(m_controlsWidget); m_widthEntry->setTextf("%d", m_filter.getWidth()); m_heightEntry->setTextf("%d", m_filter.getHeight()); diff --git a/src/commands/filters/cmd_replace_color.cpp b/src/commands/filters/cmd_replace_color.cpp index 897f9c3b7..7a8d248d9 100644 --- a/src/commands/filters/cmd_replace_color.cpp +++ b/src/commands/filters/cmd_replace_color.cpp @@ -84,7 +84,7 @@ public: "to", &m_toButton, "tolerance", &m_toleranceSlider, NULL); - jwidget_add_child(getContainer(), m_controlsWidget); + getContainer()->addChild(m_controlsWidget); m_fromButton->setColor(m_filter.getFrom()); m_toButton->setColor(m_filter.getTo()); diff --git a/src/commands/filters/filter_target_buttons.cpp b/src/commands/filters/filter_target_buttons.cpp index cba1e4639..c80779e6e 100644 --- a/src/commands/filters/filter_target_buttons.cpp +++ b/src/commands/filters/filter_target_buttons.cpp @@ -40,7 +40,7 @@ FilterTargetButtons::FilterTargetButtons(int imgtype, bool withChannels) #define ADD(box, widget, hook) \ if (widget) { \ jwidget_set_border(widget, 2 * jguiscale()); \ - jwidget_add_child(box, widget); \ + box->addChild(widget); \ widget->Click.connect(Bind(&FilterTargetButtons::hook, this, widget)); \ } @@ -110,7 +110,7 @@ FilterTargetButtons::FilterTargetButtons(int imgtype, bool withChannels) ADD(hbox, a, onChannelChange); if (withChannels) - jwidget_add_child(this, hbox); + addChild(hbox); else jwidget_free(hbox); diff --git a/src/commands/filters/filter_window.cpp b/src/commands/filters/filter_window.cpp index 3df9fcb2f..9be592ab1 100644 --- a/src/commands/filters/filter_window.cpp +++ b/src/commands/filters/filter_window.cpp @@ -52,22 +52,22 @@ FilterWindow::FilterWindow(const char* title, const char* cfgSection, jwidget_expansive(&m_container, true); - jwidget_add_child(&m_hbox, &m_container); - jwidget_add_child(&m_hbox, &m_vbox); + m_hbox.addChild(&m_container); + m_hbox.addChild(&m_vbox); - jwidget_add_child(&m_vbox, &m_okButton); - jwidget_add_child(&m_vbox, &m_cancelButton); - jwidget_add_child(&m_vbox, &m_targetButton); - jwidget_add_child(&m_vbox, &m_showPreview); + m_vbox.addChild(&m_okButton); + m_vbox.addChild(&m_cancelButton); + m_vbox.addChild(&m_targetButton); + m_vbox.addChild(&m_showPreview); - jwidget_add_child(this, &m_preview); - jwidget_add_child(this, &m_hbox); + addChild(&m_preview); + addChild(&m_hbox); if (m_tiledCheck) { m_tiledCheck->setSelected(tiledMode != TILED_NONE); m_tiledCheck->Click.connect(Bind(&FilterWindow::onTiledChange, this)); - jwidget_add_child(&m_vbox, m_tiledCheck); + m_vbox.addChild(m_tiledCheck); } // Load "Preview" check status. diff --git a/src/console.cpp b/src/console.cpp index 14fada03b..7ebcc298f 100644 --- a/src/console.cpp +++ b/src/console.cpp @@ -67,7 +67,7 @@ Console::Console() grid->addChildInCell(view, 1, 1, JI_HORIZONTAL | JI_VERTICAL); grid->addChildInCell(button, 1, 1, JI_CENTER); - jwidget_add_child(window, grid); + window->addChild(grid); view->setVisible(false); jwidget_magnetic(button, true); diff --git a/src/dialogs/aniedit.cpp b/src/dialogs/aniedit.cpp index 3884a966c..de0e1ea61 100644 --- a/src/dialogs/aniedit.cpp +++ b/src/dialogs/aniedit.cpp @@ -182,7 +182,7 @@ void switch_between_animation_and_sprite_editor() AnimationEditor* anieditor = new AnimationEditor(document, sprite); current_anieditor = anieditor; - jwidget_add_child(window, anieditor); + window->addChild(anieditor); window->remap_window(); anieditor->centerCurrentCel(); diff --git a/src/dialogs/drawtext.cpp b/src/dialogs/drawtext.cpp index a35ade43f..618223527 100644 --- a/src/dialogs/drawtext.cpp +++ b/src/dialogs/drawtext.cpp @@ -82,7 +82,7 @@ void dialogs_draw_text(Sprite* sprite) colorbar_get_fg_color(app_get_colorbar())), sprite->imgtype); - jwidget_add_child(color_box, color_but); + color_box->addChild(color_but); /* entries */ usprintf(buf, "%d", get_config_int("DrawText", "Size", 8)); diff --git a/src/dialogs/filesel.cpp b/src/dialogs/filesel.cpp index 3988079c5..0cd9aa1c8 100644 --- a/src/dialogs/filesel.cpp +++ b/src/dialogs/filesel.cpp @@ -195,7 +195,7 @@ base::string ase_file_selector(const base::string& message, view->attachToView(fileview); jwidget_expansive(view, true); - jwidget_add_child(box, view); + box->addChild(view); jwidget_set_min_size(window, JI_SCREEN_W*9/10, JI_SCREEN_H*9/10); window->remap_window(); diff --git a/src/dialogs/maskcol.cpp b/src/dialogs/maskcol.cpp index 184513429..ede13ea65 100644 --- a/src/dialogs/maskcol.cpp +++ b/src/dialogs/maskcol.cpp @@ -107,23 +107,31 @@ void dialogs_mask_color(Document* document) jwidget_expansive(slider_tolerance, true); jwidget_expansive(box2, true); - jwidget_add_child(window, box1); - jwidget_add_children(box1, box2, box3, check_preview, box4, NULL); - jwidget_add_children(box2, label_color, button_color, button_1, button_2, NULL); - jwidget_add_children(box3, label_tolerance, slider_tolerance, NULL); - jwidget_add_children(box4, button_ok, button_cancel, NULL); + window->addChild(box1); + box1->addChild(box2); + box1->addChild(box3); + box1->addChild(check_preview); + box1->addChild(box4); + box2->addChild(label_color); + box2->addChild(button_color); + box2->addChild(button_1); + box2->addChild(button_2); + box3->addChild(label_tolerance); + box3->addChild(slider_tolerance); + box4->addChild(button_ok); + box4->addChild(button_cancel); - /* default position */ + // Default position window->remap_window(); window->center_window(); - /* mask first preview */ + // Mask first preview mask_preview(documentReader); - /* load window configuration */ + // Load window configuration load_window_pos(window, "MaskColor"); - /* open the window */ + // Open the window window->open_window_fg(); if (window->get_killer() == button_ok) { diff --git a/src/dialogs/repo.cpp b/src/dialogs/repo.cpp index c54569dc6..0dd0c551d 100644 --- a/src/dialogs/repo.cpp +++ b/src/dialogs/repo.cpp @@ -75,13 +75,13 @@ void ji_show_repo_dlg(RepoDlg *repo_dlg) } /* hierarchy */ - jwidget_add_child(box2, repo_dlg->button_use); - jwidget_add_child(box2, repo_dlg->button_add); - jwidget_add_child(box2, repo_dlg->button_delete); - jwidget_add_child(box2, button_close); - jwidget_add_child(box1, box2); - jwidget_add_child(box1, view); - jwidget_add_child(window, box1); + box2->addChild(repo_dlg->button_use); + box2->addChild(repo_dlg->button_add); + box2->addChild(repo_dlg->button_delete); + box2->addChild(button_close); + box1->addChild(box2); + box1->addChild(view); + window->addChild(box1); /* default position */ window->remap_window(); @@ -128,7 +128,7 @@ static void kill_listbox(RepoDlg *repo_dlg) JI_LIST_FOR_EACH_SAFE(listbox->children, link, next) { listitem = reinterpret_cast(link->data); - jwidget_remove_child(repo_dlg->listbox, listitem); + repo_dlg->listbox->removeChild(listitem); if (repo_dlg->free_listitem) { repo_dlg->listitem = listitem; @@ -221,7 +221,7 @@ static void delete_command(Button* widget, RepoDlg* repo_dlg) index = jlistbox_get_selected_index(repo_dlg->listbox); /* delete "repo_dlg->listitem" */ - jwidget_remove_child(repo_dlg->listbox, repo_dlg->listitem); + repo_dlg->listbox->removeChild(repo_dlg->listitem); if (repo_dlg->free_listitem) (*repo_dlg->free_listitem) (repo_dlg); diff --git a/src/gui/alert.cpp b/src/gui/alert.cpp index 8f8905bc4..af01a0ee8 100644 --- a/src/gui/alert.cpp +++ b/src/gui/alert.cpp @@ -192,20 +192,20 @@ void Alert::processString(char* buf, std::vector& labels, std::vector children relationship - jwidget_add_child(this, box1); + addChild(box1); - jwidget_add_child(box1, box4); // Filler - jwidget_add_child(box1, box2); // Labels - jwidget_add_child(box1, box5); // Filler - jwidget_add_child(box1, grid); // Buttons + box1->addChild(box4); // Filler + box1->addChild(box2); // Labels + box1->addChild(box5); // Filler + box1->addChild(grid); // Buttons grid->addChildInCell(box3, 1, 1, JI_CENTER | JI_BOTTOM); for (std::vector::iterator it = labels.begin(); it != labels.end(); ++it) - jwidget_add_child(box2, *it); + box2->addChild(*it); for (std::vector::iterator it = buttons.begin(); it != buttons.end(); ++it) - jwidget_add_child(box3, *it); + box3->addChild(*it); // Default button is the last one if (!buttons.empty()) diff --git a/src/gui/combobox.cpp b/src/gui/combobox.cpp index 0f81b3bad..aea132a3e 100644 --- a/src/gui/combobox.cpp +++ b/src/gui/combobox.cpp @@ -65,8 +65,8 @@ ComboBox::ComboBox() // When the "m_button" is clicked ("Click" signal) call onButtonClick() method m_button->Click.connect(&ComboBox::onButtonClick, this); - jwidget_add_child(this, m_entry); - jwidget_add_child(this, m_button); + addChild(m_entry); + addChild(m_button); setEditable(m_editable); @@ -448,7 +448,7 @@ void ComboBox::openListBox() std::vector::iterator it, end = m_items.end(); for (it = m_items.begin(); it != end; ++it) { Item* item = *it; - jwidget_add_child(m_listbox, jlistitem_new(item->text.c_str())); + m_listbox->addChild(jlistitem_new(item->text.c_str())); } m_window->set_ontop(true); @@ -463,7 +463,7 @@ void ComboBox::openListBox() +(2*jguiscale()+jwidget_get_text_height(m_listbox))*MID(1, size, 16)+ +viewport->border_width.b); - jwidget_add_child(m_window, view); + m_window->addChild(view); view->attachToView(m_listbox); jwidget_signal_off(m_listbox); diff --git a/src/gui/grid.cpp b/src/gui/grid.cpp index 2bafed889..5399f422a 100644 --- a/src/gui/grid.cpp +++ b/src/gui/grid.cpp @@ -85,7 +85,7 @@ void Grid::addChildInCell(Widget* child, int hspan, int vspan, int align) ASSERT(hspan > 0); ASSERT(vspan > 0); - jwidget_add_child(this, child); + addChild(child); if (!putWidgetInCell(child, hspan, vspan, align)) { expandRows(m_rowstrip.size()+1); diff --git a/src/gui/menu.cpp b/src/gui/menu.cpp index c93f53a38..8f3ccdba5 100644 --- a/src/gui/menu.cpp +++ b/src/gui/menu.cpp @@ -242,11 +242,11 @@ void jmenubox_set_menu(Widget* widget, Widget* widget_menu) old_menu = jmenubox_get_menu(widget); if (old_menu) - jwidget_remove_child(widget, old_menu); + widget->removeChild(old_menu); if (widget_menu) { ASSERT_VALID_WIDGET(widget_menu); - jwidget_add_child(widget, widget_menu); + widget->addChild(widget_menu); } } @@ -324,7 +324,7 @@ void jmenu_popup(Widget* menu, int x, int y) // Set children jmenubox_set_menu(menubox, menu); - jwidget_add_child(window, menubox); + window->addChild(menubox); window->remap_window(); @@ -895,7 +895,7 @@ static bool menuitem_msg_proc(Widget* widget, JMessage msg) // Set children jmenubox_set_menu(menubox, menuitem->submenu); - jwidget_add_child(window, menubox); + window->addChild(menubox); window->remap_window(); diff --git a/src/gui/view.cpp b/src/gui/view.cpp index 15576981e..427a8ba06 100644 --- a/src/gui/view.cpp +++ b/src/gui/view.cpp @@ -29,7 +29,7 @@ View::View() m_hasBars = true; jwidget_focusrest(this, true); - jwidget_add_child(this, &m_viewport); + addChild(&m_viewport); setScrollableSize(Size(0, 0)); initTheme(); @@ -42,7 +42,7 @@ bool View::hasScrollBars() void View::attachToView(Widget* viewable_widget) { - jwidget_add_child(&m_viewport, viewable_widget); + m_viewport.addChild(viewable_widget); /* TODO */ /* jwidget_emit_signal(this, JI_SIGNAL_VIEW_ATTACH); */ } @@ -94,43 +94,43 @@ void View::setScrollableSize(const Size& sz) pos = jwidget_get_child_rect(this); - /* setup scroll-bars */ - jwidget_remove_child(this, &m_scrollbar_h); - jwidget_remove_child(this, &m_scrollbar_v); + // Setup scroll-bars + removeChild(&m_scrollbar_h); + removeChild(&m_scrollbar_v); if (m_hasBars) { if (CHECK(w, h, l, t, r, b)) { pos->y2 -= BAR_SIZE; - jwidget_add_child(this, &m_scrollbar_h); + addChild(&m_scrollbar_h); if (CHECK(h, w, t, l, b, r)) { pos->x2 -= BAR_SIZE; if (CHECK(w, h, l, t, r, b)) - jwidget_add_child(this, &m_scrollbar_v); + addChild(&m_scrollbar_v); else { pos->x2 += BAR_SIZE; pos->y2 += BAR_SIZE; - jwidget_remove_child(this, &m_scrollbar_h); + removeChild(&m_scrollbar_h); } } } else if (CHECK(h, w, t, l, b, r)) { pos->x2 -= BAR_SIZE; - jwidget_add_child(this, &m_scrollbar_v); + addChild(&m_scrollbar_v); if (CHECK(w, h, l, t, r, b)) { pos->y2 -= BAR_SIZE; if (CHECK(h, w, t, l, b, r)) - jwidget_add_child(this, &m_scrollbar_h); + addChild(&m_scrollbar_h); else { pos->x2 += BAR_SIZE; pos->y2 += BAR_SIZE; - jwidget_remove_child(this, &m_scrollbar_v); + removeChild(&m_scrollbar_v); } } } - if (this->hasChild(&m_scrollbar_h)) { + if (hasChild(&m_scrollbar_h)) { rect = jrect_new(pos->x1, pos->y2, pos->x1+jrect_w(pos), pos->y2+BAR_SIZE); jwidget_set_rect(&m_scrollbar_h, rect); @@ -141,7 +141,7 @@ void View::setScrollableSize(const Size& sz) else m_scrollbar_h.setVisible(false); - if (this->hasChild(&m_scrollbar_v)) { + if (hasChild(&m_scrollbar_v)) { rect = jrect_new(pos->x2, pos->y1, pos->x2+BAR_SIZE, pos->y1+jrect_h(pos)); jwidget_set_rect(&m_scrollbar_v, rect); @@ -154,7 +154,7 @@ void View::setScrollableSize(const Size& sz) } // Setup viewport - this->invalidate(); + invalidate(); jwidget_set_rect(&m_viewport, pos); setViewScroll(getViewScroll()); // Setup the same scroll-point @@ -188,7 +188,7 @@ void View::setViewScroll(const Point& pt) m_scrollbar_v.setPos(newScroll.y); jwidget_set_rect(&m_viewport, m_viewport.rc); - this->invalidate(); + invalidate(); } void View::updateView() diff --git a/src/gui/widget.cpp b/src/gui/widget.cpp index 2bb8b719e..6e432ca73 100644 --- a/src/gui/widget.cpp +++ b/src/gui/widget.cpp @@ -109,7 +109,7 @@ Widget::~Widget() /* remove from parent */ if (this->parent) - jwidget_remove_child(this->parent, this); + this->parent->removeChild(this); /* remove children */ JI_LIST_FOR_EACH_SAFE(this->children, link, next) @@ -489,67 +489,9 @@ bool Widget::isSelected() const return (this->flags & JI_SELECTED) ? true: false; } -/**********************************************************************/ -/* children handle */ - -void jwidget_add_child(JWidget widget, JWidget child) -{ - ASSERT_VALID_WIDGET(widget); - ASSERT_VALID_WIDGET(child); - - jlist_append(widget->children, child); - child->parent = widget; - - jwidget_emit_signal(widget, JI_SIGNAL_ADD_CHILD); -} - -void jwidget_add_children(JWidget widget, ...) -{ - JWidget child; - va_list ap; - - ASSERT_VALID_WIDGET(widget); - - va_start(ap, widget); - - while ((child=va_arg(ap, JWidget)) != NULL) - jwidget_add_child(widget, child); - - va_end(ap); -} - -void jwidget_remove_child(JWidget widget, JWidget child) -{ - ASSERT_VALID_WIDGET(widget); - ASSERT_VALID_WIDGET(child); - - jlist_remove(widget->children, child); - child->parent = NULL; -} - -void jwidget_replace_child(JWidget widget, JWidget old_child, JWidget new_child) -{ - JLink before; - - ASSERT_VALID_WIDGET(widget); - ASSERT_VALID_WIDGET(old_child); - ASSERT_VALID_WIDGET(new_child); - - before = jlist_find(widget->children, old_child); - if (!before) - return; - before = before->next; - - jwidget_remove_child(widget, old_child); - - jlist_insert_before(widget->children, before, new_child); - new_child->parent = widget; - - jwidget_emit_signal(widget, JI_SIGNAL_ADD_CHILD); -} - -/**********************************************************************/ -/* parents and children */ +// =============================================================== +// PARENTS & CHILDREN +// =============================================================== Widget* Widget::getRoot() { @@ -584,9 +526,6 @@ Widget* Widget::getManager() return ji_get_default_manager(); } -/* returns a list of parents (you must free the list), if "ascendant" - is true the list is build from child to parents, else the list is - from parent to children */ JList Widget::getParents(bool ascendant) { JList list = jlist_new(); @@ -603,7 +542,6 @@ JList Widget::getParents(bool ascendant) return list; } -/* returns a list of children (you must free the list) */ JList Widget::getChildren() { return jlist_copy(this->children); @@ -656,14 +594,50 @@ Widget* Widget::findChild(const char* name) return 0; } -/** - * Returns a widget in the same window that is located "sibling". - */ Widget* Widget::findSibling(const char* name) { return getRoot()->findChild(name); } +void Widget::addChild(Widget* child) +{ + ASSERT_VALID_WIDGET(this); + ASSERT_VALID_WIDGET(child); + + jlist_append(children, child); + child->parent = this; + + jwidget_emit_signal(this, JI_SIGNAL_ADD_CHILD); +} + +void Widget::removeChild(Widget* child) +{ + ASSERT_VALID_WIDGET(this); + ASSERT_VALID_WIDGET(child); + + jlist_remove(children, child); + child->parent = NULL; +} + +void Widget::replaceChild(Widget* oldChild, Widget* newChild) +{ + ASSERT_VALID_WIDGET(oldChild); + ASSERT_VALID_WIDGET(newChild); + + JLink before = jlist_find(children, oldChild); + if (!before) + return; + + before = before->next; + + removeChild(oldChild); + + jlist_insert_before(children, before, newChild); + newChild->parent = this; + + jwidget_emit_signal(this, JI_SIGNAL_ADD_CHILD); +} + // =============================================================== // LAYOUT & CONSTRAINT // =============================================================== diff --git a/src/gui/widget.h b/src/gui/widget.h index 263089243..5ebe7ebbe 100644 --- a/src/gui/widget.h +++ b/src/gui/widget.h @@ -53,14 +53,6 @@ bool jwidget_is_expansive(JWidget widget); bool jwidget_is_decorative(JWidget widget); bool jwidget_is_focusrest(JWidget widget); -/* children handle */ - -void jwidget_add_child(JWidget widget, JWidget child); -void jwidget_add_children(JWidget widget, ...); -void jwidget_remove_child(JWidget widget, JWidget child); -void jwidget_replace_child(JWidget widget, JWidget old_child, - JWidget new_child); - /* position and geometry */ JRect jwidget_get_rect(JWidget widget); @@ -222,11 +214,20 @@ public: Widget* getRoot(); Widget* getParent(); Widget* getManager(); + + // Returns a list of parents (you must free the list), if + // "ascendant" is true the list is build from child to parents, else + // the list is from parent to children. JList getParents(bool ascendant); + + // Returns a list of children (you must free the list). JList getChildren(); + Widget* pick(int x, int y); bool hasChild(Widget* child); Widget* findChild(const char* name); + + // Returns a widget in the same window that is located "sibling". Widget* findSibling(const char* name); // Finds a child with the specified name and dynamic-casts it to @@ -236,6 +237,10 @@ public: return dynamic_cast(findChild(name)); } + void addChild(Widget* child); + void removeChild(Widget* child); + void replaceChild(Widget* oldChild, Widget* newChild); + // =============================================================== // LAYOUT & CONSTRAINT // =============================================================== diff --git a/src/modules/editors.cpp b/src/modules/editors.cpp index ac2e7e1c7..1f472e2dc 100644 --- a/src/modules/editors.cpp +++ b/src/modules/editors.cpp @@ -266,7 +266,7 @@ void split_editor(Editor* editor, int align) Editor* new_editor = create_new_editor(); // Insert the "new_box" in the same location that the view. - jwidget_replace_child(parent_box, view, new_panel); + parent_box->replaceChild(view, new_panel); // Append the new editor. new_view->attachToView(new_editor); @@ -280,8 +280,8 @@ void split_editor(Editor* editor, int align) jwidget_expansive(new_view, true); // Append both views to the "new_panel". - jwidget_add_child(new_panel, view); - jwidget_add_child(new_panel, new_view); + new_panel->addChild(view); + new_panel->addChild(new_view); // Same position. { @@ -318,14 +318,14 @@ void close_editor(Editor* editor) current_editor = 0; // Remove this editor. - jwidget_remove_child(parent_box, view); + parent_box->removeChild(view); jwidget_free(view); // Fixup the parent. other_widget = reinterpret_cast(jlist_first_data(parent_box->children)); - jwidget_remove_child(parent_box, other_widget); - jwidget_replace_child(parent_box->getParent(), parent_box, other_widget); + parent_box->removeChild(other_widget); + parent_box->getParent()->replaceChild(parent_box, other_widget); jwidget_free(parent_box); // Find next editor to select. @@ -359,18 +359,18 @@ void make_unique_editor(Editor* editor) return; // Remove the editor-view of its parent. - jwidget_remove_child(view->getParent(), view); + view->getParent()->removeChild(view); // Remove all children of main_editor_box. JI_LIST_FOR_EACH_SAFE(box_editors->children, link, next) { child = (JWidget)link->data; - jwidget_remove_child(box_editors, child); + box_editors->removeChild(child); delete child; // widget } // Append the editor to main box. - jwidget_add_child(box_editors, view); + box_editors->addChild(view); // New current editor. set_current_editor(editor); diff --git a/src/modules/rootmenu.cpp b/src/modules/rootmenu.cpp index 0f9e7f34e..81b579271 100644 --- a/src/modules/rootmenu.cpp +++ b/src/modules/rootmenu.cpp @@ -271,7 +271,7 @@ static JWidget convert_xmlelem_to_menu(TiXmlElement* elem) while (child) { JWidget menuitem = convert_xmlelem_to_menuitem(child); if (menuitem) - jwidget_add_child(menu, menuitem); + menu->addChild(menuitem); else throw base::Exception("Error converting the element \"%s\" to a menu-item.\n", static_cast(child->Value())); diff --git a/src/skin/skin_theme.cpp b/src/skin/skin_theme.cpp index 0703dd95f..0195864e0 100644 --- a/src/skin/skin_theme.cpp +++ b/src/skin/skin_theme.cpp @@ -623,7 +623,7 @@ void SkinTheme::init_widget(JWidget widget) jwidget_add_hook(button, JI_WIDGET, &SkinTheme::theme_frame_button_msg_proc, NULL); jwidget_decorative(button, true); - jwidget_add_child(widget, button); + widget->addChild(button); button->setName("theme_close_button"); button->Click.connect(Bind(&Frame::closeWindow, (Frame*)widget, button)); } diff --git a/src/widgets/color_bar.cpp b/src/widgets/color_bar.cpp index 4b0acea32..dad25c9e8 100644 --- a/src/widgets/color_bar.cpp +++ b/src/widgets/color_bar.cpp @@ -99,10 +99,10 @@ ColorBar::ColorBar(int align) jwidget_expansive(&m_scrollableView, true); - jwidget_add_child(this, &m_paletteButton); - jwidget_add_child(this, &m_scrollableView); - jwidget_add_child(this, &m_fgColor); - jwidget_add_child(this, &m_bgColor); + addChild(&m_paletteButton); + addChild(&m_scrollableView); + addChild(&m_fgColor); + addChild(&m_bgColor); this->border_width.l = 2*jguiscale(); this->border_width.t = 2*jguiscale(); diff --git a/src/widgets/color_selector.cpp b/src/widgets/color_selector.cpp index 036dedbe5..d0364abae 100644 --- a/src/widgets/color_selector.cpp +++ b/src/widgets/color_selector.cpp @@ -64,27 +64,25 @@ ColorSelector::ColorSelector() setup_mini_look(&m_grayButton); setup_mini_look(&m_maskButton); - jwidget_add_child(&m_topBox, &m_indexButton); - jwidget_add_child(&m_topBox, &m_rgbButton); - jwidget_add_child(&m_topBox, &m_hsvButton); - jwidget_add_child(&m_topBox, &m_grayButton); - jwidget_add_child(&m_topBox, &m_maskButton); - jwidget_add_child(&m_topBox, &m_hexColorEntry); + m_topBox.addChild(&m_indexButton); + m_topBox.addChild(&m_rgbButton); + m_topBox.addChild(&m_hsvButton); + m_topBox.addChild(&m_grayButton); + m_topBox.addChild(&m_maskButton); + m_topBox.addChild(&m_hexColorEntry); { - Box* filler = new Box(JI_HORIZONTAL); Box* miniVbox = new Box(JI_VERTICAL); - jwidget_expansive(filler, true); - jwidget_add_child(&m_topBox, filler); - jwidget_add_child(&m_topBox, miniVbox); - jwidget_add_child(miniVbox, getPin()); + miniVbox->addChild(getPin()); + m_topBox.addChild(new BoxFiller); + m_topBox.addChild(miniVbox); } - jwidget_add_child(&m_vbox, &m_topBox); - jwidget_add_child(&m_vbox, &m_colorPaletteContainer); - jwidget_add_child(&m_vbox, &m_rgbSliders); - jwidget_add_child(&m_vbox, &m_hsvSliders); - jwidget_add_child(&m_vbox, &m_graySlider); - jwidget_add_child(&m_vbox, &m_maskLabel); - jwidget_add_child(this, &m_vbox); + m_vbox.addChild(&m_topBox); + m_vbox.addChild(&m_colorPaletteContainer); + m_vbox.addChild(&m_rgbSliders); + m_vbox.addChild(&m_hsvSliders); + m_vbox.addChild(&m_graySlider); + m_vbox.addChild(&m_maskLabel); + addChild(&m_vbox); m_indexButton.Click.connect(&ColorSelector::onColorTypeButtonClick, this); m_rgbButton.Click.connect(&ColorSelector::onColorTypeButtonClick, this); @@ -106,7 +104,7 @@ ColorSelector::ColorSelector() ColorSelector::~ColorSelector() { - jwidget_remove_child(getPin()->getParent(), getPin()); + getPin()->getParent()->removeChild(getPin()); } void ColorSelector::setColor(const Color& color) diff --git a/src/widgets/color_sliders.cpp b/src/widgets/color_sliders.cpp index 7ea75f610..d834c5661 100644 --- a/src/widgets/color_sliders.cpp +++ b/src/widgets/color_sliders.cpp @@ -94,7 +94,7 @@ ColorSliders::ColorSliders() : Widget(JI_WIDGET) , m_grid(3, false) { - jwidget_add_child(this, &m_grid); + addChild(&m_grid); } ColorSliders::~ColorSliders() diff --git a/src/widgets/groupbut.cpp b/src/widgets/groupbut.cpp index f8d37ef90..58408bf5c 100644 --- a/src/widgets/groupbut.cpp +++ b/src/widgets/groupbut.cpp @@ -80,15 +80,15 @@ JWidget group_button_new(int w, int h, int first_selected, ...) radio->setSelected(true); if (hbox) - jwidget_add_child(hbox, radio); + hbox->addChild(radio); else - jwidget_add_child(vbox, radio); + vbox->addChild(radio); c++; } if (hbox) - jwidget_add_child(vbox, hbox); + vbox->addChild(hbox); } va_end(ap); diff --git a/src/widgets/hex_color_entry.cpp b/src/widgets/hex_color_entry.cpp index e10e64833..796b5530f 100644 --- a/src/widgets/hex_color_entry.cpp +++ b/src/widgets/hex_color_entry.cpp @@ -30,8 +30,8 @@ HexColorEntry::HexColorEntry() , m_label("#") , m_entry(6, "") { - jwidget_add_child(this, &m_label); - jwidget_add_child(this, &m_entry); + addChild(&m_label); + addChild(&m_entry); m_entry.EntryChange.connect(&HexColorEntry::onEntryChange, this); diff --git a/src/widgets/statebar.cpp b/src/widgets/statebar.cpp index 78cd3467e..e0adc7167 100644 --- a/src/widgets/statebar.cpp +++ b/src/widgets/statebar.cpp @@ -124,15 +124,15 @@ StatusBar::StatusBar() jwidget_noborders(box3); jwidget_expansive(box3, true); - jwidget_add_child(box2, m_b_first); - jwidget_add_child(box2, m_b_prev); - jwidget_add_child(box2, m_b_play); - jwidget_add_child(box2, m_b_next); - jwidget_add_child(box2, m_b_last); + box2->addChild(m_b_first); + box2->addChild(m_b_prev); + box2->addChild(m_b_play); + box2->addChild(m_b_next); + box2->addChild(m_b_last); - jwidget_add_child(box1, box3); - jwidget_add_child(box1, box2); - jwidget_add_child(box1, m_slider); + box1->addChild(box3); + box1->addChild(box2); + box1->addChild(m_slider); m_commandsBox = box1; } @@ -146,9 +146,9 @@ StatusBar::StatusBar() m_transparentLabel = new Label("Transparent Color:"); m_transparentColor = new ColorButton(Color::fromMask(), IMAGE_RGB); - jwidget_add_child(m_movePixelsBox, filler); - jwidget_add_child(m_movePixelsBox, m_transparentLabel); - jwidget_add_child(m_movePixelsBox, m_transparentColor); + m_movePixelsBox->addChild(filler); + m_movePixelsBox->addChild(m_transparentLabel); + m_movePixelsBox->addChild(m_transparentColor); m_transparentColor->Change.connect(Bind(&StatusBar::onTransparentColorChange, this)); } @@ -283,16 +283,16 @@ void StatusBar::showTool(int msecs, Tool* tool) void StatusBar::showMovePixelsOptions() { - if (!this->hasChild(m_movePixelsBox)) { - jwidget_add_child(this, m_movePixelsBox); + if (!hasChild(m_movePixelsBox)) { + addChild(m_movePixelsBox); invalidate(); } } void StatusBar::hideMovePixelsOptions() { - if (this->hasChild(m_movePixelsBox)) { - jwidget_remove_child(this, m_movePixelsBox); + if (hasChild(m_movePixelsBox)) { + removeChild(m_movePixelsBox); invalidate(); } } @@ -384,13 +384,13 @@ bool StatusBar::onProcessMessage(JMessage msg) return true; case JM_CLOSE: - if (!this->hasChild(m_commandsBox)) { + if (!hasChild(m_commandsBox)) { // Append the "m_commandsBox" so it is destroyed in StatusBar dtor. - jwidget_add_child(this, m_commandsBox); + addChild(m_commandsBox); } - if (!this->hasChild(m_movePixelsBox)) { + if (!hasChild(m_movePixelsBox)) { // Append the "m_movePixelsBox" so it is destroyed in StatusBar dtor. - jwidget_add_child(this, m_movePixelsBox); + addChild(m_movePixelsBox); } break; @@ -591,7 +591,7 @@ bool StatusBar::onProcessMessage(JMessage msg) updateFromLayer(); - jwidget_add_child(this, m_commandsBox); + addChild(m_commandsBox); invalidate(); } else { @@ -709,7 +709,7 @@ bool StatusBar::onProcessMessage(JMessage msg) // ...exit from command mode jmanager_free_focus(); // TODO Review this code - jwidget_remove_child(this, m_commandsBox); + removeChild(m_commandsBox); invalidate(); } diff --git a/src/widgets/tabs.cpp b/src/widgets/tabs.cpp index c4ec4dd00..e962898a8 100644 --- a/src/widgets/tabs.cpp +++ b/src/widgets/tabs.cpp @@ -530,8 +530,8 @@ void Tabs::setScrollX(int scroll_x) if (max_x > 0) { // Add childs if (!HAS_ARROWS(this)) { - jwidget_add_child(this, m_button_left); - jwidget_add_child(this, m_button_right); + addChild(m_button_left); + addChild(m_button_right); invalidate(); } @@ -555,8 +555,8 @@ void Tabs::setScrollX(int scroll_x) } // Remove buttons else if (HAS_ARROWS(this)) { - jwidget_remove_child(this, m_button_left); - jwidget_remove_child(this, m_button_right); + removeChild(m_button_left); + removeChild(m_button_right); invalidate(); } } diff --git a/src/widgets/toolbar.cpp b/src/widgets/toolbar.cpp index cfc734519..4c5087499 100644 --- a/src/widgets/toolbar.cpp +++ b/src/widgets/toolbar.cpp @@ -407,7 +407,7 @@ void ToolBar::openPopupFrame(int group_index, ToolGroup* tool_group) m_popupFrame->Close.connect(Bind(&ToolBar::onClosePopup, this)); ToolStrip* toolstrip = new ToolStrip(tool_group, this); - jwidget_add_child(m_popupFrame, toolstrip); + m_popupFrame->addChild(toolstrip); Rect rc = getToolGroupBounds(group_index); int w = 0; diff --git a/src/xml_widgets.cpp b/src/xml_widgets.cpp index dea19c3d8..ad149d5c3 100644 --- a/src/xml_widgets.cpp +++ b/src/xml_widgets.cpp @@ -418,7 +418,7 @@ static Widget* convert_xmlelement_to_widget(TiXmlElement* elem, Widget* root) } // Just add the child in any other kind of widget else - jwidget_add_child(widget, child); + widget->addChild(child); } child_elem = child_elem->NextSiblingElement(); }