added numObjects
This commit is contained in:
parent
511dca32f8
commit
ae9d3d84c9
2 changed files with 53 additions and 53 deletions
103
src/Tab.cc
103
src/Tab.cc
|
@ -13,18 +13,18 @@
|
||||||
//
|
//
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||||
// DEALINGS IN THE SOFTWARE.
|
// DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
// $Id: Tab.cc,v 1.19 2002/02/02 18:20:44 pekdon Exp $
|
// $Id: Tab.cc,v 1.20 2002/02/04 06:50:48 fluxgen Exp $
|
||||||
|
|
||||||
#include "Tab.hh"
|
#include "Tab.hh"
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
# include "../config.h"
|
# include "../config.h"
|
||||||
#endif // HAVE_CONFIG_H
|
#endif // HAVE_CONFIG_H
|
||||||
|
|
||||||
#include "i18n.hh"
|
#include "i18n.hh"
|
||||||
|
@ -92,7 +92,7 @@ Tab::~Tab() {
|
||||||
//-------------------------------------------------
|
//-------------------------------------------------
|
||||||
void Tab::createTabWindow() {
|
void Tab::createTabWindow() {
|
||||||
unsigned long attrib_mask = CWBackPixmap | CWBackPixel | CWBorderPixel |
|
unsigned long attrib_mask = CWBackPixmap | CWBackPixel | CWBorderPixel |
|
||||||
CWColormap | CWOverrideRedirect | CWEventMask;
|
CWColormap | CWOverrideRedirect | CWEventMask;
|
||||||
XSetWindowAttributes attrib;
|
XSetWindowAttributes attrib;
|
||||||
attrib.background_pixmap = None;
|
attrib.background_pixmap = None;
|
||||||
attrib.background_pixel = attrib.border_pixel =
|
attrib.background_pixel = attrib.border_pixel =
|
||||||
|
@ -152,11 +152,10 @@ void Tab::focus() {
|
||||||
//-----------------------------------------
|
//-----------------------------------------
|
||||||
void Tab::raise() {
|
void Tab::raise() {
|
||||||
//get first tab
|
//get first tab
|
||||||
Tab *first = 0;
|
Tab *tab = 0;
|
||||||
first = getFirst(this);
|
|
||||||
//raise tabs
|
//raise tabs
|
||||||
for (; first!=0; first = first->m_next)
|
for (tab = getFirst(this); tab!=0; tab = tab->m_next)
|
||||||
m_win->getScreen()->raiseWindows(&first->m_tabwin, 1);
|
m_win->getScreen()->raiseWindows(&tab->m_tabwin, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
//-------------- lower --------------------
|
//-------------- lower --------------------
|
||||||
|
@ -165,9 +164,9 @@ void Tab::raise() {
|
||||||
//-----------------------------------------
|
//-----------------------------------------
|
||||||
void Tab::lower() {
|
void Tab::lower() {
|
||||||
Tab *current = this;
|
Tab *current = this;
|
||||||
FluxboxWindow *win = 0; //convinence
|
FluxboxWindow *win = 0; //convenience
|
||||||
//this have to be done in the correct order, otherwise we'll switch the window
|
//this have to be done in the correct order, otherwise we'll switch the window
|
||||||
//beeing ontop in the group
|
//being ontop in the group
|
||||||
do {
|
do {
|
||||||
XLowerWindow(m_display, current->m_tabwin); //lower tabwin and tabs window
|
XLowerWindow(m_display, current->m_tabwin); //lower tabwin and tabs window
|
||||||
win = current->getWindow();
|
win = current->getWindow();
|
||||||
|
@ -191,42 +190,43 @@ void Tab::loadTheme() {
|
||||||
Pixmap tmp = m_focus_pm;
|
Pixmap tmp = m_focus_pm;
|
||||||
BTexture *texture = &(m_win->getScreen()->getWindowStyle()->tab.l_focus);
|
BTexture *texture = &(m_win->getScreen()->getWindowStyle()->tab.l_focus);
|
||||||
|
|
||||||
if (texture->getTexture() & BImage::PARENTRELATIVE ) {
|
if (texture->getTexture() & BImage::PARENTRELATIVE ) {
|
||||||
BTexture *pt = &(m_win->getScreen()->getWindowStyle()->tab.t_focus);
|
BTexture *pt = &(m_win->getScreen()->getWindowStyle()->tab.t_focus);
|
||||||
if (pt->getTexture() == (BImage::FLAT | BImage::SOLID)) {
|
if (pt->getTexture() == (BImage::FLAT | BImage::SOLID)) {
|
||||||
m_focus_pm = None;
|
m_focus_pm = None;
|
||||||
m_focus_pixel = pt->getColor()->getPixel();
|
m_focus_pixel = pt->getColor()->getPixel();
|
||||||
} else
|
} else
|
||||||
m_focus_pm =
|
m_focus_pm =
|
||||||
image_ctrl->renderImage(m_size_w, m_size_h, pt);
|
image_ctrl->renderImage(m_size_w, m_size_h, pt);
|
||||||
if (tmp) image_ctrl->removeImage(tmp);
|
|
||||||
|
if (tmp) image_ctrl->removeImage(tmp);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if (texture->getTexture() == (BImage::FLAT | BImage::SOLID)) {
|
if (texture->getTexture() == (BImage::FLAT | BImage::SOLID)) {
|
||||||
m_focus_pm = None;
|
m_focus_pm = None;
|
||||||
m_focus_pixel = texture->getColor()->getPixel();
|
m_focus_pixel = texture->getColor()->getPixel();
|
||||||
} else
|
} else
|
||||||
m_focus_pm =
|
m_focus_pm =
|
||||||
image_ctrl->renderImage(m_size_w, m_size_h, texture);
|
image_ctrl->renderImage(m_size_w, m_size_h, texture);
|
||||||
if (tmp) image_ctrl->removeImage(tmp);
|
if (tmp) image_ctrl->removeImage(tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
tmp = m_unfocus_pm;
|
tmp = m_unfocus_pm;
|
||||||
texture = &(m_win->getScreen()->getWindowStyle()->tab.l_unfocus);
|
texture = &(m_win->getScreen()->getWindowStyle()->tab.l_unfocus);
|
||||||
|
|
||||||
if (texture->getTexture() & BImage::PARENTRELATIVE ) {
|
if (texture->getTexture() & BImage::PARENTRELATIVE ) {
|
||||||
BTexture *pt = &(m_win->getScreen()->getWindowStyle()->tab.t_unfocus);
|
BTexture *pt = &(m_win->getScreen()->getWindowStyle()->tab.t_unfocus);
|
||||||
if (pt->getTexture() == (BImage::FLAT | BImage::SOLID)) {
|
if (pt->getTexture() == (BImage::FLAT | BImage::SOLID)) {
|
||||||
m_unfocus_pm = None;
|
m_unfocus_pm = None;
|
||||||
m_unfocus_pixel = pt->getColor()->getPixel();
|
m_unfocus_pixel = pt->getColor()->getPixel();
|
||||||
} else
|
} else
|
||||||
m_unfocus_pm =
|
m_unfocus_pm =
|
||||||
image_ctrl->renderImage(m_size_w, m_size_h, pt);
|
image_ctrl->renderImage(m_size_w, m_size_h, pt);
|
||||||
} else {
|
} else {
|
||||||
if (texture->getTexture() == (BImage::FLAT | BImage::SOLID)) {
|
if (texture->getTexture() == (BImage::FLAT | BImage::SOLID)) {
|
||||||
m_unfocus_pm = None;
|
m_unfocus_pm = None;
|
||||||
m_unfocus_pixel = texture->getColor()->getPixel();
|
m_unfocus_pixel = texture->getColor()->getPixel();
|
||||||
} else
|
} else
|
||||||
m_unfocus_pm =
|
m_unfocus_pm =
|
||||||
image_ctrl->renderImage(m_size_w, m_size_h, texture);
|
image_ctrl->renderImage(m_size_w, m_size_h, texture);
|
||||||
}
|
}
|
||||||
|
@ -279,14 +279,14 @@ void Tab::stick() {
|
||||||
|
|
||||||
//now do stick for all windows in the list
|
//now do stick for all windows in the list
|
||||||
for (tab = getFirst(this); tab != 0; tab = tab->m_next) {
|
for (tab = getFirst(this); tab != 0; tab = tab->m_next) {
|
||||||
FluxboxWindow *win = tab->m_win; //just for convenient
|
FluxboxWindow *win = tab->m_win; //just for convenience
|
||||||
if (win->isStuck()) {
|
if (win->isStuck()) {
|
||||||
win->blackbox_attrib.flags ^= BaseDisplay::ATTRIB_OMNIPRESENT;
|
win->blackbox_attrib.flags ^= BaseDisplay::ATTRIB_OMNIPRESENT;
|
||||||
win->blackbox_attrib.attrib ^= BaseDisplay::ATTRIB_OMNIPRESENT;
|
win->blackbox_attrib.attrib ^= BaseDisplay::ATTRIB_OMNIPRESENT;
|
||||||
win->stuck = false;
|
win->stuck = false;
|
||||||
if (!win->isIconic())
|
if (!win->isIconic())
|
||||||
win->getScreen()->reassociateWindow(win, -1, true);
|
win->getScreen()->reassociateWindow(win, -1, true);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
win->stuck = true;
|
win->stuck = true;
|
||||||
win->blackbox_attrib.flags |= BaseDisplay::ATTRIB_OMNIPRESENT;
|
win->blackbox_attrib.flags |= BaseDisplay::ATTRIB_OMNIPRESENT;
|
||||||
|
@ -351,7 +351,7 @@ void Tab::draw(bool pressed) {
|
||||||
unsigned int tabtext_w;
|
unsigned int tabtext_w;
|
||||||
|
|
||||||
GC gc = ((m_win->isFocused()) ? m_win->getScreen()->getWindowStyle()->tab.l_text_focus_gc :
|
GC gc = ((m_win->isFocused()) ? m_win->getScreen()->getWindowStyle()->tab.l_text_focus_gc :
|
||||||
m_win->getScreen()->getWindowStyle()->tab.l_text_unfocus_gc);
|
m_win->getScreen()->getWindowStyle()->tab.l_text_unfocus_gc);
|
||||||
|
|
||||||
// Different routines for drawing rotated text
|
// Different routines for drawing rotated text
|
||||||
if ((m_win->getScreen()->getTabPlacement() == PLEFT ||
|
if ((m_win->getScreen()->getTabPlacement() == PLEFT ||
|
||||||
|
@ -543,7 +543,7 @@ void Tab::calcIncrease(void) {
|
||||||
|
|
||||||
Tab *tab;
|
Tab *tab;
|
||||||
int inc_x = 0, inc_y = 0;
|
int inc_x = 0, inc_y = 0;
|
||||||
unsigned int tabs = 0, i = 0;
|
unsigned int i = 0, tabs = numObjects();
|
||||||
|
|
||||||
if (m_win->getScreen()->getTabPlacement() == PTOP ||
|
if (m_win->getScreen()->getTabPlacement() == PTOP ||
|
||||||
m_win->getScreen()->getTabPlacement() == PBOTTOM ||
|
m_win->getScreen()->getTabPlacement() == PBOTTOM ||
|
||||||
|
@ -588,9 +588,7 @@ void Tab::calcIncrease(void) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (tab = getFirst(this); tab!=0; tab = tab->m_next, tabs++);
|
for (tab = getFirst(this); tab!=0; tab = tab->m_next, i++) {
|
||||||
|
|
||||||
for (tab = getFirst(this); tab!=0; tab = tab->m_next, i++){
|
|
||||||
|
|
||||||
//TODO: move this out from here?
|
//TODO: move this out from here?
|
||||||
if ((m_win->getScreen()->getTabPlacement() == PTOP ||
|
if ((m_win->getScreen()->getTabPlacement() == PTOP ||
|
||||||
|
@ -672,7 +670,7 @@ void Tab::buttonReleaseEvent(XButtonEvent *be) {
|
||||||
m_win->getScreen()->getRootWindow(),
|
m_win->getScreen()->getRootWindow(),
|
||||||
be->x_root, be->y_root, &dest_x, &dest_y, &child)) {
|
be->x_root, be->y_root, &dest_x, &dest_y, &child)) {
|
||||||
|
|
||||||
Tab *tab = Fluxbox::instance()->searchTab(child);
|
Tab *tab = Fluxbox::instance()->searchTab(child);
|
||||||
FluxboxWindow *win = Fluxbox::instance()->searchWindow(child);
|
FluxboxWindow *win = Fluxbox::instance()->searchWindow(child);
|
||||||
//search tablist for a tabwindow
|
//search tablist for a tabwindow
|
||||||
if ( (tab!=0) || (m_win->getScreen()->isSloppyWindowGrouping() &&
|
if ( (tab!=0) || (m_win->getScreen()->isSloppyWindowGrouping() &&
|
||||||
|
@ -1067,16 +1065,23 @@ unsigned int Tab::calcRelativeWidth() {
|
||||||
return ((m_win->getWidth() + m_win->getScreen()->getBorderWidth2x())/num);
|
return ((m_win->getWidth() + m_win->getScreen()->getBorderWidth2x())/num);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------- numObjects -------------------
|
||||||
|
// Returns the number of objects in
|
||||||
|
// the TabGroup.
|
||||||
|
//-----------------------------------------------
|
||||||
|
unsigned int Tab::numObjects() {
|
||||||
|
unsigned int num = 0;
|
||||||
|
for (Tab *tab = getFirst(this); tab != 0; tab = tab->m_next, num++);
|
||||||
|
return num;
|
||||||
|
}
|
||||||
|
|
||||||
//------------- calcRelativeHeight -------
|
//------------- calcRelativeHeight -------
|
||||||
// Returns: Calculated height for relative
|
// Returns: Calculated height for relative
|
||||||
// alignment
|
// alignment
|
||||||
//----------------------------------------
|
//----------------------------------------
|
||||||
unsigned int Tab::calcRelativeHeight() {
|
unsigned int Tab::calcRelativeHeight() {
|
||||||
unsigned int num=0;
|
return ((m_win->getHeight() +
|
||||||
//calculate num objs in list (extract this to a function?)
|
m_win->getScreen()->getBorderWidth2x())/numObjects());
|
||||||
for (Tab *first=getFirst(this); first!=0; first=first->m_next, num++);
|
|
||||||
|
|
||||||
return ((m_win->getHeight() + m_win->getScreen()->getBorderWidth2x())/num);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------- calcCenterXPos -----------
|
//------------- calcCenterXPos -----------
|
||||||
|
@ -1084,11 +1089,8 @@ unsigned int Tab::calcRelativeHeight() {
|
||||||
// centered alignment
|
// centered alignment
|
||||||
//----------------------------------------
|
//----------------------------------------
|
||||||
unsigned int Tab::calcCenterXPos() {
|
unsigned int Tab::calcCenterXPos() {
|
||||||
unsigned int num=0;
|
return (m_win->getXFrame() + ((m_win->getWidth() -
|
||||||
//calculate num objs in list (extract this to a function?)
|
(m_size_w * numObjects())) / 2));
|
||||||
for (Tab *first=getFirst(this); first!=0; first=first->m_next, num++);
|
|
||||||
|
|
||||||
return (m_win->getXFrame() + ((m_win->getWidth() - (m_size_w * num)) / 2));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------- calcCenterYPos -----------
|
//------------- calcCenterYPos -----------
|
||||||
|
@ -1096,11 +1098,8 @@ unsigned int Tab::calcCenterXPos() {
|
||||||
// centered alignment
|
// centered alignment
|
||||||
//----------------------------------------
|
//----------------------------------------
|
||||||
unsigned int Tab::calcCenterYPos() {
|
unsigned int Tab::calcCenterYPos() {
|
||||||
unsigned int num=0;
|
return (m_win->getYFrame() + ((m_win->getHeight() -
|
||||||
//calculate num objs in list (extract this to a function?)
|
(m_size_h * numObjects())) / 2));
|
||||||
for (Tab *first=getFirst(this); first!=0; first=first->m_next, num++);
|
|
||||||
|
|
||||||
return (m_win->getYFrame() + ((m_win->getHeight() - (m_size_h * num)) / 2));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||||
// DEALINGS IN THE SOFTWARE.
|
// DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
// $Id: Tab.hh,v 1.9 2002/01/27 12:52:02 fluxgen Exp $
|
// $Id: Tab.hh,v 1.10 2002/02/04 06:51:15 fluxgen Exp $
|
||||||
|
|
||||||
#ifndef _TAB_HH_
|
#ifndef _TAB_HH_
|
||||||
#define _TAB_HH_
|
#define _TAB_HH_
|
||||||
|
@ -100,6 +100,7 @@ private:
|
||||||
int setPositionLRAlignHelper(Alignment align);
|
int setPositionLRAlignHelper(Alignment align);
|
||||||
void setTabWidth(unsigned int w);
|
void setTabWidth(unsigned int w);
|
||||||
void setTabHeight(unsigned int h);
|
void setTabHeight(unsigned int h);
|
||||||
|
unsigned int numObjects();
|
||||||
unsigned int calcRelativeWidth();
|
unsigned int calcRelativeWidth();
|
||||||
unsigned int calcRelativeHeight();
|
unsigned int calcRelativeHeight();
|
||||||
unsigned int calcCenterXPos();
|
unsigned int calcCenterXPos();
|
||||||
|
|
Loading…
Reference in a new issue