Remove jwidget_get_parent/manager/parents/children/pick/has_child functions.

This commit is contained in:
David Capello 2011-01-21 18:54:47 -03:00
parent 74b7442ae4
commit 86e145f0ed
14 changed files with 37 additions and 69 deletions

View File

@ -201,15 +201,14 @@ static bool listbox_msg_proc(JWidget widget, JMessage msg)
JWidget picked;
if (view) {
picked = jwidget_pick(jview_get_viewport(view),
msg->mouse.x, msg->mouse.y);
picked = jview_get_viewport(view)->pick(msg->mouse.x, msg->mouse.y);
}
else {
picked = jwidget_pick(widget, msg->mouse.x, msg->mouse.y);
picked = widget->pick(msg->mouse.x, msg->mouse.y);
}
/* if the picked widget is a child of the list, select it */
if (picked && jwidget_has_child(widget, picked))
if (picked && widget->hasChild(picked))
jlistbox_select_child(widget, picked);
}

View File

@ -716,14 +716,14 @@ void jmanager_set_focus(JWidget widget)
JMessage msg;
if (widget)
widget_parents = jwidget_get_parents(widget, false);
widget_parents = widget->getParents(false);
else
widget_parents = jlist_new();
/* fetch the focus */
if (focus_widget) {
JList focus_parents = jwidget_get_parents(focus_widget, true);
JList focus_parents = focus_widget->getParents(true);
msg = jmessage_new(JM_FOCUSLEAVE);
JI_LIST_FOR_EACH(focus_parents, link) {
@ -786,14 +786,14 @@ void jmanager_set_mouse(JWidget widget)
JMessage msg;
if (widget)
widget_parents = jwidget_get_parents(widget, false);
widget_parents = widget->getParents(false);
else
widget_parents = jlist_new();
/* fetch the mouse */
if (mouse_widget) {
JList mouse_parents = jwidget_get_parents(mouse_widget, true);
JList mouse_parents = mouse_widget->getParents(true);
msg = jmessage_new(JM_MOUSELEAVE);
JI_LIST_FOR_EACH(mouse_parents, link) {
@ -994,7 +994,7 @@ void _jmanager_close_window(JWidget manager, Frame* window, bool redraw_backgrou
JMessage msg;
JRegion reg1;
if (!jwidget_has_child(manager, window))
if (!manager->hasChild(window))
return;
if (redraw_background)

View File

@ -494,8 +494,7 @@ static bool menubox_msg_proc(Widget* widget, JMessage msg)
// the widget
if (msg->type == JM_BUTTONPRESSED
&& MBOX(widget)->base != NULL) {
Widget* picked = jwidget_pick(ji_get_default_manager(),
msg->mouse.x, msg->mouse.y);
Widget* picked = ji_get_default_manager()->pick(msg->mouse.x, msg->mouse.y);
// If one of these conditions are accomplished we have to
// close all menus (back to menu-bar or close the popuped
@ -517,7 +516,7 @@ static bool menubox_msg_proc(Widget* widget, JMessage msg)
}
// Get the widget below the mouse cursor
picked = jwidget_pick(menu, msg->mouse.x, msg->mouse.y);
picked = menu->pick(msg->mouse.x, msg->mouse.y);
if (picked) {
if ((picked->type == JI_MENUITEM) &&
!(picked->flags & JI_DISABLED)) {

View File

@ -146,6 +146,6 @@ void jmessage_broadcast_to_parents(JMessage msg, JWidget widget)
if (widget && widget->type != JI_MANAGER) {
jmessage_add_dest(msg, widget);
jmessage_broadcast_to_parents(msg, jwidget_get_parent(widget));
jmessage_broadcast_to_parents(msg, widget->getParent());
}
}

View File

@ -114,7 +114,7 @@ bool PopupWindow::onProcessMessage(JMessage msg)
/* if the user click outside the window, we have to close the
tooltip window */
if (m_filtering) {
Widget* picked = jwidget_pick(this, msg->mouse.x, msg->mouse.y);
Widget* picked = this->pick(msg->mouse.x, msg->mouse.y);
if (!picked || picked->getRoot() != this) {
this->closeWindow(NULL);
}

View File

@ -234,7 +234,7 @@ bool TipWindow::onProcessMessage(JMessage msg)
/* if the user click outside the window, we have to close the
tooltip window */
if (m_filtering) {
JWidget picked = jwidget_pick(this, msg->mouse.x, msg->mouse.y);
Widget* picked = this->pick(msg->mouse.x, msg->mouse.y);
if (!picked || picked->getRoot() != this) {
this->closeWindow(NULL);
}

View File

@ -172,7 +172,7 @@ void jview_set_size(JWidget widget, int w, int h)
}
}
if (jwidget_has_child(widget, view->scrollbar_h)) {
if (widget->hasChild(view->scrollbar_h)) {
rect = jrect_new(pos->x1, pos->y2,
pos->x1+jrect_w(pos), pos->y2+BAR_SIZE);
jwidget_set_rect(view->scrollbar_h, rect);
@ -183,7 +183,7 @@ void jview_set_size(JWidget widget, int w, int h)
else
view->scrollbar_h->setVisible(false);
if (jwidget_has_child(widget, view->scrollbar_v)) {
if (widget->hasChild(view->scrollbar_v)) {
rect = jrect_new(pos->x2, pos->y1,
pos->x2+BAR_SIZE, pos->y1+jrect_h(pos));
jwidget_set_rect(view->scrollbar_v, rect);
@ -301,8 +301,8 @@ static void view_plain_update(JWidget widget)
viewport_needed_size(view->viewport, &req_w, &req_h);
jview_set_size(widget, req_w, req_h);
if ((jwidget_has_child(widget, view->scrollbar_h)) ||
(jwidget_has_child(widget, view->scrollbar_v))) {
if ((widget->hasChild(view->scrollbar_h)) ||
(widget->hasChild(view->scrollbar_v))) {
viewport_needed_size(view->viewport, &req_w, &req_h);
jview_set_size(widget, req_w, req_h);
}

View File

@ -555,24 +555,6 @@ void jwidget_replace_child(JWidget widget, JWidget old_child, JWidget new_child)
/**********************************************************************/
/* parents and children */
JWidget jwidget_get_parent(JWidget widget)
{ return widget->getParent(); }
JWidget jwidget_get_manager(JWidget widget)
{ return widget->getManager(); }
JList jwidget_get_parents(JWidget widget, bool ascendant)
{ return widget->getParents(ascendant); }
JList jwidget_get_children(JWidget widget)
{ return widget->getChildren(); }
JWidget jwidget_pick(JWidget widget, int x, int y)
{ return widget->pick(x, y); }
bool jwidget_has_child(JWidget widget, JWidget child)
{ return widget->hasChild(child); }
Widget* Widget::getRoot()
{
Widget* widget = this;
@ -755,7 +737,7 @@ JRegion jwidget_get_drawable_region(JWidget widget, int flags)
/* cut the top windows areas */
if (flags & JI_GDR_CUTTOPWINDOWS) {
window = widget->getRoot();
manager = window ? jwidget_get_manager(window): NULL;
manager = window ? window->getManager(): NULL;
while (manager) {
windows_list = manager->children;

View File

@ -65,15 +65,6 @@ void jwidget_remove_child(JWidget widget, JWidget child);
void jwidget_replace_child(JWidget widget, JWidget old_child,
JWidget new_child);
/* parents and children */
JWidget jwidget_get_parent(JWidget widget);
JWidget jwidget_get_manager(JWidget widget);
JList jwidget_get_parents(JWidget widget, bool ascendant);
JList jwidget_get_children(JWidget widget);
JWidget jwidget_pick(JWidget widget, int x, int y);
bool jwidget_has_child(JWidget widget, JWidget child);
/* position and geometry */
void jwidget_relayout(JWidget widget);

View File

@ -48,7 +48,7 @@ static EditorList editors;
static int is_sprite_in_some_editor(Sprite *sprite);
static Sprite *get_more_reliable_sprite();
static JWidget find_next_editor(JWidget widget);
static int count_parents(JWidget widget);
static int count_parents(Widget* widget);
int init_module_editors()
{
@ -260,7 +260,7 @@ void split_editor(Editor* editor, int align)
}
JWidget view = jwidget_get_view(editor);
JWidget parent_box = jwidget_get_parent(view); /* box or panel */
JWidget parent_box = view->getParent(); // box or panel
/* create a new box to contain both editors, and a new view to put
the new editor */
@ -313,7 +313,7 @@ void split_editor(Editor* editor, int align)
void close_editor(Editor* editor)
{
JWidget view = jwidget_get_view(editor);
JWidget parent_box = jwidget_get_parent(view); /* box or panel */
JWidget parent_box = view->getParent(); // Box or panel
JWidget other_widget;
/* you can't remove all editors */
@ -332,8 +332,7 @@ void close_editor(Editor* editor)
other_widget = reinterpret_cast<JWidget>(jlist_first_data(parent_box->children));
jwidget_remove_child(parent_box, other_widget);
jwidget_replace_child(jwidget_get_parent(parent_box),
parent_box, other_widget);
jwidget_replace_child(parent_box->getParent(), parent_box, other_widget);
jwidget_free(parent_box);
/* find next editor to select */
@ -367,7 +366,7 @@ void make_unique_editor(Editor* editor)
return;
/* remove the editor-view of its parent */
jwidget_remove_child(jwidget_get_parent(view), view);
jwidget_remove_child(view->getParent(), view);
/* remove all children of main_editor_box */
JI_LIST_FOR_EACH_SAFE(box_editors->children, link, next) {
@ -436,10 +435,10 @@ static JWidget find_next_editor(JWidget widget)
return editor;
}
static int count_parents(JWidget widget)
static int count_parents(Widget* widget)
{
int count = 0;
while ((widget = jwidget_get_parent(widget)))
while ((widget = widget->getParent()))
count++;
return count;
}

View File

@ -338,7 +338,7 @@ static JWidget convert_xmlelem_to_menuitem(TiXmlElement* elem)
static void apply_shortcut_to_menuitems_with_command(JWidget menu, Command *command, Params* params, JAccel accel)
{
JList children = jwidget_get_children(menu);
JList children = menu->getChildren();
JWidget menuitem, submenu;
JLink link;

View File

@ -99,9 +99,7 @@ bool ColorButton::onProcessMessage(JMessage msg)
case JM_MOTION:
if (this->hasCapture()) {
JWidget picked = jwidget_pick(ji_get_default_manager(),
msg->mouse.x,
msg->mouse.y);
Widget* picked = ji_get_default_manager()->pick(msg->mouse.x, msg->mouse.y);
Color color = this->m_color;
if (picked && picked != this) {
@ -232,7 +230,7 @@ void ColorButton::openSelectorDialog()
window->position_window(x, y);
jmanager_dispatch_messages(jwidget_get_manager(window));
jmanager_dispatch_messages(window->getManager());
jwidget_relayout(window);
/* setup the hot-region */

View File

@ -283,7 +283,7 @@ void StatusBar::showTool(int msecs, Tool* tool)
void StatusBar::showMovePixelsOptions()
{
if (!jwidget_has_child(this, m_movePixelsBox)) {
if (!this->hasChild(m_movePixelsBox)) {
jwidget_add_child(this, m_movePixelsBox);
jwidget_dirty(this);
}
@ -291,7 +291,7 @@ void StatusBar::showMovePixelsOptions()
void StatusBar::hideMovePixelsOptions()
{
if (jwidget_has_child(this, m_movePixelsBox)) {
if (this->hasChild(m_movePixelsBox)) {
jwidget_remove_child(this, m_movePixelsBox);
jwidget_dirty(this);
}
@ -381,11 +381,11 @@ bool StatusBar::onProcessMessage(JMessage msg)
return true;
case JM_CLOSE:
if (!jwidget_has_child(this, m_commandsBox)) {
if (!this->hasChild(m_commandsBox)) {
// Append the "m_commandsBox" so it is destroyed in StatusBar dtor.
jwidget_add_child(this, m_commandsBox);
}
if (!jwidget_has_child(this, m_movePixelsBox)) {
if (!this->hasChild(m_movePixelsBox)) {
// Append the "m_movePixelsBox" so it is destroyed in StatusBar dtor.
jwidget_add_child(this, m_movePixelsBox);
}
@ -577,8 +577,8 @@ bool StatusBar::onProcessMessage(JMessage msg)
case JM_MOUSEENTER: {
bool state = (UIContext::instance()->getCurrentSprite() != NULL);
if (!jwidget_has_child(this, m_movePixelsBox)) {
if (!jwidget_has_child(this, m_commandsBox) && state) {
if (!this->hasChild(m_movePixelsBox)) {
if (!this->hasChild(m_commandsBox) && state) {
m_b_first->setEnabled(state);
m_b_prev->setEnabled(state);
m_b_play->setEnabled(state);
@ -696,7 +696,7 @@ bool StatusBar::onProcessMessage(JMessage msg)
break;
case JM_MOUSELEAVE:
if (jwidget_has_child(this, m_commandsBox)) {
if (this->hasChild(m_commandsBox)) {
// If we want restore the state-bar and the slider doesn't have
// the capture...
if (jmanager_get_capture() != m_slider) {

View File

@ -35,7 +35,7 @@
#define ANI_REMOVING_TAB_TICKS 10
#define ANI_SMOOTH_SCROLL_TICKS 20
#define HAS_ARROWS(tabs) ((jwidget_get_parent(m_button_left) == (tabs)))
#define HAS_ARROWS(tabs) ((m_button_left->getParent() == (tabs)))
static bool tabs_button_msg_proc(JWidget widget, JMessage msg);
@ -632,7 +632,7 @@ static bool tabs_button_msg_proc(JWidget widget, JMessage msg)
JWidget parent;
Tabs* tabs = NULL;
parent = jwidget_get_parent(widget);
parent = widget->getParent();
if (parent)
tabs = dynamic_cast<Tabs*>(parent);