code cleaning

This commit is contained in:
fluxgen 2005-05-03 09:25:46 +00:00
parent 86ee497b55
commit bc3b377efb

View file

@ -407,118 +407,117 @@ void FbWinFrame::moveLabelButtonRight(const FbTk::TextButton &btn) {
} }
void FbWinFrame::moveLabelButtonTo(FbTk::TextButton &btn, int x, int y) { void FbWinFrame::moveLabelButtonTo(FbTk::TextButton &btn, int x, int y) {
Window parent_return=0, Window parent_return=0,
root_return=75, root_return=75,
*children_return=NULL; *children_return = NULL;
unsigned int nchildren_return;
//get the root window unsigned int nchildren_return;
if(!XQueryTree(FbTk::App::instance()->display(), window().window(),
&root_return, &parent_return, &children_return, &nchildren_return)) // get the root window
parent_return=parent_return;//return; if (!XQueryTree(window().display(), window().window(),
if(children_return!=NULL) &root_return, &parent_return, &children_return, &nchildren_return))
XFree(children_return); parent_return = parent_return;
int dest_x=0, dest_y=0;
Window labelbutton=0; if (children_return != NULL)
if(!XTranslateCoordinates(FbTk::App::instance()->display(), XFree(children_return);
root_return, label().window(),
x,y, &dest_x, &dest_y, int dest_x = 0, dest_y = 0;
&labelbutton)) Window labelbutton = 0;
return; if (!XTranslateCoordinates(window().display(),
LabelList::iterator it = m_labelbuttons.begin(); root_return, label().window(),
LabelList::iterator it_end = m_labelbuttons.end(); x, y, &dest_x, &dest_y,
//find the label button to move next to &labelbutton))
for(; it!=it_end; it++) { return;
if( (*it)->window()==labelbutton)
break; LabelList::iterator it = find_if(m_labelbuttons.begin(),
} m_labelbuttons.end(),
//label button not found CompareWindow(&FbTk::Button::window,
if(it==it_end) labelbutton));
return; // label button not found
Window child_return=0; if (it == m_labelbuttons.end())
//make x and y relative to our labelbutton return;
if(!XTranslateCoordinates(FbTk::App::instance()->display(),
label().window(),labelbutton, Window child_return = 0;
dest_x,dest_y, &x, &y, //make x and y relative to our labelbutton
&child_return)) if (!XTranslateCoordinates(window().display(),
return; label().window(),labelbutton,
if(x>(*it)->width()/2) dest_x, dest_y, &x, &y,
moveLabelButtonRightOf(btn,**it); &child_return))
else return;
moveLabelButtonLeftOf(btn,**it);
if (x > (*it)->width() / 2)
moveLabelButtonRightOf(btn,**it);
else
moveLabelButtonLeftOf(btn,**it);
} }
void FbWinFrame::moveLabelButtonLeftOf(const FbTk::TextButton &btn, const FbTk::TextButton &dest) { 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()) {
return;
}
//moving a button to the left of itself results in no change
if( new_pos == it) {
return;
}
FbTk::TextButton *item = *it;
//remove from list
m_labelbuttons.erase(it);
//insert on the new place
m_labelbuttons.insert(new_pos, item);
//update titlebar
redrawTitlebar();
}
void FbWinFrame::moveLabelButtonRightOf(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()){
return;
}
//moving a button to the right of itself results in no change
if( new_pos == it){
return;
}
FbTk::TextButton *item = *it;
//remove from list
m_labelbuttons.erase(it);
//need to insert into the next position
new_pos++;
//insert on the new place
if(new_pos == m_labelbuttons.end())
m_labelbuttons.push_back(item);
else
m_labelbuttons.insert(new_pos, item);
//update titlebar
redrawTitlebar();
}
void FbWinFrame::setLabelButtonFocus(FbTk::TextButton &btn) {
if (&btn == currentLabel())
return;
LabelList::iterator it = find(m_labelbuttons.begin(), LabelList::iterator it = find(m_labelbuttons.begin(),
m_labelbuttons.end(), m_labelbuttons.end(),
&btn); &btn);
if (it == m_labelbuttons.end()) 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())
return;
// moving a button to the left of itself results in no change
if (new_pos == it)
return;
FbTk::TextButton *item = *it;
// remove from list
m_labelbuttons.erase(it);
// insert on the new place
m_labelbuttons.insert(new_pos, item);
// update titlebar
redrawTitlebar();
}
void FbWinFrame::moveLabelButtonRightOf(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())
return;
//moving a button to the right of itself results in no change
if (new_pos == it)
return;
FbTk::TextButton *item = *it;
// remove from list
m_labelbuttons.erase(it);
// need to insert into the next position
new_pos++;
// insert on the new place
if (new_pos == m_labelbuttons.end())
m_labelbuttons.push_back(item);
else
m_labelbuttons.insert(new_pos, item);
//update titlebar
redrawTitlebar();
}
void FbWinFrame::setLabelButtonFocus(FbTk::TextButton &btn) {
if (&btn == currentLabel() || btn.parent() != &label())
return; return;
// render label buttons // render label buttons
if (currentLabel() != 0) if (currentLabel() != 0)
applyUnfocusLabel(*m_current_label); applyUnfocusLabel(*m_current_label);
m_current_label = *it; // current focused button m_current_label = &btn; // current focused button
if (m_focused) if (m_focused)
applyFocusLabel(*m_current_label); applyFocusLabel(*m_current_label);
@ -528,11 +527,9 @@ void FbWinFrame::setLabelButtonFocus(FbTk::TextButton &btn) {
void FbWinFrame::setClientWindow(FbTk::FbWindow &win) { void FbWinFrame::setClientWindow(FbTk::FbWindow &win) {
Display *display = FbTk::App::instance()->display();
win.setBorderWidth(0); win.setBorderWidth(0);
XChangeSaveSet(display, win.window(), SetModeInsert); XChangeSaveSet(win.display(), win.window(), SetModeInsert);
m_window.setEventMask(NoEventMask); m_window.setEventMask(NoEventMask);
@ -546,14 +543,14 @@ void FbWinFrame::setClientWindow(FbTk::FbWindow &win) {
m_window.setEventMask(ButtonPressMask | ButtonReleaseMask | m_window.setEventMask(ButtonPressMask | ButtonReleaseMask |
ButtonMotionMask | EnterWindowMask | SubstructureRedirectMask); ButtonMotionMask | EnterWindowMask | SubstructureRedirectMask);
XFlush(display); XFlush(win.display());
XSetWindowAttributes attrib_set; XSetWindowAttributes attrib_set;
attrib_set.event_mask = PropertyChangeMask | StructureNotifyMask | FocusChangeMask; attrib_set.event_mask = PropertyChangeMask | StructureNotifyMask | FocusChangeMask;
attrib_set.do_not_propagate_mask = ButtonPressMask | ButtonReleaseMask | attrib_set.do_not_propagate_mask = ButtonPressMask | ButtonReleaseMask |
ButtonMotionMask; ButtonMotionMask;
XChangeWindowAttributes(display, win.window(), CWEventMask|CWDontPropagate, &attrib_set); XChangeWindowAttributes(win.display(), win.window(), CWEventMask|CWDontPropagate, &attrib_set);
m_clientarea.raise(); m_clientarea.raise();
win.raise(); win.raise();