diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/FbWinFrame.cc | 107 | ||||
-rw-r--r-- | src/FbWinFrame.hh | 6 |
2 files changed, 113 insertions, 0 deletions
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) { | |||
357 | redrawTitle(); | 357 | redrawTitle(); |
358 | } | 358 | } |
359 | 359 | ||
360 | void FbWinFrame::moveLabelButtonTo(FbTk::TextButton &btn, int x, int y) { | ||
361 | Window parent_return=0, | ||
362 | root_return=75, | ||
363 | *children_return=NULL; | ||
364 | unsigned int nchildren_return; | ||
365 | //get the root window | ||
366 | if(!XQueryTree(FbTk::App::instance()->display(), window().window(), | ||
367 | &root_return, &parent_return, &children_return, &nchildren_return)) | ||
368 | parent_return=parent_return;//return; | ||
369 | if(children_return!=NULL) | ||
370 | XFree(children_return); | ||
371 | int dest_x=0, dest_y=0; | ||
372 | Window labelbutton=0; | ||
373 | if(!XTranslateCoordinates(FbTk::App::instance()->display(), | ||
374 | root_return, label().window(), | ||
375 | x,y, &dest_x, &dest_y, | ||
376 | &labelbutton)) | ||
377 | return; | ||
378 | LabelList::iterator it = m_labelbuttons.begin(); | ||
379 | LabelList::iterator it_end = m_labelbuttons.end(); | ||
380 | //find the label button to move next to | ||
381 | for(; it!=it_end; it++) { | ||
382 | if( (*it)->window()==labelbutton) | ||
383 | break; | ||
384 | } | ||
385 | //label button not found | ||
386 | if(it==it_end) | ||
387 | return; | ||
388 | Window child_return=0; | ||
389 | //make x and y relative to our labelbutton | ||
390 | if(!XTranslateCoordinates(FbTk::App::instance()->display(), | ||
391 | label().window(),labelbutton, | ||
392 | dest_x,dest_y, &x, &y, | ||
393 | &child_return)) | ||
394 | return; | ||
395 | if(x>(*it)->width()/2) | ||
396 | moveLabelButtonRightOf(btn,**it); | ||
397 | else | ||
398 | moveLabelButtonLeftOf(btn,**it); | ||
399 | |||
400 | } | ||
401 | |||
402 | |||
403 | |||
404 | void FbWinFrame::moveLabelButtonLeftOf(const FbTk::TextButton &btn, const FbTk::TextButton &dest) { | ||
405 | LabelList::iterator it = find(m_labelbuttons.begin(), | ||
406 | m_labelbuttons.end(), | ||
407 | &btn); | ||
408 | LabelList::iterator new_pos = find(m_labelbuttons.begin(), | ||
409 | m_labelbuttons.end(), | ||
410 | &dest); | ||
411 | |||
412 | // make sure we found them | ||
413 | if (it == m_labelbuttons.end() || new_pos==m_labelbuttons.end()) | ||
414 | { | ||
415 | cout<<"button to move not found"<<endl; | ||
416 | return; | ||
417 | } | ||
418 | //moving a button to the left of itself results in no change | ||
419 | if( new_pos == it) | ||
420 | { | ||
421 | cout<<"source and dest button are the same"<<endl; | ||
422 | return; | ||
423 | } | ||
424 | FbTk::TextButton *item = *it; | ||
425 | //remove from list | ||
426 | m_labelbuttons.erase(it); | ||
427 | //insert on the new place | ||
428 | m_labelbuttons.insert(new_pos, item); | ||
429 | //update titlebar | ||
430 | redrawTitle(); | ||
431 | } | ||
432 | |||
433 | void FbWinFrame::moveLabelButtonRightOf(const FbTk::TextButton &btn, const FbTk::TextButton &dest) { | ||
434 | LabelList::iterator it = find(m_labelbuttons.begin(), | ||
435 | m_labelbuttons.end(), | ||
436 | &btn); | ||
437 | LabelList::iterator new_pos = find(m_labelbuttons.begin(), | ||
438 | m_labelbuttons.end(), | ||
439 | &dest); | ||
440 | |||
441 | // make sure we found them | ||
442 | if (it == m_labelbuttons.end() || new_pos==m_labelbuttons.end()) | ||
443 | { | ||
444 | cout<<"button to move not found"<<endl; | ||
445 | return; | ||
446 | } | ||
447 | //moving a button to the right of itself results in no change | ||
448 | if( new_pos == it) | ||
449 | { | ||
450 | cout<<"source and dest button are the same"<<endl; | ||
451 | return; | ||
452 | } | ||
453 | FbTk::TextButton *item = *it; | ||
454 | //remove from list | ||
455 | m_labelbuttons.erase(it); | ||
456 | //need to insert into the next position | ||
457 | new_pos++; | ||
458 | //insert on the new place | ||
459 | if(new_pos == m_labelbuttons.end()) | ||
460 | m_labelbuttons.push_back(item); | ||
461 | else | ||
462 | m_labelbuttons.insert(new_pos, item); | ||
463 | //update titlebar | ||
464 | redrawTitle(); | ||
465 | } | ||
466 | |||
360 | void FbWinFrame::setLabelButtonFocus(FbTk::TextButton &btn) { | 467 | void FbWinFrame::setLabelButtonFocus(FbTk::TextButton &btn) { |
361 | if (&btn == currentLabel()) | 468 | if (&btn == currentLabel()) |
362 | return; | 469 | return; |
diff --git a/src/FbWinFrame.hh b/src/FbWinFrame.hh index 88fe51a..1ff7709 100644 --- a/src/FbWinFrame.hh +++ b/src/FbWinFrame.hh | |||
@@ -105,6 +105,12 @@ public: | |||
105 | void moveLabelButtonLeft(const FbTk::TextButton &btn); | 105 | void moveLabelButtonLeft(const FbTk::TextButton &btn); |
106 | /// move label button to the right | 106 | /// move label button to the right |
107 | void moveLabelButtonRight(const FbTk::TextButton &btn); | 107 | void moveLabelButtonRight(const FbTk::TextButton &btn); |
108 | /// move label button to the given location( x and y are relative to the root window) | ||
109 | void moveLabelButtonTo(FbTk::TextButton &btn, int x, int y); | ||
110 | /// move the first label button to the left of the second | ||
111 | void moveLabelButtonLeftOf(const FbTk::TextButton &btn, const FbTk::TextButton &dest); | ||
112 | //move the first label button to the right of the second | ||
113 | void moveLabelButtonRightOf(const FbTk::TextButton &btn, const FbTk::TextButton &dest); | ||
108 | /// which button is to be rendered focused | 114 | /// which button is to be rendered focused |
109 | void setLabelButtonFocus(FbTk::TextButton &btn); | 115 | void setLabelButtonFocus(FbTk::TextButton &btn); |
110 | /// attach a client window for client area | 116 | /// attach a client window for client area |