From a932a7a80169253fb29be8f1bed87f510cefad24 Mon Sep 17 00:00:00 2001 From: mathias Date: Wed, 24 Nov 2004 23:27:28 +0000 Subject: patch from Rob Stevens to add dragndrop-reordering of the tabs --- src/FbWinFrame.cc | 107 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/FbWinFrame.hh | 6 +++ 2 files changed, 113 insertions(+) diff --git a/src/FbWinFrame.cc b/src/FbWinFrame.cc index 06c53f6..7f4b4c8 100644 --- a/src/FbWinFrame.cc +++ b/src/FbWinFrame.cc @@ -357,6 +357,113 @@ void FbWinFrame::moveLabelButtonRight(const FbTk::TextButton &btn) { redrawTitle(); } +void FbWinFrame::moveLabelButtonTo(FbTk::TextButton &btn, int x, int y) { + Window parent_return=0, + root_return=75, + *children_return=NULL; + unsigned int nchildren_return; + //get the root window + if(!XQueryTree(FbTk::App::instance()->display(), window().window(), + &root_return, &parent_return, &children_return, &nchildren_return)) + parent_return=parent_return;//return; + if(children_return!=NULL) + XFree(children_return); + int dest_x=0, dest_y=0; + Window labelbutton=0; + if(!XTranslateCoordinates(FbTk::App::instance()->display(), + root_return, label().window(), + x,y, &dest_x, &dest_y, + &labelbutton)) + return; + LabelList::iterator it = m_labelbuttons.begin(); + LabelList::iterator it_end = m_labelbuttons.end(); + //find the label button to move next to + for(; it!=it_end; it++) { + if( (*it)->window()==labelbutton) + break; + } + //label button not found + if(it==it_end) + return; + Window child_return=0; + //make x and y relative to our labelbutton + if(!XTranslateCoordinates(FbTk::App::instance()->display(), + label().window(),labelbutton, + dest_x,dest_y, &x, &y, + &child_return)) + return; + if(x>(*it)->width()/2) + moveLabelButtonRightOf(btn,**it); + else + moveLabelButtonLeftOf(btn,**it); + +} + + + +void FbWinFrame::moveLabelButtonLeftOf(const FbTk::TextButton &btn, const FbTk::TextButton &dest) { + LabelList::iterator it = find(m_labelbuttons.begin(), + m_labelbuttons.end(), + &btn); + LabelList::iterator new_pos = find(m_labelbuttons.begin(), + m_labelbuttons.end(), + &dest); + + // make sure we found them + if (it == m_labelbuttons.end() || new_pos==m_labelbuttons.end()) + { + cout<<"button to move not found"<