2003-01-05 22:14:10 +00:00
|
|
|
// FbWinFrame.cc for Fluxbox Window Manager
|
2006-02-16 06:53:05 +00:00
|
|
|
// Copyright (c) 2003 - 2006 Henrik Kinnunen (fluxgen at fluxbox dot org)
|
2003-01-05 22:14:10 +00:00
|
|
|
//
|
|
|
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
// copy of this software and associated documentation files (the "Software"),
|
|
|
|
// to deal in the Software without restriction, including without limitation
|
|
|
|
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
|
// and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
// Software is furnished to do so, subject to the following conditions:
|
|
|
|
//
|
|
|
|
// The above copyright notice and this permission notice shall be included in
|
|
|
|
// all copies or substantial portions of the Software.
|
|
|
|
//
|
|
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
// 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
|
|
|
|
// DEALINGS IN THE SOFTWARE.
|
|
|
|
|
|
|
|
#include "FbWinFrame.hh"
|
2003-08-19 16:15:32 +00:00
|
|
|
|
|
|
|
#include "FbTk/ImageControl.hh"
|
|
|
|
#include "FbTk/EventManager.hh"
|
|
|
|
#include "FbTk/App.hh"
|
2003-09-10 09:53:21 +00:00
|
|
|
#include "FbTk/SimpleCommand.hh"
|
2004-02-28 16:54:04 +00:00
|
|
|
#include "FbTk/Compose.hh"
|
2004-09-12 14:56:20 +00:00
|
|
|
#include "FbTk/Transparent.hh"
|
2007-12-28 05:47:55 +00:00
|
|
|
#include "FbTk/CompareEqual.hh"
|
2003-07-10 11:36:21 +00:00
|
|
|
#include "FbWinFrameTheme.hh"
|
2006-03-20 11:31:24 +00:00
|
|
|
#include "Screen.hh"
|
2004-02-27 12:20:01 +00:00
|
|
|
|
2007-10-13 21:51:37 +00:00
|
|
|
#include "IconButton.hh"
|
2005-06-19 12:12:54 +00:00
|
|
|
|
2003-04-14 15:01:55 +00:00
|
|
|
#include <algorithm>
|
2003-09-11 13:35:37 +00:00
|
|
|
#include <X11/X.h>
|
2003-01-05 22:14:10 +00:00
|
|
|
|
2006-10-27 06:57:43 +00:00
|
|
|
using std::mem_fun;
|
|
|
|
using std::string;
|
|
|
|
|
2008-01-05 01:39:19 +00:00
|
|
|
FbWinFrame::FbWinFrame(BScreen &screen,
|
|
|
|
FbTk::ThemeProxy<FbWinFrameTheme> &theme,
|
|
|
|
FbTk::ImageControl &imgctrl,
|
2006-03-20 11:31:24 +00:00
|
|
|
FbTk::XLayer &layer,
|
2003-12-18 18:03:23 +00:00
|
|
|
int x, int y,
|
2003-01-05 22:14:10 +00:00
|
|
|
unsigned int width, unsigned int height):
|
2006-03-20 11:31:24 +00:00
|
|
|
m_screen(screen),
|
2003-01-05 22:14:10 +00:00
|
|
|
m_theme(theme),
|
|
|
|
m_imagectrl(imgctrl),
|
2008-01-05 01:39:19 +00:00
|
|
|
m_window(theme->screenNum(), x, y, width, height,
|
2007-10-13 21:51:37 +00:00
|
|
|
ButtonPressMask | ButtonReleaseMask |
|
2007-11-22 20:21:47 +00:00
|
|
|
ButtonMotionMask | EnterWindowMask |
|
|
|
|
LeaveWindowMask, true),
|
2006-03-20 11:31:24 +00:00
|
|
|
m_layeritem(window(), layer),
|
2006-10-27 06:57:43 +00:00
|
|
|
m_titlebar(m_window, 0, 0, 100, 16,
|
2003-01-05 22:14:10 +00:00
|
|
|
ButtonPressMask | ButtonReleaseMask |
|
|
|
|
ButtonMotionMask | ExposureMask |
|
|
|
|
EnterWindowMask | LeaveWindowMask),
|
2005-06-19 12:12:54 +00:00
|
|
|
m_tab_container(m_titlebar),
|
2008-01-05 01:39:19 +00:00
|
|
|
m_label(m_titlebar, m_theme->font(), ""),
|
2003-10-02 14:14:46 +00:00
|
|
|
m_handle(m_window, 0, 0, 100, 5,
|
|
|
|
ButtonPressMask | ButtonReleaseMask |
|
|
|
|
ButtonMotionMask | ExposureMask |
|
|
|
|
EnterWindowMask | LeaveWindowMask),
|
|
|
|
m_grip_right(m_handle, 0, 0, 10, 4,
|
2003-01-05 22:14:10 +00:00
|
|
|
ButtonPressMask | ButtonReleaseMask |
|
|
|
|
ButtonMotionMask | ExposureMask |
|
|
|
|
EnterWindowMask | LeaveWindowMask),
|
2003-10-02 14:14:46 +00:00
|
|
|
m_grip_left(m_handle, 0, 0, 10, 4,
|
2007-12-30 15:32:53 +00:00
|
|
|
ButtonPressMask | ButtonReleaseMask |
|
|
|
|
ButtonMotionMask | ExposureMask |
|
|
|
|
EnterWindowMask | LeaveWindowMask),
|
2003-01-05 22:14:10 +00:00
|
|
|
m_clientarea(m_window, 0, 0, 100, 100,
|
|
|
|
ButtonPressMask | ButtonReleaseMask |
|
|
|
|
ButtonMotionMask | ExposureMask |
|
|
|
|
EnterWindowMask | LeaveWindowMask),
|
|
|
|
m_bevel(1),
|
2007-12-23 21:28:08 +00:00
|
|
|
m_decoration_mask(DECOR_NORMAL),
|
2006-10-27 06:57:43 +00:00
|
|
|
m_use_titlebar(true),
|
|
|
|
m_use_tabs(true),
|
2003-01-07 01:30:57 +00:00
|
|
|
m_use_handle(true),
|
2003-04-09 17:20:06 +00:00
|
|
|
m_focused(false),
|
2003-05-01 13:19:36 +00:00
|
|
|
m_visible(false),
|
2003-02-15 01:54:54 +00:00
|
|
|
m_button_pm(0),
|
2006-03-22 13:06:00 +00:00
|
|
|
m_tabmode(screen.getDefaultInternalTabs()?INTERNAL:EXTERNAL),
|
2006-07-17 20:55:20 +00:00
|
|
|
m_active_gravity(0),
|
|
|
|
m_active_orig_client_bw(0),
|
2005-04-10 18:18:14 +00:00
|
|
|
m_need_render(true),
|
2006-07-17 20:55:20 +00:00
|
|
|
m_button_size(1),
|
|
|
|
m_height_before_shade(1),
|
2007-01-07 11:55:14 +00:00
|
|
|
m_shaded(false),
|
2008-01-05 01:39:19 +00:00
|
|
|
m_focused_alpha(AlphaAcc(*theme, &FbWinFrameTheme::focusedAlpha)),
|
|
|
|
m_unfocused_alpha(AlphaAcc(*theme, &FbWinFrameTheme::unfocusedAlpha)),
|
|
|
|
m_shape(m_window, theme->shapePlace()),
|
2007-08-09 03:45:31 +00:00
|
|
|
m_disable_themeshape(false) {
|
2003-01-05 22:14:10 +00:00
|
|
|
init();
|
|
|
|
}
|
2003-04-14 15:01:55 +00:00
|
|
|
|
2003-01-05 22:14:10 +00:00
|
|
|
FbWinFrame::~FbWinFrame() {
|
|
|
|
removeEventHandler();
|
|
|
|
removeAllButtons();
|
|
|
|
}
|
|
|
|
|
2006-03-20 11:31:24 +00:00
|
|
|
bool FbWinFrame::setTabMode(TabMode tabmode) {
|
|
|
|
if (m_tabmode == tabmode)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
bool ret = true;
|
|
|
|
|
2006-10-27 06:57:43 +00:00
|
|
|
// setting tabmode to notset forces it through when
|
2006-03-20 11:31:24 +00:00
|
|
|
// something is likely to change
|
|
|
|
if (tabmode == NOTSET)
|
|
|
|
tabmode = m_tabmode;
|
|
|
|
|
2006-03-22 12:23:17 +00:00
|
|
|
m_tabmode = tabmode;
|
|
|
|
|
2006-03-20 11:31:24 +00:00
|
|
|
// reparent tab container
|
|
|
|
if (tabmode == EXTERNAL) {
|
2006-03-22 12:23:17 +00:00
|
|
|
m_label.show();
|
2006-03-20 11:31:24 +00:00
|
|
|
m_tab_container.setBorderWidth(m_window.borderWidth());
|
2008-01-05 01:39:19 +00:00
|
|
|
m_tab_container.setBorderColor(theme()->border(m_focused).color());
|
2006-03-20 11:31:24 +00:00
|
|
|
m_tab_container.setEventMask(
|
|
|
|
ButtonPressMask | ButtonReleaseMask |
|
|
|
|
ButtonMotionMask | ExposureMask |
|
|
|
|
EnterWindowMask | LeaveWindowMask);
|
|
|
|
|
2006-03-26 12:32:15 +00:00
|
|
|
alignTabs();
|
2006-03-22 13:06:00 +00:00
|
|
|
|
2006-03-20 11:31:24 +00:00
|
|
|
// TODO: tab position
|
|
|
|
if (m_use_tabs && m_visible)
|
|
|
|
m_tab_container.show();
|
|
|
|
else {
|
|
|
|
ret = false;
|
|
|
|
m_tab_container.hide();
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
2006-03-26 12:32:15 +00:00
|
|
|
m_tab_container.setUpdateLock(true);
|
|
|
|
|
2007-12-28 05:47:55 +00:00
|
|
|
m_tab_container.setAlignment(FbTk::Container::RELATIVE);
|
2006-03-26 04:02:30 +00:00
|
|
|
m_tab_container.setOrientation(FbTk::ROT0);
|
2006-03-20 11:31:24 +00:00
|
|
|
if (m_tab_container.parent()->window() == m_screen.rootWindow().window()) {
|
|
|
|
m_layeritem.removeWindow(m_tab_container);
|
2006-06-24 14:05:19 +00:00
|
|
|
m_tab_container.hide();
|
2006-03-20 11:31:24 +00:00
|
|
|
m_tab_container.reparent(m_titlebar, m_label.x(), m_label.y());
|
2006-06-24 14:05:19 +00:00
|
|
|
m_tab_container.invalidateBackground();
|
2006-03-22 12:23:17 +00:00
|
|
|
m_tab_container.resize(m_label.width(), m_label.height());
|
2006-03-20 11:31:24 +00:00
|
|
|
m_tab_container.raise();
|
|
|
|
}
|
|
|
|
m_tab_container.setBorderWidth(0);
|
|
|
|
m_tab_container.setMaxTotalSize(0);
|
2006-03-22 13:06:00 +00:00
|
|
|
m_tab_container.setUpdateLock(false);
|
2006-03-20 11:31:24 +00:00
|
|
|
m_tab_container.setMaxSizePerClient(0);
|
2006-03-22 13:06:00 +00:00
|
|
|
|
|
|
|
renderTabContainer();
|
|
|
|
applyTabContainer();
|
|
|
|
m_tab_container.clear();
|
|
|
|
|
2006-03-23 02:06:51 +00:00
|
|
|
m_tab_container.raise();
|
|
|
|
m_tab_container.show();
|
2006-10-27 06:57:43 +00:00
|
|
|
|
2006-03-20 11:31:24 +00:00
|
|
|
if (!m_use_tabs)
|
|
|
|
ret = false;
|
2006-03-23 02:06:51 +00:00
|
|
|
|
2006-03-22 12:23:17 +00:00
|
|
|
m_label.hide();
|
2006-03-20 11:31:24 +00:00
|
|
|
// reconfigure();
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2003-01-05 22:14:10 +00:00
|
|
|
void FbWinFrame::hide() {
|
|
|
|
m_window.hide();
|
2006-03-20 11:31:24 +00:00
|
|
|
if (m_tabmode == EXTERNAL && m_use_tabs)
|
|
|
|
m_tab_container.hide();
|
|
|
|
|
2003-05-01 13:19:36 +00:00
|
|
|
m_visible = false;
|
2003-01-05 22:14:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void FbWinFrame::show() {
|
2003-05-01 13:19:36 +00:00
|
|
|
m_visible = true;
|
2005-04-10 18:18:14 +00:00
|
|
|
|
|
|
|
if (m_need_render) {
|
|
|
|
renderAll();
|
2007-08-09 03:45:31 +00:00
|
|
|
applyAll();
|
2005-04-10 18:18:14 +00:00
|
|
|
clearAll();
|
|
|
|
}
|
|
|
|
|
2006-03-20 11:31:24 +00:00
|
|
|
if (m_tabmode == EXTERNAL && m_use_tabs)
|
|
|
|
m_tab_container.show();
|
|
|
|
|
2003-01-05 22:14:10 +00:00
|
|
|
m_window.showSubwindows();
|
|
|
|
m_window.show();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
Toggle shade state, and resize window
|
|
|
|
*/
|
|
|
|
void FbWinFrame::shade() {
|
2003-02-20 23:21:23 +00:00
|
|
|
if (!m_use_titlebar)
|
|
|
|
return;
|
|
|
|
|
2003-04-03 22:37:43 +00:00
|
|
|
// toggle shade
|
|
|
|
m_shaded = !m_shaded;
|
|
|
|
if (m_shaded) { // i.e. should be shaded now
|
2003-01-05 22:14:10 +00:00
|
|
|
m_height_before_shade = m_window.height();
|
2003-02-23 21:32:37 +00:00
|
|
|
m_window.resize(m_window.width(), m_titlebar.height());
|
2006-03-24 15:19:02 +00:00
|
|
|
alignTabs();
|
2006-07-06 20:09:23 +00:00
|
|
|
// need to update our shape
|
2007-08-09 03:45:31 +00:00
|
|
|
m_shape.update();
|
2003-04-03 22:37:43 +00:00
|
|
|
} else { // should be unshaded
|
2007-04-23 16:09:00 +00:00
|
|
|
m_window.resize(m_window.width(), m_height_before_shade);
|
2003-04-03 22:37:43 +00:00
|
|
|
reconfigure();
|
2003-01-05 22:14:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-07-03 17:18:17 +00:00
|
|
|
void FbWinFrame::move(int x, int y) {
|
|
|
|
moveResize(x, y, 0, 0, true, false);
|
2003-09-24 14:02:25 +00:00
|
|
|
}
|
2003-08-04 12:47:36 +00:00
|
|
|
|
2006-07-03 17:18:17 +00:00
|
|
|
void FbWinFrame::resize(unsigned int width, unsigned int height) {
|
|
|
|
moveResize(0, 0, width, height, false, true);
|
2003-09-24 14:02:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// need an atomic moveresize where possible
|
2006-10-27 06:57:43 +00:00
|
|
|
void FbWinFrame::moveResizeForClient(int x, int y,
|
|
|
|
unsigned int width, unsigned int height,
|
|
|
|
int win_gravity,
|
|
|
|
unsigned int client_bw,
|
2006-07-17 20:55:20 +00:00
|
|
|
bool move, bool resize) {
|
2003-09-24 14:02:25 +00:00
|
|
|
// total height for frame
|
2003-08-04 12:47:36 +00:00
|
|
|
|
2006-07-03 17:18:17 +00:00
|
|
|
if (resize) // these fns check if the elements are "on"
|
|
|
|
height += titlebarHeight() + handleHeight();
|
2003-08-04 12:47:36 +00:00
|
|
|
|
2006-07-03 17:18:17 +00:00
|
|
|
gravityTranslate(x, y, win_gravity, client_bw, false);
|
|
|
|
setActiveGravity(win_gravity, client_bw);
|
|
|
|
moveResize(x, y, width, height, move, resize);
|
2003-09-24 14:02:25 +00:00
|
|
|
}
|
2003-09-10 09:53:21 +00:00
|
|
|
|
2006-10-27 06:57:43 +00:00
|
|
|
void FbWinFrame::resizeForClient(unsigned int width, unsigned int height,
|
2006-07-17 20:55:20 +00:00
|
|
|
int win_gravity, unsigned int client_bw) {
|
2006-07-04 13:20:04 +00:00
|
|
|
moveResizeForClient(0, 0, width, height, win_gravity, client_bw, false, true);
|
2003-01-05 22:14:10 +00:00
|
|
|
}
|
|
|
|
|
2006-07-03 17:18:17 +00:00
|
|
|
void FbWinFrame::moveResize(int x, int y, unsigned int width, unsigned int height, bool move, bool resize) {
|
2006-10-27 06:57:43 +00:00
|
|
|
if (move && x == window().x() && y == window().y())
|
2003-09-24 14:02:25 +00:00
|
|
|
move = false;
|
|
|
|
|
2007-04-23 16:09:00 +00:00
|
|
|
if (resize && (m_shaded || width == FbWinFrame::width() &&
|
|
|
|
height == FbWinFrame::height()))
|
2003-09-24 14:02:25 +00:00
|
|
|
resize = false;
|
|
|
|
|
|
|
|
if (!move && !resize)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (move && resize) {
|
|
|
|
m_window.moveResize(x, y, width, height);
|
2005-04-10 18:18:14 +00:00
|
|
|
notifyMoved(false); // will reconfigure
|
2003-09-24 14:02:25 +00:00
|
|
|
} else if (move) {
|
|
|
|
m_window.move(x, y);
|
|
|
|
// this stuff will be caught by reconfigure if resized
|
2005-04-10 18:18:14 +00:00
|
|
|
notifyMoved(true);
|
2003-01-05 22:14:10 +00:00
|
|
|
} else {
|
|
|
|
m_window.resize(width, height);
|
|
|
|
}
|
|
|
|
|
2006-03-22 13:06:00 +00:00
|
|
|
if (move || resize && m_screen.getTabPlacement() != TOPLEFT)
|
2006-03-20 11:31:24 +00:00
|
|
|
alignTabs();
|
|
|
|
|
|
|
|
if (resize) {
|
2006-03-26 04:02:30 +00:00
|
|
|
if (m_tabmode == EXTERNAL) {
|
|
|
|
switch(m_screen.getTabPlacement()) {
|
|
|
|
case LEFTTOP:
|
|
|
|
case RIGHTTOP:
|
|
|
|
case LEFTBOTTOM:
|
|
|
|
case RIGHTBOTTOM:
|
|
|
|
m_tab_container.setMaxTotalSize(height);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
m_tab_container.setMaxTotalSize(width);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2003-09-24 14:02:25 +00:00
|
|
|
reconfigure();
|
2006-03-20 11:31:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-10-27 06:57:43 +00:00
|
|
|
void FbWinFrame::quietMoveResize(int x, int y,
|
2006-03-20 11:31:24 +00:00
|
|
|
unsigned int width, unsigned int height) {
|
|
|
|
m_window.moveResize(x, y, width, height);
|
|
|
|
if (m_tabmode == EXTERNAL) {
|
2006-10-27 06:57:43 +00:00
|
|
|
|
2006-03-26 04:02:30 +00:00
|
|
|
switch(m_screen.getTabPlacement()) {
|
|
|
|
case LEFTTOP:
|
|
|
|
case RIGHTTOP:
|
|
|
|
case LEFTBOTTOM:
|
|
|
|
case RIGHTBOTTOM:
|
|
|
|
m_tab_container.setMaxTotalSize(height);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
m_tab_container.setMaxTotalSize(width);
|
|
|
|
break;
|
|
|
|
}
|
2006-03-20 11:31:24 +00:00
|
|
|
alignTabs();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void FbWinFrame::alignTabs() {
|
2006-03-22 12:23:17 +00:00
|
|
|
if (m_tabmode != EXTERNAL)
|
|
|
|
return;
|
|
|
|
|
2006-04-04 12:16:26 +00:00
|
|
|
|
2006-03-26 12:32:15 +00:00
|
|
|
FbTk::Orientation orig_orient = m_tab_container.orientation();
|
|
|
|
unsigned int orig_tabwidth = m_tab_container.maxWidthPerClient();
|
|
|
|
|
|
|
|
if (orig_tabwidth != m_screen.getTabWidth())
|
2006-03-23 01:06:29 +00:00
|
|
|
m_tab_container.setMaxSizePerClient(m_screen.getTabWidth());
|
2006-03-22 13:06:00 +00:00
|
|
|
|
2006-03-22 12:23:17 +00:00
|
|
|
int tabx = 0, taby = 0;
|
2006-03-22 13:06:00 +00:00
|
|
|
switch (m_screen.getTabPlacement()) {
|
2006-03-22 12:23:17 +00:00
|
|
|
case TOPLEFT:
|
2006-03-26 12:32:15 +00:00
|
|
|
if (orig_orient != FbTk::ROT0) m_tab_container.hide();
|
2006-03-26 04:02:30 +00:00
|
|
|
m_tab_container.setOrientation(FbTk::ROT0);
|
2007-12-28 05:47:55 +00:00
|
|
|
m_tab_container.setAlignment(FbTk::Container::LEFT);
|
2006-06-10 16:31:47 +00:00
|
|
|
m_tab_container.setMaxTotalSize(m_window.width());
|
2006-03-22 12:23:17 +00:00
|
|
|
tabx = x();
|
|
|
|
taby = y() - yOffset();
|
|
|
|
break;
|
|
|
|
case TOPRIGHT:
|
2006-03-26 12:32:15 +00:00
|
|
|
if (orig_orient != FbTk::ROT0) m_tab_container.hide();
|
2006-03-26 04:02:30 +00:00
|
|
|
m_tab_container.setOrientation(FbTk::ROT0);
|
2007-12-28 05:47:55 +00:00
|
|
|
m_tab_container.setAlignment(FbTk::Container::RIGHT);
|
2006-06-10 16:31:47 +00:00
|
|
|
m_tab_container.setMaxTotalSize(m_window.width());
|
2006-03-22 12:23:17 +00:00
|
|
|
tabx = x() + width() - m_tab_container.width();
|
|
|
|
taby = y() - yOffset();
|
|
|
|
break;
|
2006-03-26 04:02:30 +00:00
|
|
|
case LEFTTOP:
|
2006-03-26 12:32:15 +00:00
|
|
|
if (orig_orient != FbTk::ROT270) m_tab_container.hide();
|
2006-03-26 04:02:30 +00:00
|
|
|
m_tab_container.setOrientation(FbTk::ROT270);
|
2007-12-28 05:47:55 +00:00
|
|
|
m_tab_container.setAlignment(FbTk::Container::RIGHT);
|
2006-06-10 16:31:47 +00:00
|
|
|
m_tab_container.setMaxTotalSize(m_window.height());
|
2006-03-26 04:02:30 +00:00
|
|
|
tabx = x() - xOffset();
|
|
|
|
taby = y();
|
|
|
|
break;
|
|
|
|
case LEFTBOTTOM:
|
2006-03-26 12:32:15 +00:00
|
|
|
if (orig_orient != FbTk::ROT270) m_tab_container.hide();
|
2006-03-26 04:02:30 +00:00
|
|
|
m_tab_container.setOrientation(FbTk::ROT270);
|
2007-12-28 05:47:55 +00:00
|
|
|
m_tab_container.setAlignment(FbTk::Container::LEFT);
|
2006-06-10 16:31:47 +00:00
|
|
|
m_tab_container.setMaxTotalSize(m_window.height());
|
2006-03-26 04:02:30 +00:00
|
|
|
tabx = x() - xOffset();
|
|
|
|
taby = y() + height() - m_tab_container.height();
|
|
|
|
break;
|
|
|
|
case RIGHTTOP:
|
2006-03-26 12:32:15 +00:00
|
|
|
if (orig_orient != FbTk::ROT90) m_tab_container.hide();
|
2006-03-26 04:02:30 +00:00
|
|
|
m_tab_container.setOrientation(FbTk::ROT90);
|
2007-12-28 05:47:55 +00:00
|
|
|
m_tab_container.setAlignment(FbTk::Container::LEFT);
|
2006-06-10 16:31:47 +00:00
|
|
|
m_tab_container.setMaxTotalSize(m_window.height());
|
2006-04-04 12:16:26 +00:00
|
|
|
tabx = x() + width() + m_window.borderWidth();
|
2006-03-26 04:02:30 +00:00
|
|
|
taby = y();
|
|
|
|
break;
|
|
|
|
case RIGHTBOTTOM:
|
2006-03-26 12:32:15 +00:00
|
|
|
if (orig_orient != FbTk::ROT90) m_tab_container.hide();
|
2006-03-26 04:02:30 +00:00
|
|
|
m_tab_container.setOrientation(FbTk::ROT90);
|
2007-12-28 05:47:55 +00:00
|
|
|
m_tab_container.setAlignment(FbTk::Container::RIGHT);
|
2006-06-10 16:31:47 +00:00
|
|
|
m_tab_container.setMaxTotalSize(m_window.height());
|
2006-04-04 12:16:26 +00:00
|
|
|
tabx = x() + width() + m_window.borderWidth();
|
2006-03-26 04:02:30 +00:00
|
|
|
taby = y() + height() - m_tab_container.height();
|
|
|
|
break;
|
2006-03-22 12:23:17 +00:00
|
|
|
case BOTTOMLEFT:
|
2006-03-26 12:32:15 +00:00
|
|
|
if (orig_orient != FbTk::ROT0) m_tab_container.hide();
|
2006-03-26 04:02:30 +00:00
|
|
|
m_tab_container.setOrientation(FbTk::ROT0);
|
2007-12-28 05:47:55 +00:00
|
|
|
m_tab_container.setAlignment(FbTk::Container::LEFT);
|
2006-06-10 16:31:47 +00:00
|
|
|
m_tab_container.setMaxTotalSize(m_window.width());
|
2006-03-22 12:23:17 +00:00
|
|
|
tabx = x();
|
|
|
|
taby = y() + height() + m_window.borderWidth();
|
|
|
|
break;
|
|
|
|
case BOTTOMRIGHT:
|
2006-03-26 12:32:15 +00:00
|
|
|
if (orig_orient != FbTk::ROT0) m_tab_container.hide();
|
2006-03-26 04:02:30 +00:00
|
|
|
m_tab_container.setOrientation(FbTk::ROT0);
|
2007-12-28 05:47:55 +00:00
|
|
|
m_tab_container.setAlignment(FbTk::Container::RIGHT);
|
2006-06-10 16:31:47 +00:00
|
|
|
m_tab_container.setMaxTotalSize(m_window.width());
|
2006-03-22 12:23:17 +00:00
|
|
|
tabx = x() + width() - m_tab_container.width();
|
|
|
|
taby = y() + height() + m_window.borderWidth();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2006-03-26 12:32:15 +00:00
|
|
|
unsigned int w = m_window.width(), h = m_window.height();
|
|
|
|
translateSize(m_tab_container.orientation(), w, h);
|
|
|
|
|
|
|
|
if (m_tab_container.orientation() != orig_orient ||
|
|
|
|
m_tab_container.maxWidthPerClient() != orig_tabwidth) {
|
2006-03-26 04:07:14 +00:00
|
|
|
renderTabContainer();
|
2006-03-26 12:32:15 +00:00
|
|
|
if (m_visible && m_use_tabs) {
|
|
|
|
applyTabContainer();
|
|
|
|
m_tab_container.clear();
|
|
|
|
m_tab_container.show();
|
2006-04-05 03:48:16 +00:00
|
|
|
}
|
2006-03-26 04:07:14 +00:00
|
|
|
}
|
|
|
|
|
2006-03-26 12:32:15 +00:00
|
|
|
if (m_tab_container.parent()->window() != m_screen.rootWindow().window()) {
|
|
|
|
m_tab_container.reparent(m_screen.rootWindow(), tabx, taby);
|
2006-06-24 14:05:19 +00:00
|
|
|
m_label.clear();
|
2006-03-26 12:32:15 +00:00
|
|
|
m_layeritem.addWindow(m_tab_container);
|
|
|
|
} else {
|
|
|
|
m_tab_container.move(tabx, taby);
|
|
|
|
}
|
2003-01-05 22:14:10 +00:00
|
|
|
}
|
|
|
|
|
2005-04-10 18:18:14 +00:00
|
|
|
void FbWinFrame::notifyMoved(bool clear) {
|
|
|
|
// not important if no alpha...
|
2007-01-07 11:55:14 +00:00
|
|
|
unsigned char alpha = getAlpha(m_focused);
|
2006-10-27 06:57:43 +00:00
|
|
|
if (alpha == 255)
|
2005-04-10 18:18:14 +00:00
|
|
|
return;
|
|
|
|
|
2006-03-20 11:31:24 +00:00
|
|
|
if (m_tabmode == EXTERNAL && m_use_tabs || m_use_titlebar) {
|
|
|
|
m_tab_container.parentMoved();
|
|
|
|
m_tab_container.for_each(mem_fun(&FbTk::Button::parentMoved));
|
|
|
|
}
|
|
|
|
|
2005-04-10 18:18:14 +00:00
|
|
|
if (m_use_titlebar) {
|
2006-04-09 13:38:13 +00:00
|
|
|
if (m_tabmode != INTERNAL)
|
2006-03-20 11:31:24 +00:00
|
|
|
m_label.parentMoved();
|
|
|
|
|
2005-04-10 18:18:14 +00:00
|
|
|
m_titlebar.parentMoved();
|
|
|
|
|
|
|
|
for_each(m_buttons_left.begin(),
|
|
|
|
m_buttons_left.end(),
|
|
|
|
mem_fun(&FbTk::Button::parentMoved));
|
|
|
|
for_each(m_buttons_right.begin(),
|
|
|
|
m_buttons_right.end(),
|
|
|
|
mem_fun(&FbTk::Button::parentMoved));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (m_use_handle) {
|
|
|
|
m_handle.parentMoved();
|
|
|
|
m_grip_left.parentMoved();
|
|
|
|
m_grip_right.parentMoved();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (clear && (m_use_handle || m_use_titlebar)) {
|
|
|
|
clearAll();
|
2006-03-20 11:31:24 +00:00
|
|
|
} else if (clear && m_tabmode == EXTERNAL && m_use_tabs)
|
|
|
|
m_tab_container.clear();
|
2005-04-10 18:18:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void FbWinFrame::clearAll() {
|
2005-04-13 14:39:25 +00:00
|
|
|
|
2005-04-10 18:18:14 +00:00
|
|
|
if (m_use_titlebar) {
|
|
|
|
redrawTitlebar();
|
|
|
|
|
|
|
|
for_each(m_buttons_left.begin(),
|
|
|
|
m_buttons_left.end(),
|
|
|
|
mem_fun(&FbTk::Button::clear));
|
|
|
|
for_each(m_buttons_right.begin(),
|
|
|
|
m_buttons_right.end(),
|
|
|
|
mem_fun(&FbTk::Button::clear));
|
2006-03-20 11:31:24 +00:00
|
|
|
} else if (m_tabmode == EXTERNAL && m_use_tabs)
|
|
|
|
m_tab_container.clear();
|
2005-04-10 18:18:14 +00:00
|
|
|
|
|
|
|
if (m_use_handle) {
|
|
|
|
m_handle.clear();
|
|
|
|
m_grip_left.clear();
|
|
|
|
m_grip_right.clear();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-01-05 22:14:10 +00:00
|
|
|
void FbWinFrame::setFocus(bool newvalue) {
|
2003-09-14 10:32:31 +00:00
|
|
|
if (m_focused == newvalue)
|
2003-01-05 22:14:10 +00:00
|
|
|
return;
|
|
|
|
|
2003-10-31 10:37:09 +00:00
|
|
|
m_focused = newvalue;
|
|
|
|
|
2007-01-27 20:34:57 +00:00
|
|
|
if (FbTk::Transparent::haveRender() &&
|
|
|
|
getAlpha(true) != getAlpha(false)) { // different alpha for focused and unfocused
|
2007-01-07 11:55:14 +00:00
|
|
|
unsigned char alpha = getAlpha(m_focused);
|
2005-04-10 18:18:14 +00:00
|
|
|
if (FbTk::Transparent::haveComposite()) {
|
2007-01-06 19:03:33 +00:00
|
|
|
m_tab_container.setAlpha(255);
|
2005-04-10 18:18:14 +00:00
|
|
|
m_window.setOpaque(alpha);
|
|
|
|
} else {
|
2005-06-19 12:12:54 +00:00
|
|
|
m_tab_container.setAlpha(alpha);
|
2007-01-06 19:03:33 +00:00
|
|
|
m_window.setOpaque(255);
|
2005-04-10 18:18:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-12-23 21:33:10 +00:00
|
|
|
if (m_decoration_mask & DECORM_BORDER &&
|
2008-01-05 01:39:19 +00:00
|
|
|
(theme()->border(true).width() != theme()->border(false).width() ||
|
|
|
|
theme()->border(true).color().pixel() !=
|
|
|
|
theme()->border(false).color().pixel()))
|
|
|
|
setBorderWidth(theme()->border(newvalue).width());
|
2007-12-23 21:33:10 +00:00
|
|
|
|
2007-01-06 19:03:33 +00:00
|
|
|
applyAll();
|
2005-04-10 18:18:14 +00:00
|
|
|
clearAll();
|
2003-01-05 22:14:10 +00:00
|
|
|
}
|
|
|
|
|
2007-01-07 11:55:14 +00:00
|
|
|
void FbWinFrame::setAlpha(bool focused, unsigned char alpha) {
|
|
|
|
if (focused)
|
|
|
|
m_focused_alpha = alpha;
|
|
|
|
else
|
|
|
|
m_unfocused_alpha = alpha;
|
|
|
|
|
2007-12-27 04:42:10 +00:00
|
|
|
if (m_focused == focused)
|
|
|
|
applyAlpha();
|
2007-01-07 11:55:14 +00:00
|
|
|
}
|
|
|
|
|
2007-12-27 04:42:10 +00:00
|
|
|
void FbWinFrame::applyAlpha() {
|
|
|
|
unsigned char alpha = getAlpha(m_focused);
|
2007-02-02 19:04:57 +00:00
|
|
|
if (FbTk::Transparent::haveComposite())
|
2007-12-27 04:42:10 +00:00
|
|
|
m_window.setOpaque(alpha);
|
2007-02-02 19:04:57 +00:00
|
|
|
else {
|
|
|
|
// don't need to setAlpha, since apply updates them anyway
|
|
|
|
applyAll();
|
|
|
|
clearAll();
|
|
|
|
}
|
2007-01-07 11:55:14 +00:00
|
|
|
}
|
|
|
|
|
2007-12-27 04:42:10 +00:00
|
|
|
unsigned char FbWinFrame::getAlpha(bool focused) const {
|
|
|
|
return focused ? m_focused_alpha : m_unfocused_alpha;
|
|
|
|
}
|
|
|
|
|
|
|
|
void FbWinFrame::setDefaultAlpha() {
|
|
|
|
if (getUseDefaultAlpha())
|
|
|
|
return;
|
|
|
|
m_focused_alpha.restoreDefault();
|
|
|
|
m_unfocused_alpha.restoreDefault();
|
|
|
|
applyAlpha();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool FbWinFrame::getUseDefaultAlpha() const {
|
|
|
|
return m_focused_alpha.isDefault() && m_unfocused_alpha.isDefault();
|
|
|
|
}
|
|
|
|
|
2003-01-05 22:14:10 +00:00
|
|
|
void FbWinFrame::addLeftButton(FbTk::Button *btn) {
|
|
|
|
if (btn == 0) // valid button?
|
|
|
|
return;
|
|
|
|
|
2005-04-10 18:18:14 +00:00
|
|
|
applyButton(*btn); // setup theme and other stuff
|
2006-10-27 06:57:43 +00:00
|
|
|
|
2003-01-05 22:14:10 +00:00
|
|
|
m_buttons_left.push_back(btn);
|
|
|
|
}
|
|
|
|
|
|
|
|
void FbWinFrame::addRightButton(FbTk::Button *btn) {
|
|
|
|
if (btn == 0) // valid button?
|
|
|
|
return;
|
|
|
|
|
2005-04-10 18:18:14 +00:00
|
|
|
applyButton(*btn); // setup theme and other stuff
|
2003-01-05 22:14:10 +00:00
|
|
|
|
|
|
|
m_buttons_right.push_back(btn);
|
|
|
|
}
|
|
|
|
|
|
|
|
void FbWinFrame::removeAllButtons() {
|
|
|
|
// destroy left side
|
|
|
|
while (!m_buttons_left.empty()) {
|
|
|
|
delete m_buttons_left.back();
|
|
|
|
m_buttons_left.pop_back();
|
|
|
|
}
|
|
|
|
// destroy right side
|
|
|
|
while (!m_buttons_right.empty()) {
|
|
|
|
delete m_buttons_right.back();
|
|
|
|
m_buttons_right.pop_back();
|
|
|
|
}
|
2003-04-14 15:01:55 +00:00
|
|
|
}
|
|
|
|
|
2007-10-13 21:51:37 +00:00
|
|
|
IconButton *FbWinFrame::createTab(Focusable &client) {
|
2008-01-05 01:39:19 +00:00
|
|
|
IconButton *button = new IconButton(m_tab_container, theme()->iconbarTheme(),
|
2007-10-13 21:51:37 +00:00
|
|
|
client);
|
2005-06-19 12:12:54 +00:00
|
|
|
|
2005-05-02 01:17:08 +00:00
|
|
|
button->show();
|
|
|
|
button->setEventMask(ExposureMask | ButtonPressMask |
|
2005-06-19 12:12:54 +00:00
|
|
|
ButtonReleaseMask | ButtonMotionMask |
|
2005-05-02 01:17:08 +00:00
|
|
|
EnterWindowMask);
|
2005-06-19 12:12:54 +00:00
|
|
|
FbTk::EventManager::instance()->add(*button, button->window());
|
2006-10-27 06:57:43 +00:00
|
|
|
|
2005-06-19 12:12:54 +00:00
|
|
|
m_tab_container.insertItem(button);
|
2003-12-09 08:48:08 +00:00
|
|
|
|
2005-05-02 01:17:08 +00:00
|
|
|
return button;
|
2003-04-14 15:01:55 +00:00
|
|
|
}
|
|
|
|
|
2007-10-13 21:51:37 +00:00
|
|
|
void FbWinFrame::removeTab(IconButton *btn) {
|
2005-06-19 12:12:54 +00:00
|
|
|
if (m_tab_container.removeItem(btn))
|
|
|
|
delete btn;
|
|
|
|
}
|
2003-07-28 12:11:57 +00:00
|
|
|
|
|
|
|
|
2005-06-19 12:12:54 +00:00
|
|
|
void FbWinFrame::moveLabelButtonLeft(FbTk::TextButton &btn) {
|
|
|
|
m_tab_container.moveItem(&btn, -1);
|
2003-07-28 12:11:57 +00:00
|
|
|
}
|
|
|
|
|
2005-06-19 12:12:54 +00:00
|
|
|
void FbWinFrame::moveLabelButtonRight(FbTk::TextButton &btn) {
|
2005-07-25 23:17:41 +00:00
|
|
|
m_tab_container.moveItem(&btn, +1);
|
2003-07-28 12:11:57 +00:00
|
|
|
}
|
|
|
|
|
2004-11-24 23:27:28 +00:00
|
|
|
void FbWinFrame::moveLabelButtonTo(FbTk::TextButton &btn, int x, int y) {
|
2005-06-19 12:12:54 +00:00
|
|
|
m_tab_container.moveItemTo(&btn, x, y);
|
2004-11-24 23:27:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2005-06-19 12:12:54 +00:00
|
|
|
void FbWinFrame::moveLabelButtonLeftOf(FbTk::TextButton &btn, const FbTk::TextButton &dest) {
|
2005-10-19 04:46:05 +00:00
|
|
|
int dest_pos = m_tab_container.find(&dest);
|
|
|
|
int cur_pos = m_tab_container.find(&btn);
|
|
|
|
if (dest_pos < 0 || cur_pos < 0)
|
2005-05-03 09:25:46 +00:00
|
|
|
return;
|
2005-10-19 04:46:05 +00:00
|
|
|
int movement=dest_pos - cur_pos;
|
|
|
|
if(movement>0)
|
|
|
|
movement-=1;
|
|
|
|
// else
|
|
|
|
// movement-=1;
|
2005-05-03 09:25:46 +00:00
|
|
|
|
2005-10-19 04:46:05 +00:00
|
|
|
m_tab_container.moveItem(&btn, movement);
|
2004-11-24 23:27:28 +00:00
|
|
|
}
|
|
|
|
|
2005-06-19 12:12:54 +00:00
|
|
|
void FbWinFrame::moveLabelButtonRightOf(FbTk::TextButton &btn, const FbTk::TextButton &dest) {
|
2005-10-19 04:46:05 +00:00
|
|
|
int dest_pos = m_tab_container.find(&dest);
|
|
|
|
int cur_pos = m_tab_container.find(&btn);
|
|
|
|
if (dest_pos < 0 || cur_pos < 0 )
|
2005-05-03 09:25:46 +00:00
|
|
|
return;
|
2005-10-19 04:46:05 +00:00
|
|
|
int movement=dest_pos - cur_pos;
|
|
|
|
if(movement<0)
|
|
|
|
movement+=1;
|
2005-05-03 09:25:46 +00:00
|
|
|
|
2005-10-19 04:46:05 +00:00
|
|
|
m_tab_container.moveItem(&btn, movement);
|
2004-11-24 23:27:28 +00:00
|
|
|
}
|
|
|
|
|
2007-10-13 21:51:37 +00:00
|
|
|
void FbWinFrame::setLabelButtonFocus(IconButton &btn) {
|
2006-06-24 18:19:49 +00:00
|
|
|
if (btn.parent() != &m_tab_container)
|
|
|
|
return;
|
2007-10-13 21:51:37 +00:00
|
|
|
m_label.setText(btn.text());
|
2006-06-24 18:19:49 +00:00
|
|
|
}
|
|
|
|
|
2003-04-14 15:01:55 +00:00
|
|
|
void FbWinFrame::setClientWindow(FbTk::FbWindow &win) {
|
2003-01-05 22:14:10 +00:00
|
|
|
|
2004-01-02 13:26:44 +00:00
|
|
|
win.setBorderWidth(0);
|
|
|
|
|
2005-05-03 09:25:46 +00:00
|
|
|
XChangeSaveSet(win.display(), win.window(), SetModeInsert);
|
2003-10-28 02:17:03 +00:00
|
|
|
|
2004-01-02 13:26:44 +00:00
|
|
|
m_window.setEventMask(NoEventMask);
|
2003-10-28 02:17:03 +00:00
|
|
|
|
2003-04-14 23:40:41 +00:00
|
|
|
// we need to mask this so we don't get unmap event
|
2004-01-02 13:26:44 +00:00
|
|
|
win.setEventMask(NoEventMask);
|
|
|
|
win.reparent(m_window, 0, clientArea().y());
|
2003-04-14 23:40:41 +00:00
|
|
|
// remask window so we get events
|
2006-10-27 06:57:43 +00:00
|
|
|
win.setEventMask(PropertyChangeMask | StructureNotifyMask |
|
2007-11-20 19:01:45 +00:00
|
|
|
FocusChangeMask | KeyPressMask);
|
2004-01-02 13:26:44 +00:00
|
|
|
|
|
|
|
m_window.setEventMask(ButtonPressMask | ButtonReleaseMask |
|
2007-11-22 20:21:47 +00:00
|
|
|
ButtonMotionMask | EnterWindowMask |
|
|
|
|
LeaveWindowMask | SubstructureRedirectMask);
|
2003-01-05 22:14:10 +00:00
|
|
|
|
2005-05-03 09:25:46 +00:00
|
|
|
XFlush(win.display());
|
2003-01-05 22:14:10 +00:00
|
|
|
|
2003-04-14 23:40:41 +00:00
|
|
|
XSetWindowAttributes attrib_set;
|
2003-01-05 22:14:10 +00:00
|
|
|
attrib_set.event_mask = PropertyChangeMask | StructureNotifyMask | FocusChangeMask;
|
2006-10-27 06:57:43 +00:00
|
|
|
attrib_set.do_not_propagate_mask = ButtonPressMask | ButtonReleaseMask |
|
2003-04-14 23:40:41 +00:00
|
|
|
ButtonMotionMask;
|
2003-01-05 22:14:10 +00:00
|
|
|
|
2005-05-03 09:25:46 +00:00
|
|
|
XChangeWindowAttributes(win.display(), win.window(), CWEventMask|CWDontPropagate, &attrib_set);
|
2003-01-05 22:14:10 +00:00
|
|
|
|
|
|
|
m_clientarea.raise();
|
2007-10-13 21:51:37 +00:00
|
|
|
if (isVisible())
|
|
|
|
win.show();
|
2004-01-02 13:26:44 +00:00
|
|
|
win.raise();
|
2003-10-28 02:17:03 +00:00
|
|
|
m_window.showSubwindows();
|
2005-05-02 01:17:08 +00:00
|
|
|
|
2003-01-05 22:14:10 +00:00
|
|
|
}
|
|
|
|
|
2006-03-20 11:31:24 +00:00
|
|
|
bool FbWinFrame::hideTabs() {
|
|
|
|
if (m_tabmode == INTERNAL || !m_use_tabs) {
|
|
|
|
m_use_tabs = false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_use_tabs = false;
|
|
|
|
m_tab_container.hide();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool FbWinFrame::showTabs() {
|
|
|
|
if (m_tabmode == INTERNAL || m_use_tabs) {
|
|
|
|
m_use_tabs = true;
|
|
|
|
return false; // nothing changed
|
|
|
|
}
|
|
|
|
|
|
|
|
m_use_tabs = true;
|
|
|
|
if (m_visible)
|
|
|
|
m_tab_container.show();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2003-10-05 09:03:43 +00:00
|
|
|
bool FbWinFrame::hideTitlebar() {
|
2003-02-20 23:21:23 +00:00
|
|
|
if (!m_use_titlebar)
|
2003-10-05 09:03:43 +00:00
|
|
|
return false;
|
2003-02-20 23:21:23 +00:00
|
|
|
|
2003-01-05 22:14:10 +00:00
|
|
|
m_titlebar.hide();
|
2003-01-07 01:30:57 +00:00
|
|
|
m_use_titlebar = false;
|
2004-01-21 19:47:30 +00:00
|
|
|
if (static_cast<signed int>(m_window.height() - m_titlebar.height() -
|
|
|
|
m_titlebar.borderWidth()) <= 0) {
|
|
|
|
m_window.resize(m_window.width(), 1);
|
|
|
|
} else {
|
|
|
|
// only take away one borderwidth (as the other border is still the "top" border)
|
|
|
|
m_window.resize(m_window.width(), m_window.height() - m_titlebar.height() -
|
|
|
|
m_titlebar.borderWidth());
|
|
|
|
}
|
2003-02-23 13:40:22 +00:00
|
|
|
|
2003-10-05 09:03:43 +00:00
|
|
|
return true;
|
2003-01-05 22:14:10 +00:00
|
|
|
}
|
|
|
|
|
2003-10-05 09:03:43 +00:00
|
|
|
bool FbWinFrame::showTitlebar() {
|
2003-02-20 23:21:23 +00:00
|
|
|
if (m_use_titlebar)
|
2003-10-05 09:03:43 +00:00
|
|
|
return false;
|
2003-02-20 23:21:23 +00:00
|
|
|
|
2003-01-05 22:14:10 +00:00
|
|
|
m_titlebar.show();
|
2003-01-07 01:30:57 +00:00
|
|
|
m_use_titlebar = true;
|
2003-02-23 13:40:22 +00:00
|
|
|
|
|
|
|
// only add one borderwidth (as the other border is still the "top" border)
|
|
|
|
m_window.resize(m_window.width(), m_window.height() + m_titlebar.height() +
|
|
|
|
m_titlebar.borderWidth());
|
2006-03-20 11:31:24 +00:00
|
|
|
|
2003-10-05 09:03:43 +00:00
|
|
|
return true;
|
2003-02-23 13:40:22 +00:00
|
|
|
|
2003-01-05 22:14:10 +00:00
|
|
|
}
|
|
|
|
|
2003-10-05 09:03:43 +00:00
|
|
|
bool FbWinFrame::hideHandle() {
|
2003-02-23 13:40:22 +00:00
|
|
|
if (!m_use_handle)
|
2003-10-05 09:03:43 +00:00
|
|
|
return false;
|
2003-01-05 22:14:10 +00:00
|
|
|
m_handle.hide();
|
2003-01-07 01:30:57 +00:00
|
|
|
m_grip_left.hide();
|
|
|
|
m_grip_right.hide();
|
|
|
|
m_use_handle = false;
|
2004-01-21 19:47:30 +00:00
|
|
|
|
|
|
|
if (static_cast<signed int>(m_window.height() - m_handle.height() -
|
2004-01-23 11:04:05 +00:00
|
|
|
m_handle.borderWidth()) <= 0) {
|
2004-01-21 19:47:30 +00:00
|
|
|
m_window.resize(m_window.width(), 1);
|
|
|
|
} else {
|
|
|
|
// only take away one borderwidth (as the other border is still the "top" border)
|
|
|
|
m_window.resize(m_window.width(), m_window.height() - m_handle.height() -
|
|
|
|
m_handle.borderWidth());
|
|
|
|
}
|
|
|
|
|
2003-10-05 09:03:43 +00:00
|
|
|
return true;
|
2003-02-23 13:40:22 +00:00
|
|
|
|
2003-01-05 22:14:10 +00:00
|
|
|
}
|
|
|
|
|
2003-10-05 09:03:43 +00:00
|
|
|
bool FbWinFrame::showHandle() {
|
2008-01-05 01:39:19 +00:00
|
|
|
if (m_use_handle || theme()->handleWidth() == 0)
|
2003-10-05 09:03:43 +00:00
|
|
|
return false;
|
2003-10-02 14:14:46 +00:00
|
|
|
|
2007-07-02 05:26:32 +00:00
|
|
|
m_use_handle = true;
|
|
|
|
|
2005-04-10 18:18:14 +00:00
|
|
|
// weren't previously rendered...
|
|
|
|
renderHandles();
|
2007-07-02 05:26:32 +00:00
|
|
|
applyHandles();
|
2004-01-23 10:38:25 +00:00
|
|
|
|
2003-01-05 22:14:10 +00:00
|
|
|
m_handle.show();
|
2003-10-02 14:14:46 +00:00
|
|
|
m_handle.showSubwindows(); // shows grips
|
|
|
|
|
2003-02-23 13:40:22 +00:00
|
|
|
m_window.resize(m_window.width(), m_window.height() + m_handle.height() +
|
|
|
|
m_handle.borderWidth());
|
2003-10-05 09:03:43 +00:00
|
|
|
return true;
|
2003-01-07 01:30:57 +00:00
|
|
|
}
|
|
|
|
|
2003-10-05 09:03:43 +00:00
|
|
|
bool FbWinFrame::hideAllDecorations() {
|
|
|
|
bool changed = false;
|
|
|
|
changed |= hideHandle();
|
|
|
|
changed |= hideTitlebar();
|
2003-02-23 13:40:22 +00:00
|
|
|
// resize done by hide*
|
2003-01-07 01:30:57 +00:00
|
|
|
reconfigure();
|
2003-10-05 09:03:43 +00:00
|
|
|
|
|
|
|
return changed;
|
2003-01-07 01:30:57 +00:00
|
|
|
}
|
|
|
|
|
2003-10-05 09:03:43 +00:00
|
|
|
bool FbWinFrame::showAllDecorations() {
|
|
|
|
bool changed = false;
|
2003-01-07 01:30:57 +00:00
|
|
|
if (!m_use_handle)
|
2003-10-05 09:03:43 +00:00
|
|
|
changed |= showHandle();
|
2003-01-07 01:30:57 +00:00
|
|
|
if (!m_use_titlebar)
|
2003-10-05 09:03:43 +00:00
|
|
|
changed |= showTitlebar();
|
2003-02-23 13:40:22 +00:00
|
|
|
// resize shouldn't be necessary
|
2003-02-22 18:31:00 +00:00
|
|
|
reconfigure();
|
2003-10-05 09:03:43 +00:00
|
|
|
|
|
|
|
return changed;
|
2003-01-05 22:14:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
Set new event handler for the frame's windows
|
|
|
|
*/
|
|
|
|
void FbWinFrame::setEventHandler(FbTk::EventHandler &evh) {
|
|
|
|
|
|
|
|
FbTk::EventManager &evm = *FbTk::EventManager::instance();
|
2005-06-19 12:12:54 +00:00
|
|
|
evm.add(evh, m_tab_container);
|
2006-03-20 11:31:24 +00:00
|
|
|
evm.add(evh, m_label);
|
2003-01-05 22:14:10 +00:00
|
|
|
evm.add(evh, m_titlebar);
|
|
|
|
evm.add(evh, m_handle);
|
|
|
|
evm.add(evh, m_grip_right);
|
|
|
|
evm.add(evh, m_grip_left);
|
|
|
|
evm.add(evh, m_window);
|
|
|
|
evm.add(evh, m_clientarea);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
remove event handler from windows
|
|
|
|
*/
|
|
|
|
void FbWinFrame::removeEventHandler() {
|
|
|
|
FbTk::EventManager &evm = *FbTk::EventManager::instance();
|
2005-06-19 12:12:54 +00:00
|
|
|
evm.remove(m_tab_container);
|
2006-03-20 11:31:24 +00:00
|
|
|
evm.remove(m_label);
|
2003-01-05 22:14:10 +00:00
|
|
|
evm.remove(m_titlebar);
|
|
|
|
evm.remove(m_handle);
|
|
|
|
evm.remove(m_grip_right);
|
|
|
|
evm.remove(m_grip_left);
|
|
|
|
evm.remove(m_window);
|
|
|
|
evm.remove(m_clientarea);
|
|
|
|
}
|
|
|
|
|
|
|
|
void FbWinFrame::exposeEvent(XExposeEvent &event) {
|
2004-01-10 00:37:35 +00:00
|
|
|
if (m_titlebar == event.window) {
|
|
|
|
m_titlebar.clearArea(event.x, event.y, event.width, event.height);
|
2005-06-19 12:12:54 +00:00
|
|
|
} else if (m_tab_container == event.window) {
|
|
|
|
m_tab_container.clearArea(event.x, event.y, event.width, event.height);
|
2006-03-20 11:31:24 +00:00
|
|
|
} else if (m_label == event.window) {
|
|
|
|
m_label.clearArea(event.x, event.y, event.width, event.height);
|
2003-09-12 22:49:14 +00:00
|
|
|
} else if (m_handle == event.window) {
|
2003-08-04 12:47:36 +00:00
|
|
|
m_handle.clearArea(event.x, event.y, event.width, event.height);
|
|
|
|
} else if (m_grip_left == event.window) {
|
|
|
|
m_grip_left.clearArea(event.x, event.y, event.width, event.height);
|
|
|
|
} else if (m_grip_right == event.window) {
|
|
|
|
m_grip_right.clearArea(event.x, event.y, event.width, event.height);
|
|
|
|
} else {
|
2005-06-19 12:12:54 +00:00
|
|
|
|
|
|
|
if (m_tab_container.tryExposeEvent(event))
|
|
|
|
return;
|
|
|
|
|
2003-08-24 11:19:45 +00:00
|
|
|
// create compare function
|
2006-10-27 06:57:43 +00:00
|
|
|
// that we should use with find_if
|
2004-02-27 12:20:01 +00:00
|
|
|
FbTk::CompareEqual_base<FbTk::FbWindow, Window> compare(&FbTk::FbWindow::window,
|
|
|
|
event.window);
|
2003-08-24 11:19:45 +00:00
|
|
|
|
|
|
|
ButtonList::iterator it = find_if(m_buttons_left.begin(),
|
|
|
|
m_buttons_left.end(),
|
|
|
|
compare);
|
|
|
|
if (it != m_buttons_left.end()) {
|
|
|
|
(*it)->exposeEvent(event);
|
|
|
|
return;
|
2003-08-04 12:47:36 +00:00
|
|
|
}
|
|
|
|
|
2003-08-24 11:19:45 +00:00
|
|
|
it = find_if(m_buttons_right.begin(),
|
|
|
|
m_buttons_right.end(),
|
|
|
|
compare);
|
2003-08-04 12:47:36 +00:00
|
|
|
|
2003-08-24 11:19:45 +00:00
|
|
|
if (it != m_buttons_right.end())
|
|
|
|
(*it)->exposeEvent(event);
|
|
|
|
}
|
2003-09-12 22:49:14 +00:00
|
|
|
|
2003-01-05 22:14:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void FbWinFrame::handleEvent(XEvent &event) {
|
2003-08-23 15:46:06 +00:00
|
|
|
if (event.type == ConfigureNotify && event.xconfigure.window == window().window())
|
2003-01-05 22:14:10 +00:00
|
|
|
configureNotifyEvent(event.xconfigure);
|
|
|
|
}
|
|
|
|
|
|
|
|
void FbWinFrame::configureNotifyEvent(XConfigureEvent &event) {
|
|
|
|
resize(event.width, event.height);
|
|
|
|
}
|
|
|
|
|
|
|
|
void FbWinFrame::reconfigure() {
|
2005-06-19 12:12:54 +00:00
|
|
|
if (m_tab_container.empty())
|
2003-09-12 22:49:14 +00:00
|
|
|
return;
|
2003-01-09 18:03:33 +00:00
|
|
|
|
2006-07-03 17:18:17 +00:00
|
|
|
int grav_x=0, grav_y=0;
|
|
|
|
// negate gravity
|
|
|
|
gravityTranslate(grav_x, grav_y, -m_active_gravity, m_active_orig_client_bw, false);
|
|
|
|
|
2008-01-05 01:39:19 +00:00
|
|
|
m_bevel = theme()->bevelWidth();
|
2004-01-23 10:38:25 +00:00
|
|
|
// reconfigure can't set borderwidth, as it doesn't know
|
|
|
|
// if it's meant to be borderless or not
|
|
|
|
|
|
|
|
unsigned int orig_handle_h = handle().height();
|
2008-01-05 01:39:19 +00:00
|
|
|
if (m_use_handle && orig_handle_h != theme()->handleWidth())
|
2004-01-23 10:38:25 +00:00
|
|
|
m_window.resize(m_window.width(), m_window.height() -
|
2008-01-05 01:39:19 +00:00
|
|
|
orig_handle_h + theme()->handleWidth());
|
2003-09-12 23:38:50 +00:00
|
|
|
|
2006-10-27 06:57:43 +00:00
|
|
|
handle().resize(handle().width(),
|
2008-01-05 01:39:19 +00:00
|
|
|
theme()->handleWidth());
|
2006-10-27 06:57:43 +00:00
|
|
|
gripLeft().resize(buttonHeight(),
|
2008-01-05 01:39:19 +00:00
|
|
|
theme()->handleWidth());
|
2006-10-27 06:57:43 +00:00
|
|
|
gripRight().resize(gripLeft().width(),
|
2003-09-12 23:38:50 +00:00
|
|
|
gripLeft().height());
|
|
|
|
|
2003-01-05 22:14:10 +00:00
|
|
|
// align titlebar and render it
|
2003-10-28 02:17:03 +00:00
|
|
|
if (m_use_titlebar) {
|
2003-01-07 01:30:57 +00:00
|
|
|
reconfigureTitlebar();
|
2003-10-28 02:17:03 +00:00
|
|
|
m_titlebar.raise();
|
2006-10-27 06:57:43 +00:00
|
|
|
} else
|
2003-10-28 02:17:03 +00:00
|
|
|
m_titlebar.lower();
|
|
|
|
|
2006-03-22 13:06:00 +00:00
|
|
|
if (m_tabmode == EXTERNAL) {
|
2006-03-26 04:02:30 +00:00
|
|
|
unsigned int neww, newh;
|
|
|
|
switch (m_screen.getTabPlacement()) {
|
|
|
|
case TOPLEFT:
|
|
|
|
case TOPRIGHT:
|
|
|
|
case BOTTOMLEFT:
|
|
|
|
case BOTTOMRIGHT:
|
|
|
|
neww = m_tab_container.width();
|
|
|
|
newh = buttonHeight();
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
neww = buttonHeight();
|
|
|
|
newh = m_tab_container.height();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
m_tab_container.resize(neww, newh);
|
2006-03-22 13:06:00 +00:00
|
|
|
alignTabs();
|
|
|
|
}
|
2003-02-20 23:21:23 +00:00
|
|
|
|
2003-04-03 22:37:43 +00:00
|
|
|
// leave client+grips alone if we're shaded (it'll get fixed when we unshade)
|
|
|
|
if (!m_shaded) {
|
|
|
|
int client_top = 0;
|
|
|
|
int client_height = m_window.height();
|
|
|
|
if (m_use_titlebar) {
|
|
|
|
// only one borderwidth as titlebar is really at -borderwidth
|
|
|
|
int titlebar_height = m_titlebar.height() + m_titlebar.borderWidth();
|
|
|
|
client_top += titlebar_height;
|
|
|
|
client_height -= titlebar_height;
|
|
|
|
}
|
2006-10-27 06:57:43 +00:00
|
|
|
|
2004-01-23 10:38:25 +00:00
|
|
|
// align handle and grips
|
|
|
|
const int grip_height = m_handle.height();
|
|
|
|
const int grip_width = 20; //TODO
|
|
|
|
const int handle_bw = static_cast<signed>(m_handle.borderWidth());
|
2003-10-02 14:14:46 +00:00
|
|
|
|
2004-01-23 10:38:25 +00:00
|
|
|
int ypos = m_window.height();
|
2004-01-02 13:26:44 +00:00
|
|
|
|
2004-01-23 10:38:25 +00:00
|
|
|
// if the handle isn't on, it's actually below the window
|
|
|
|
if (m_use_handle)
|
|
|
|
ypos -= grip_height + handle_bw;
|
|
|
|
|
|
|
|
// we do handle settings whether on or not so that if they get toggled
|
|
|
|
// then things are ok...
|
2006-06-24 14:05:19 +00:00
|
|
|
m_handle.invalidateBackground();
|
2004-01-23 10:38:25 +00:00
|
|
|
m_handle.moveResize(-handle_bw, ypos,
|
|
|
|
m_window.width(), grip_height);
|
|
|
|
|
2006-06-24 14:05:19 +00:00
|
|
|
m_grip_left.invalidateBackground();
|
2004-01-23 10:38:25 +00:00
|
|
|
m_grip_left.moveResize(-handle_bw, -handle_bw,
|
|
|
|
grip_width, grip_height);
|
|
|
|
|
2006-06-24 14:05:19 +00:00
|
|
|
m_grip_right.invalidateBackground();
|
2004-01-23 10:38:25 +00:00
|
|
|
m_grip_right.moveResize(m_handle.width() - grip_width - handle_bw, -handle_bw,
|
|
|
|
grip_width, grip_height);
|
2004-01-02 13:26:44 +00:00
|
|
|
|
2004-01-23 10:38:25 +00:00
|
|
|
if (m_use_handle) {
|
|
|
|
m_handle.raise();
|
|
|
|
client_height -= m_handle.height() + m_handle.borderWidth();
|
2003-10-28 02:17:03 +00:00
|
|
|
} else {
|
|
|
|
m_handle.lower();
|
2003-04-16 10:56:37 +00:00
|
|
|
}
|
2004-01-02 13:26:44 +00:00
|
|
|
|
|
|
|
m_clientarea.moveResize(0, client_top,
|
|
|
|
m_window.width(), client_height);
|
2003-10-28 02:17:03 +00:00
|
|
|
}
|
|
|
|
|
2006-07-03 17:18:17 +00:00
|
|
|
gravityTranslate(grav_x, grav_y, m_active_gravity, m_active_orig_client_bw, false);
|
|
|
|
// if the location changes, shift it
|
|
|
|
if (grav_x != 0 || grav_y != 0)
|
|
|
|
move(grav_x + x(), grav_y + y());
|
2003-01-05 22:14:10 +00:00
|
|
|
|
|
|
|
// render the theme
|
2005-04-13 14:39:25 +00:00
|
|
|
if (isVisible()) {
|
2007-01-06 19:03:33 +00:00
|
|
|
// update transparency settings
|
|
|
|
if (FbTk::Transparent::haveRender()) {
|
|
|
|
unsigned char alpha =
|
2007-01-07 11:55:14 +00:00
|
|
|
getAlpha(m_focused);
|
2007-01-06 19:03:33 +00:00
|
|
|
if (FbTk::Transparent::haveComposite()) {
|
|
|
|
m_tab_container.setAlpha(255);
|
|
|
|
m_window.setOpaque(alpha);
|
|
|
|
} else {
|
|
|
|
m_tab_container.setAlpha(alpha);
|
|
|
|
m_window.setOpaque(255);
|
|
|
|
}
|
|
|
|
}
|
2005-04-13 14:39:25 +00:00
|
|
|
renderAll();
|
|
|
|
applyAll();
|
|
|
|
clearAll();
|
|
|
|
} else {
|
|
|
|
m_need_render = true;
|
|
|
|
}
|
2003-07-10 11:36:21 +00:00
|
|
|
|
2007-08-09 03:45:31 +00:00
|
|
|
if (m_disable_themeshape)
|
2007-12-28 06:52:48 +00:00
|
|
|
m_shape.setPlaces(FbTk::Shape::NONE);
|
2007-08-09 03:45:31 +00:00
|
|
|
else
|
2008-01-05 01:39:19 +00:00
|
|
|
m_shape.setPlaces(theme()->shapePlace());
|
2003-07-10 11:36:21 +00:00
|
|
|
|
2007-08-09 03:45:31 +00:00
|
|
|
m_shape.setShapeOffsets(0, titlebarHeight());
|
2003-07-10 11:36:21 +00:00
|
|
|
|
2003-05-01 13:19:36 +00:00
|
|
|
// titlebar stuff rendered already by reconftitlebar
|
2003-01-05 22:14:10 +00:00
|
|
|
}
|
|
|
|
|
2003-08-24 15:39:52 +00:00
|
|
|
void FbWinFrame::setUseShape(bool value) {
|
2007-08-09 03:45:31 +00:00
|
|
|
m_disable_themeshape = !value;
|
|
|
|
|
|
|
|
if (m_disable_themeshape)
|
2007-12-28 06:52:48 +00:00
|
|
|
m_shape.setPlaces(FbTk::Shape::NONE);
|
2007-08-09 03:45:31 +00:00
|
|
|
else
|
2008-01-05 01:39:19 +00:00
|
|
|
m_shape.setPlaces(theme()->shapePlace());
|
2007-08-09 03:45:31 +00:00
|
|
|
|
|
|
|
}
|
2003-08-24 15:39:52 +00:00
|
|
|
|
2007-08-09 03:45:31 +00:00
|
|
|
void FbWinFrame::setShapingClient(FbTk::FbWindow *win, bool always_update) {
|
|
|
|
m_shape.setShapeSource(win, 0, titlebarHeight(), always_update);
|
2003-08-24 15:39:52 +00:00
|
|
|
}
|
|
|
|
|
2003-01-05 22:14:10 +00:00
|
|
|
unsigned int FbWinFrame::buttonHeight() const {
|
|
|
|
return m_titlebar.height() - m_bevel*2;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------- private area
|
|
|
|
|
|
|
|
/**
|
|
|
|
aligns and redraws title
|
|
|
|
*/
|
2005-04-26 01:41:55 +00:00
|
|
|
void FbWinFrame::redrawTitlebar() {
|
2005-06-19 12:12:54 +00:00
|
|
|
if (!m_use_titlebar || m_tab_container.empty())
|
2003-04-14 15:01:55 +00:00
|
|
|
return;
|
|
|
|
|
2004-02-27 12:20:01 +00:00
|
|
|
if (isVisible()) {
|
2005-06-19 12:12:54 +00:00
|
|
|
m_tab_container.clear();
|
2006-03-20 11:31:24 +00:00
|
|
|
m_label.clear();
|
2003-10-09 16:48:09 +00:00
|
|
|
m_titlebar.clear();
|
2003-04-14 15:01:55 +00:00
|
|
|
}
|
2003-01-05 22:14:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
Align buttons with title text window
|
|
|
|
*/
|
|
|
|
void FbWinFrame::reconfigureTitlebar() {
|
2003-02-20 23:21:23 +00:00
|
|
|
if (!m_use_titlebar)
|
|
|
|
return;
|
|
|
|
|
2003-10-05 09:03:43 +00:00
|
|
|
int orig_height = m_titlebar.height();
|
2003-01-05 22:14:10 +00:00
|
|
|
// resize titlebar to window size with font height
|
2008-01-05 01:39:19 +00:00
|
|
|
int title_height = theme()->font().height() == 0 ? 16 :
|
|
|
|
theme()->font().height() + m_bevel*2 + 2;
|
|
|
|
if (theme()->titleHeight() != 0)
|
|
|
|
title_height = theme()->titleHeight();
|
2003-08-22 15:20:32 +00:00
|
|
|
|
2003-10-05 09:03:43 +00:00
|
|
|
// if the titlebar grows in size, make sure the whole window does too
|
2006-10-27 06:57:43 +00:00
|
|
|
if (orig_height != title_height)
|
2003-10-05 09:03:43 +00:00
|
|
|
m_window.resize(m_window.width(), m_window.height()-orig_height+title_height);
|
2006-06-24 14:05:19 +00:00
|
|
|
m_titlebar.invalidateBackground();
|
2003-02-17 22:45:42 +00:00
|
|
|
m_titlebar.moveResize(-m_titlebar.borderWidth(), -m_titlebar.borderWidth(),
|
2003-08-22 15:20:32 +00:00
|
|
|
m_window.width(), title_height);
|
2003-01-05 22:14:10 +00:00
|
|
|
|
|
|
|
// draw left buttons first
|
2006-10-27 06:57:43 +00:00
|
|
|
unsigned int next_x = m_bevel;
|
2003-01-05 22:14:10 +00:00
|
|
|
unsigned int button_size = buttonHeight();
|
|
|
|
m_button_size = button_size;
|
|
|
|
for (size_t i=0; i < m_buttons_left.size(); i++, next_x += button_size + m_bevel) {
|
2006-06-24 14:05:19 +00:00
|
|
|
// probably on theme reconfigure, leave bg alone for now
|
|
|
|
m_buttons_left[i]->invalidateBackground();
|
2006-10-27 06:57:43 +00:00
|
|
|
m_buttons_left[i]->moveResize(next_x, m_bevel,
|
2003-01-05 22:14:10 +00:00
|
|
|
button_size, button_size);
|
|
|
|
}
|
2006-10-27 06:57:43 +00:00
|
|
|
|
2003-01-05 22:14:10 +00:00
|
|
|
next_x += m_bevel;
|
2005-04-10 18:18:14 +00:00
|
|
|
|
2003-01-05 22:14:10 +00:00
|
|
|
// space left on titlebar between left and right buttons
|
2006-03-20 11:31:24 +00:00
|
|
|
int space_left = m_titlebar.width() - next_x;
|
|
|
|
|
2006-10-27 06:57:43 +00:00
|
|
|
if (!m_buttons_right.empty())
|
2003-02-17 22:45:42 +00:00
|
|
|
space_left -= m_buttons_right.size() * (button_size + m_bevel);
|
|
|
|
|
2003-01-05 22:14:10 +00:00
|
|
|
space_left -= m_bevel;
|
|
|
|
|
2006-03-20 11:31:24 +00:00
|
|
|
if (space_left <= 0)
|
|
|
|
space_left = 1;
|
|
|
|
|
2006-06-24 14:05:19 +00:00
|
|
|
m_label.invalidateBackground();
|
2006-03-20 11:31:24 +00:00
|
|
|
m_label.moveResize(next_x, m_bevel, space_left, button_size);
|
|
|
|
|
2006-06-24 14:05:19 +00:00
|
|
|
m_tab_container.invalidateBackground();
|
2006-03-20 11:31:24 +00:00
|
|
|
if (m_tabmode == INTERNAL)
|
|
|
|
m_tab_container.moveResize(next_x, m_bevel,
|
|
|
|
space_left, button_size);
|
2006-04-04 12:16:26 +00:00
|
|
|
else {
|
|
|
|
if (m_use_tabs) {
|
|
|
|
if (m_tab_container.orientation() == FbTk::ROT0) {
|
|
|
|
m_tab_container.resize(m_tab_container.width(), button_size);
|
|
|
|
} else {
|
|
|
|
m_tab_container.resize(button_size, m_tab_container.height());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2006-03-20 11:31:24 +00:00
|
|
|
|
|
|
|
next_x += m_label.width() + m_bevel;
|
2003-01-05 22:14:10 +00:00
|
|
|
|
|
|
|
// finaly set new buttons to the right
|
2006-10-27 06:57:43 +00:00
|
|
|
for (size_t i=0; i < m_buttons_right.size();
|
2003-01-05 22:14:10 +00:00
|
|
|
++i, next_x += button_size + m_bevel) {
|
2006-06-24 14:05:19 +00:00
|
|
|
m_buttons_right[i]->invalidateBackground();
|
2003-01-05 22:14:10 +00:00
|
|
|
m_buttons_right[i]->moveResize(next_x, m_bevel,
|
|
|
|
button_size, button_size);
|
|
|
|
}
|
|
|
|
|
|
|
|
m_titlebar.raise(); // always on top
|
|
|
|
}
|
|
|
|
|
2005-04-10 18:18:14 +00:00
|
|
|
void FbWinFrame::renderAll() {
|
|
|
|
m_need_render = false;
|
|
|
|
|
|
|
|
renderTitlebar();
|
|
|
|
renderHandles();
|
2006-03-20 11:31:24 +00:00
|
|
|
renderTabContainer();
|
2005-04-10 18:18:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void FbWinFrame::applyAll() {
|
|
|
|
applyTitlebar();
|
|
|
|
applyHandles();
|
2006-03-20 11:31:24 +00:00
|
|
|
applyTabContainer();
|
2005-04-10 18:18:14 +00:00
|
|
|
}
|
|
|
|
|
2003-01-05 22:14:10 +00:00
|
|
|
void FbWinFrame::renderTitlebar() {
|
2003-09-12 22:49:14 +00:00
|
|
|
if (!m_use_titlebar)
|
2003-01-05 22:14:10 +00:00
|
|
|
return;
|
|
|
|
|
2005-04-10 18:18:14 +00:00
|
|
|
if (!isVisible()) {
|
|
|
|
m_need_render = true;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2003-01-05 22:14:10 +00:00
|
|
|
// render pixmaps
|
2008-01-05 01:39:19 +00:00
|
|
|
render(theme()->titleFocusTexture(), m_title_focused_color,
|
2003-01-05 22:14:10 +00:00
|
|
|
m_title_focused_pm,
|
|
|
|
m_titlebar.width(), m_titlebar.height());
|
|
|
|
|
2008-01-05 01:39:19 +00:00
|
|
|
render(theme()->titleUnfocusTexture(), m_title_unfocused_color,
|
2003-01-05 22:14:10 +00:00
|
|
|
m_title_unfocused_pm,
|
|
|
|
m_titlebar.width(), m_titlebar.height());
|
|
|
|
|
2006-03-20 11:31:24 +00:00
|
|
|
//!! TODO: don't render label if internal tabs
|
|
|
|
|
2008-01-05 01:39:19 +00:00
|
|
|
render(theme()->iconbarTheme()->focusedTexture(), m_label_focused_color,
|
2003-01-05 22:14:10 +00:00
|
|
|
m_label_focused_pm,
|
2006-03-20 11:31:24 +00:00
|
|
|
m_label.width(), m_label.height());
|
2004-01-02 13:26:44 +00:00
|
|
|
|
2008-01-05 01:39:19 +00:00
|
|
|
render(theme()->iconbarTheme()->unfocusedTexture(), m_label_unfocused_color,
|
2003-01-05 22:14:10 +00:00
|
|
|
m_label_unfocused_pm,
|
2006-03-20 11:31:24 +00:00
|
|
|
m_label.width(), m_label.height());
|
2003-01-05 22:14:10 +00:00
|
|
|
|
2005-04-10 18:18:14 +00:00
|
|
|
}
|
2003-12-09 08:48:08 +00:00
|
|
|
|
2006-03-20 11:31:24 +00:00
|
|
|
void FbWinFrame::renderTabContainer() {
|
|
|
|
if (!isVisible()) {
|
|
|
|
m_need_render = true;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-01-05 01:39:19 +00:00
|
|
|
const FbTk::Texture *tc_focused = &theme()->iconbarTheme()->focusedTexture();
|
|
|
|
const FbTk::Texture *tc_unfocused = &theme()->iconbarTheme()->unfocusedTexture();
|
2006-05-20 16:27:25 +00:00
|
|
|
|
|
|
|
if (m_tabmode == EXTERNAL && tc_focused->type() & FbTk::Texture::PARENTRELATIVE)
|
2008-01-05 01:39:19 +00:00
|
|
|
tc_focused = &theme()->titleFocusTexture();
|
2006-05-20 16:27:25 +00:00
|
|
|
if (m_tabmode == EXTERNAL && tc_unfocused->type() & FbTk::Texture::PARENTRELATIVE)
|
2008-01-05 01:39:19 +00:00
|
|
|
tc_unfocused = &theme()->titleUnfocusTexture();
|
2006-05-20 16:27:25 +00:00
|
|
|
|
2006-10-27 06:57:43 +00:00
|
|
|
render(*tc_focused, m_tabcontainer_focused_color,
|
2006-03-20 11:31:24 +00:00
|
|
|
m_tabcontainer_focused_pm,
|
2006-03-26 04:02:30 +00:00
|
|
|
m_tab_container.width(), m_tab_container.height(), m_tab_container.orientation());
|
2006-03-20 11:31:24 +00:00
|
|
|
|
2006-10-27 06:57:43 +00:00
|
|
|
render(*tc_unfocused, m_tabcontainer_unfocused_color,
|
2006-03-20 11:31:24 +00:00
|
|
|
m_tabcontainer_unfocused_pm,
|
2006-03-26 04:02:30 +00:00
|
|
|
m_tab_container.width(), m_tab_container.height(), m_tab_container.orientation());
|
2006-03-20 11:31:24 +00:00
|
|
|
|
2006-06-25 14:59:34 +00:00
|
|
|
renderButtons();
|
|
|
|
|
2006-03-20 11:31:24 +00:00
|
|
|
}
|
|
|
|
|
2005-04-10 18:18:14 +00:00
|
|
|
void FbWinFrame::applyTitlebar() {
|
2003-12-09 08:48:08 +00:00
|
|
|
|
2005-04-10 18:18:14 +00:00
|
|
|
// set up pixmaps for titlebar windows
|
2003-04-16 12:27:49 +00:00
|
|
|
Pixmap label_pm = None;
|
2006-10-27 06:57:43 +00:00
|
|
|
Pixmap title_pm = None;
|
2003-04-16 12:27:49 +00:00
|
|
|
FbTk::Color label_color;
|
|
|
|
FbTk::Color title_color;
|
|
|
|
getCurrentFocusPixmap(label_pm, title_pm,
|
|
|
|
label_color, title_color);
|
|
|
|
|
2007-01-07 11:55:14 +00:00
|
|
|
unsigned char alpha = getAlpha (m_focused);
|
2005-04-10 18:18:14 +00:00
|
|
|
m_titlebar.setAlpha(alpha);
|
2006-03-20 11:31:24 +00:00
|
|
|
m_label.setAlpha(alpha);
|
2005-04-10 18:18:14 +00:00
|
|
|
|
2006-04-17 14:24:11 +00:00
|
|
|
if (m_tabmode != INTERNAL) {
|
2007-10-13 21:51:37 +00:00
|
|
|
m_label.setGC(m_focused ?
|
2008-01-05 01:39:19 +00:00
|
|
|
theme()->iconbarTheme()->focusedText().textGC() :
|
|
|
|
theme()->iconbarTheme()->unfocusedText().textGC());
|
2007-10-13 21:51:37 +00:00
|
|
|
m_label.setJustify(m_focused ?
|
2008-01-05 01:39:19 +00:00
|
|
|
theme()->iconbarTheme()->focusedText().justify() :
|
|
|
|
theme()->iconbarTheme()->unfocusedText().justify());
|
2006-03-22 12:23:17 +00:00
|
|
|
|
2006-03-26 12:32:15 +00:00
|
|
|
if (label_pm != 0)
|
|
|
|
m_label.setBackgroundPixmap(label_pm);
|
|
|
|
else
|
|
|
|
m_label.setBackgroundColor(label_color);
|
|
|
|
}
|
2006-03-20 11:31:24 +00:00
|
|
|
|
2003-04-16 12:27:49 +00:00
|
|
|
if (title_pm != 0)
|
|
|
|
m_titlebar.setBackgroundPixmap(title_pm);
|
|
|
|
else
|
|
|
|
m_titlebar.setBackgroundColor(title_color);
|
2003-01-05 22:14:10 +00:00
|
|
|
|
2005-04-10 18:18:14 +00:00
|
|
|
applyButtons();
|
2003-01-05 22:14:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void FbWinFrame::renderHandles() {
|
2003-10-06 09:28:35 +00:00
|
|
|
if (!m_use_handle)
|
2003-01-05 22:14:10 +00:00
|
|
|
return;
|
2003-06-23 14:18:54 +00:00
|
|
|
|
2005-04-10 18:18:14 +00:00
|
|
|
if (!isVisible()) {
|
|
|
|
m_need_render = true;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-01-05 01:39:19 +00:00
|
|
|
render(theme()->handleFocusTexture(), m_handle_focused_color,
|
2003-01-05 22:14:10 +00:00
|
|
|
m_handle_focused_pm,
|
|
|
|
m_handle.width(), m_handle.height());
|
2006-10-27 06:57:43 +00:00
|
|
|
|
2008-01-05 01:39:19 +00:00
|
|
|
render(theme()->handleUnfocusTexture(), m_handle_unfocused_color,
|
2003-01-05 22:14:10 +00:00
|
|
|
m_handle_unfocused_pm,
|
|
|
|
m_handle.width(), m_handle.height());
|
|
|
|
|
2008-01-05 01:39:19 +00:00
|
|
|
render(theme()->gripFocusTexture(), m_grip_focused_color, m_grip_focused_pm,
|
2003-01-05 22:14:10 +00:00
|
|
|
m_grip_left.width(), m_grip_left.height());
|
|
|
|
|
2008-01-05 01:39:19 +00:00
|
|
|
render(theme()->gripUnfocusTexture(), m_grip_unfocused_color,
|
2003-01-05 22:14:10 +00:00
|
|
|
m_grip_unfocused_pm,
|
|
|
|
m_grip_left.width(), m_grip_left.height());
|
|
|
|
|
2005-04-10 18:18:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void FbWinFrame::applyHandles() {
|
|
|
|
|
2007-01-07 11:55:14 +00:00
|
|
|
unsigned char alpha = getAlpha (m_focused);
|
2005-04-10 18:18:14 +00:00
|
|
|
m_handle.setAlpha(alpha);
|
|
|
|
m_grip_left.setAlpha(alpha);
|
|
|
|
m_grip_right.setAlpha(alpha);
|
|
|
|
|
2003-01-05 22:14:10 +00:00
|
|
|
if (m_focused) {
|
2005-04-10 18:18:14 +00:00
|
|
|
|
|
|
|
if (m_handle_focused_pm) {
|
|
|
|
m_handle.setBackgroundPixmap(m_handle_focused_pm);
|
|
|
|
} else {
|
|
|
|
m_handle.setBackgroundColor(m_handle_focused_color);
|
|
|
|
}
|
|
|
|
|
2003-01-05 22:14:10 +00:00
|
|
|
if (m_grip_focused_pm) {
|
|
|
|
m_grip_left.setBackgroundPixmap(m_grip_focused_pm);
|
|
|
|
m_grip_right.setBackgroundPixmap(m_grip_focused_pm);
|
|
|
|
} else {
|
|
|
|
m_grip_left.setBackgroundColor(m_grip_focused_color);
|
|
|
|
m_grip_right.setBackgroundColor(m_grip_focused_color);
|
2006-10-27 06:57:43 +00:00
|
|
|
}
|
2005-04-10 18:18:14 +00:00
|
|
|
|
2003-01-05 22:14:10 +00:00
|
|
|
} else {
|
2005-04-10 18:18:14 +00:00
|
|
|
|
|
|
|
if (m_handle_unfocused_pm) {
|
|
|
|
m_handle.setBackgroundPixmap(m_handle_unfocused_pm);
|
|
|
|
} else {
|
|
|
|
m_handle.setBackgroundColor(m_handle_unfocused_color);
|
2006-10-27 06:57:43 +00:00
|
|
|
}
|
2005-04-10 18:18:14 +00:00
|
|
|
|
2003-01-05 22:14:10 +00:00
|
|
|
if (m_grip_unfocused_pm) {
|
|
|
|
m_grip_left.setBackgroundPixmap(m_grip_unfocused_pm);
|
|
|
|
m_grip_right.setBackgroundPixmap(m_grip_unfocused_pm);
|
|
|
|
} else {
|
|
|
|
m_grip_left.setBackgroundColor(m_grip_unfocused_color);
|
|
|
|
m_grip_right.setBackgroundColor(m_grip_unfocused_color);
|
2006-10-27 06:57:43 +00:00
|
|
|
}
|
2003-01-05 22:14:10 +00:00
|
|
|
}
|
2003-08-04 12:47:36 +00:00
|
|
|
|
2003-01-05 22:14:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void FbWinFrame::renderButtons() {
|
|
|
|
|
2005-04-10 18:18:14 +00:00
|
|
|
if (!isVisible()) {
|
|
|
|
m_need_render = true;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-01-05 01:39:19 +00:00
|
|
|
render(theme()->buttonFocusTexture(), m_button_color,
|
2005-04-10 18:18:14 +00:00
|
|
|
m_button_pm,
|
2003-01-05 22:14:10 +00:00
|
|
|
m_button_size, m_button_size);
|
2003-09-14 10:32:31 +00:00
|
|
|
|
2008-01-05 01:39:19 +00:00
|
|
|
render(theme()->buttonUnfocusTexture(), m_button_unfocused_color,
|
2003-01-05 22:14:10 +00:00
|
|
|
m_button_unfocused_pm,
|
|
|
|
m_button_size, m_button_size);
|
2006-10-27 06:57:43 +00:00
|
|
|
|
2008-01-05 01:39:19 +00:00
|
|
|
render(theme()->buttonPressedTexture(), m_button_pressed_color,
|
2003-01-05 22:14:10 +00:00
|
|
|
m_button_pressed_pm,
|
|
|
|
m_button_size, m_button_size);
|
2005-04-10 18:18:14 +00:00
|
|
|
}
|
2003-01-05 22:14:10 +00:00
|
|
|
|
2005-04-10 18:18:14 +00:00
|
|
|
void FbWinFrame::applyButtons() {
|
2003-01-05 22:14:10 +00:00
|
|
|
// setup left and right buttons
|
2004-02-27 12:20:01 +00:00
|
|
|
for (size_t i=0; i < m_buttons_left.size(); ++i)
|
2005-04-10 18:18:14 +00:00
|
|
|
applyButton(*m_buttons_left[i]);
|
2003-01-05 22:14:10 +00:00
|
|
|
|
2004-02-27 12:20:01 +00:00
|
|
|
for (size_t i=0; i < m_buttons_right.size(); ++i)
|
2005-04-10 18:18:14 +00:00
|
|
|
applyButton(*m_buttons_right[i]);
|
2003-01-05 22:14:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void FbWinFrame::init() {
|
2004-01-02 13:26:44 +00:00
|
|
|
|
2008-01-05 01:39:19 +00:00
|
|
|
if (theme()->handleWidth() == 0)
|
2003-10-30 20:27:51 +00:00
|
|
|
m_use_handle = false;
|
|
|
|
|
2007-08-09 03:45:31 +00:00
|
|
|
m_disable_themeshape = false;
|
2003-08-24 15:39:52 +00:00
|
|
|
|
2003-10-02 14:14:46 +00:00
|
|
|
m_handle.showSubwindows();
|
|
|
|
|
2003-06-23 14:18:54 +00:00
|
|
|
// clear pixmaps
|
2003-01-05 22:14:10 +00:00
|
|
|
m_title_focused_pm = m_title_unfocused_pm = 0;
|
2005-04-10 18:18:14 +00:00
|
|
|
m_label_focused_pm = m_label_unfocused_pm = 0;
|
2006-03-20 11:31:24 +00:00
|
|
|
m_tabcontainer_focused_pm = m_tabcontainer_unfocused_pm = 0;
|
2003-06-23 14:18:54 +00:00
|
|
|
m_handle_focused_pm = m_handle_unfocused_pm = 0;
|
|
|
|
m_button_pm = m_button_unfocused_pm = m_button_pressed_pm = 0;
|
|
|
|
m_grip_unfocused_pm = m_grip_focused_pm = 0;
|
|
|
|
|
2003-01-05 22:14:10 +00:00
|
|
|
m_button_size = 26;
|
2003-06-23 14:18:54 +00:00
|
|
|
|
2003-04-16 22:15:22 +00:00
|
|
|
m_clientarea.setBorderWidth(0);
|
2006-03-20 11:31:24 +00:00
|
|
|
m_label.setBorderWidth(0);
|
2003-01-05 22:14:10 +00:00
|
|
|
m_shaded = false;
|
2006-03-20 11:31:24 +00:00
|
|
|
|
2006-03-22 13:06:00 +00:00
|
|
|
setTabMode(NOTSET);
|
2006-03-20 11:31:24 +00:00
|
|
|
|
|
|
|
m_label.setEventMask(ExposureMask | ButtonPressMask |
|
|
|
|
ButtonReleaseMask | ButtonMotionMask |
|
|
|
|
EnterWindowMask);
|
2003-01-07 01:30:57 +00:00
|
|
|
|
2003-01-09 18:03:33 +00:00
|
|
|
showHandle();
|
2003-01-07 01:30:57 +00:00
|
|
|
showTitlebar();
|
2003-01-09 18:03:33 +00:00
|
|
|
|
2003-06-23 14:18:54 +00:00
|
|
|
// Note: we don't show clientarea yet
|
2003-01-05 22:14:10 +00:00
|
|
|
|
|
|
|
setEventHandler(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
Setups upp background, pressed pixmap/color of the button to current theme
|
|
|
|
*/
|
2005-04-10 18:18:14 +00:00
|
|
|
void FbWinFrame::applyButton(FbTk::Button &btn) {
|
2003-09-14 10:32:31 +00:00
|
|
|
if (m_button_pressed_pm)
|
2003-01-05 22:14:10 +00:00
|
|
|
btn.setPressedPixmap(m_button_pressed_pm);
|
2005-04-10 18:18:14 +00:00
|
|
|
else
|
|
|
|
btn.setPressedColor(m_button_pressed_color);
|
2003-01-05 22:14:10 +00:00
|
|
|
|
2003-09-14 10:32:31 +00:00
|
|
|
if (focused()) { // focused
|
2007-01-07 11:55:14 +00:00
|
|
|
btn.setAlpha(getAlpha(true));
|
2005-04-10 18:18:14 +00:00
|
|
|
|
2008-01-05 01:39:19 +00:00
|
|
|
btn.setGC(theme()->buttonPicFocusGC());
|
2003-01-05 22:14:10 +00:00
|
|
|
if (m_button_pm)
|
|
|
|
btn.setBackgroundPixmap(m_button_pm);
|
|
|
|
else
|
|
|
|
btn.setBackgroundColor(m_button_color);
|
2003-09-14 10:32:31 +00:00
|
|
|
} else { // unfocused
|
2007-01-07 11:55:14 +00:00
|
|
|
btn.setAlpha(getAlpha(false));
|
2005-04-10 18:18:14 +00:00
|
|
|
|
2008-01-05 01:39:19 +00:00
|
|
|
btn.setGC(theme()->buttonPicUnfocusGC());
|
2003-01-05 22:14:10 +00:00
|
|
|
if (m_button_unfocused_pm)
|
|
|
|
btn.setBackgroundPixmap(m_button_unfocused_pm);
|
|
|
|
else
|
2003-09-14 10:32:31 +00:00
|
|
|
btn.setBackgroundColor(m_button_unfocused_color);
|
2003-01-05 22:14:10 +00:00
|
|
|
}
|
2003-08-04 12:47:36 +00:00
|
|
|
|
2003-01-05 22:14:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void FbWinFrame::render(const FbTk::Texture &tex, FbTk::Color &col, Pixmap &pm,
|
2006-03-26 04:02:30 +00:00
|
|
|
unsigned int w, unsigned int h, FbTk::Orientation orient) {
|
2003-10-09 16:48:09 +00:00
|
|
|
|
2003-01-05 22:14:10 +00:00
|
|
|
Pixmap tmp = pm;
|
2003-12-07 16:39:43 +00:00
|
|
|
if (!tex.usePixmap()) {
|
2003-01-05 22:14:10 +00:00
|
|
|
pm = None;
|
|
|
|
col = tex.color();
|
2004-01-02 13:26:44 +00:00
|
|
|
} else {
|
2006-03-26 04:02:30 +00:00
|
|
|
pm = m_imagectrl.renderImage(w, h, tex, orient);
|
2004-01-02 13:26:44 +00:00
|
|
|
}
|
2003-06-23 14:18:54 +00:00
|
|
|
|
2006-10-27 06:57:43 +00:00
|
|
|
if (tmp)
|
2003-01-05 22:14:10 +00:00
|
|
|
m_imagectrl.removeImage(tmp);
|
|
|
|
|
|
|
|
}
|
2003-04-16 12:27:49 +00:00
|
|
|
|
|
|
|
void FbWinFrame::getCurrentFocusPixmap(Pixmap &label_pm, Pixmap &title_pm,
|
2003-08-13 09:34:40 +00:00
|
|
|
FbTk::Color &label_color, FbTk::Color &title_color) {
|
2003-04-16 12:27:49 +00:00
|
|
|
if (m_focused) {
|
2006-03-20 11:31:24 +00:00
|
|
|
if (m_label_focused_pm != 0)
|
|
|
|
label_pm = m_label_focused_pm;
|
2003-04-16 12:27:49 +00:00
|
|
|
else
|
2006-03-20 11:31:24 +00:00
|
|
|
label_color = m_label_focused_color;
|
2006-10-27 06:57:43 +00:00
|
|
|
|
2003-04-16 12:27:49 +00:00
|
|
|
if (m_title_focused_pm != 0)
|
|
|
|
title_pm = m_title_focused_pm;
|
|
|
|
else
|
|
|
|
title_color = m_title_focused_color;
|
|
|
|
} else {
|
2006-03-20 11:31:24 +00:00
|
|
|
if (m_label_unfocused_pm != 0)
|
|
|
|
label_pm = m_label_unfocused_pm;
|
|
|
|
else
|
|
|
|
label_color = m_label_unfocused_color;
|
2006-10-27 06:57:43 +00:00
|
|
|
|
2006-03-20 11:31:24 +00:00
|
|
|
if (m_title_unfocused_pm != 0)
|
|
|
|
title_pm = m_title_unfocused_pm;
|
|
|
|
else
|
|
|
|
title_color = m_title_unfocused_color;
|
2006-10-27 06:57:43 +00:00
|
|
|
}
|
2003-04-16 12:27:49 +00:00
|
|
|
}
|
|
|
|
|
2006-03-20 11:31:24 +00:00
|
|
|
void FbWinFrame::applyTabContainer() {
|
2007-01-07 11:55:14 +00:00
|
|
|
m_tab_container.setAlpha(getAlpha(m_focused));
|
2003-04-16 12:27:49 +00:00
|
|
|
|
2006-03-20 11:31:24 +00:00
|
|
|
// do the parent container
|
|
|
|
Pixmap tabcontainer_pm = None;
|
|
|
|
FbTk::Color *tabcontainer_color = NULL;
|
|
|
|
if (m_focused) {
|
|
|
|
if (m_tabcontainer_focused_pm != 0)
|
|
|
|
tabcontainer_pm = m_tabcontainer_focused_pm;
|
|
|
|
else
|
|
|
|
tabcontainer_color = &m_tabcontainer_focused_color;
|
|
|
|
} else {
|
|
|
|
if (m_tabcontainer_unfocused_pm != 0)
|
|
|
|
tabcontainer_pm = m_tabcontainer_unfocused_pm;
|
|
|
|
else
|
|
|
|
tabcontainer_color = &m_tabcontainer_unfocused_color;
|
2005-04-10 18:18:14 +00:00
|
|
|
}
|
2003-10-09 16:48:09 +00:00
|
|
|
|
2006-03-20 11:31:24 +00:00
|
|
|
if (tabcontainer_pm != 0)
|
|
|
|
m_tab_container.setBackgroundPixmap(tabcontainer_pm);
|
|
|
|
else
|
|
|
|
m_tab_container.setBackgroundColor(*tabcontainer_color);
|
2003-04-16 12:27:49 +00:00
|
|
|
|
2006-03-20 11:31:24 +00:00
|
|
|
// and the labelbuttons in it
|
2007-12-28 05:47:55 +00:00
|
|
|
FbTk::Container::ItemList::iterator btn_it = m_tab_container.begin();
|
|
|
|
FbTk::Container::ItemList::iterator btn_it_end = m_tab_container.end();
|
2003-04-16 12:27:49 +00:00
|
|
|
for (; btn_it != btn_it_end; ++btn_it) {
|
2007-10-13 21:51:37 +00:00
|
|
|
IconButton *btn = static_cast<IconButton *>(*btn_it);
|
|
|
|
btn->reconfigTheme();
|
2003-04-16 12:27:49 +00:00
|
|
|
}
|
|
|
|
}
|
2003-07-26 16:17:02 +00:00
|
|
|
|
2003-08-25 16:17:18 +00:00
|
|
|
void FbWinFrame::setBorderWidth(unsigned int border_width) {
|
2003-07-26 16:17:02 +00:00
|
|
|
int bw_changes = 0;
|
2006-07-03 17:18:17 +00:00
|
|
|
|
|
|
|
int grav_x=0, grav_y=0;
|
|
|
|
// negate gravity
|
|
|
|
gravityTranslate(grav_x, grav_y, -m_active_gravity, m_active_orig_client_bw, false);
|
|
|
|
|
|
|
|
|
2006-10-27 06:57:43 +00:00
|
|
|
// we need to change the size of the window
|
2003-07-26 16:17:02 +00:00
|
|
|
// if the border width changes...
|
2006-10-27 06:57:43 +00:00
|
|
|
if (m_use_titlebar)
|
2003-08-25 16:17:18 +00:00
|
|
|
bw_changes += static_cast<signed>(border_width - titlebar().borderWidth());
|
2006-10-27 06:57:43 +00:00
|
|
|
if (m_use_handle)
|
2003-08-25 16:17:18 +00:00
|
|
|
bw_changes += static_cast<signed>(border_width - handle().borderWidth());
|
2003-07-26 16:17:02 +00:00
|
|
|
|
2003-08-25 16:17:18 +00:00
|
|
|
window().setBorderWidth(border_width);
|
2008-01-05 01:39:19 +00:00
|
|
|
window().setBorderColor(theme()->border(m_focused).color());
|
2003-08-25 13:15:53 +00:00
|
|
|
|
2006-03-20 11:31:24 +00:00
|
|
|
setTabMode(NOTSET);
|
|
|
|
|
2003-08-25 16:17:18 +00:00
|
|
|
titlebar().setBorderWidth(border_width);
|
2008-01-05 01:39:19 +00:00
|
|
|
titlebar().setBorderColor(theme()->border(m_focused).color());
|
2003-08-25 13:15:53 +00:00
|
|
|
|
2003-08-25 16:17:18 +00:00
|
|
|
handle().setBorderWidth(border_width);
|
2008-01-05 01:39:19 +00:00
|
|
|
handle().setBorderColor(theme()->border(m_focused).color());
|
2003-08-25 13:15:53 +00:00
|
|
|
|
2003-08-25 16:17:18 +00:00
|
|
|
gripLeft().setBorderWidth(border_width);
|
2008-01-05 01:39:19 +00:00
|
|
|
gripLeft().setBorderColor(theme()->border(m_focused).color());
|
2003-08-25 13:15:53 +00:00
|
|
|
|
2003-08-25 16:17:18 +00:00
|
|
|
gripRight().setBorderWidth(border_width);
|
2008-01-05 01:39:19 +00:00
|
|
|
gripRight().setBorderColor(theme()->border(m_focused).color());
|
2003-07-26 16:17:02 +00:00
|
|
|
|
|
|
|
if (bw_changes != 0)
|
|
|
|
resize(width(), height() + bw_changes);
|
2006-03-20 11:31:24 +00:00
|
|
|
|
|
|
|
if (m_tabmode == EXTERNAL)
|
|
|
|
alignTabs();
|
2006-07-03 17:18:17 +00:00
|
|
|
|
|
|
|
gravityTranslate(grav_x, grav_y, m_active_gravity, m_active_orig_client_bw, false);
|
|
|
|
// if the location changes, shift it
|
|
|
|
if (grav_x != 0 || grav_y != 0)
|
|
|
|
move(grav_x + x(), grav_y + y());
|
|
|
|
|
2003-07-26 16:17:02 +00:00
|
|
|
}
|
2003-08-04 12:47:36 +00:00
|
|
|
|
2003-09-11 13:17:14 +00:00
|
|
|
// this function translates its arguments according to win_gravity
|
|
|
|
// if win_gravity is negative, it does an inverse translation
|
2003-09-11 19:55:27 +00:00
|
|
|
// This function should be used when a window is mapped/unmapped/pos configured
|
2006-10-27 06:57:43 +00:00
|
|
|
void FbWinFrame::gravityTranslate(int &x, int &y,
|
2006-07-17 20:55:20 +00:00
|
|
|
int win_gravity, unsigned int client_bw, bool move_frame) {
|
2003-09-11 13:17:14 +00:00
|
|
|
bool invert = false;
|
|
|
|
if (win_gravity < 0) {
|
|
|
|
invert = true;
|
|
|
|
win_gravity = -win_gravity; // make +ve
|
|
|
|
}
|
|
|
|
|
2006-10-27 06:57:43 +00:00
|
|
|
/* Ok, so, gravity says which point of the frame is put where the
|
2003-09-11 13:17:14 +00:00
|
|
|
* corresponding bit of window would have been
|
|
|
|
* Thus, x,y always refers to where top left of the WINDOW would be placed
|
|
|
|
* but given that we're wrapping it in a frame, we actually place
|
|
|
|
* it so that the given reference point is in the same spot as the
|
|
|
|
* window's reference point would have been.
|
2006-10-27 06:57:43 +00:00
|
|
|
* i.e. east gravity says that the centre of the right hand side of the
|
2003-09-11 13:17:14 +00:00
|
|
|
* frame is placed where the centre of the rhs of the window would
|
|
|
|
* have been if there was no frame.
|
|
|
|
* Hope that makes enough sense.
|
|
|
|
*
|
2006-10-27 06:57:43 +00:00
|
|
|
* NOTE: the gravity calculations are INDEPENDENT of the client
|
2006-07-03 17:18:17 +00:00
|
|
|
* window width/height.
|
|
|
|
*
|
2003-09-11 13:17:14 +00:00
|
|
|
* If you get confused with the calculations, draw a picture.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
// We calculate offsets based on the gravity and frame aspects
|
|
|
|
// and at the end apply those offsets +ve or -ve depending on 'invert'
|
|
|
|
|
2006-07-03 17:18:17 +00:00
|
|
|
// These will be set to the resulting offsets for adjusting the frame position
|
2003-09-11 13:17:14 +00:00
|
|
|
int x_offset = 0;
|
|
|
|
int y_offset = 0;
|
|
|
|
|
2006-07-03 17:18:17 +00:00
|
|
|
// These are the amount that the frame is larger than the client window
|
|
|
|
// Note that the client window's x,y is offset by it's borderWidth, which
|
|
|
|
// is removed by fluxbox, so the gravity needs to account for this change
|
2005-03-16 23:19:36 +00:00
|
|
|
|
2006-07-03 17:18:17 +00:00
|
|
|
// unsigned int width_offset = 0; // no side decorations
|
2005-03-16 23:19:36 +00:00
|
|
|
|
2006-07-03 17:18:17 +00:00
|
|
|
// these functions already check if the title/handle is used
|
|
|
|
int height_offset = - titlebarHeight() - handleHeight();
|
2005-03-16 23:19:36 +00:00
|
|
|
|
2006-07-03 17:18:17 +00:00
|
|
|
int bw_diff = client_bw - m_window.borderWidth();
|
2005-03-16 23:19:36 +00:00
|
|
|
|
2006-07-03 17:18:17 +00:00
|
|
|
// mostly no X offset, since we don't have extra frame on the sides
|
|
|
|
switch (win_gravity) {
|
|
|
|
case NorthEastGravity:
|
|
|
|
x_offset += bw_diff;
|
|
|
|
case NorthGravity:
|
|
|
|
x_offset += bw_diff;
|
|
|
|
case NorthWestGravity:
|
|
|
|
// no offset, since the top point is still the same
|
|
|
|
break;
|
|
|
|
case SouthEastGravity:
|
|
|
|
x_offset += bw_diff;
|
|
|
|
case SouthGravity:
|
|
|
|
x_offset += bw_diff;
|
|
|
|
case SouthWestGravity:
|
|
|
|
// window shifted down by height of titlebar, and the handle
|
|
|
|
// since that's necessary to get the bottom of the frame
|
|
|
|
// all the way up
|
|
|
|
y_offset += 2*bw_diff + height_offset;
|
|
|
|
break;
|
|
|
|
case EastGravity:
|
|
|
|
x_offset += bw_diff;
|
|
|
|
case CenterGravity:
|
|
|
|
x_offset += bw_diff;
|
|
|
|
case WestGravity:
|
|
|
|
// these centered ones are a little more interesting
|
|
|
|
y_offset += bw_diff + height_offset/2;
|
|
|
|
break;
|
|
|
|
case StaticGravity:
|
|
|
|
x_offset += bw_diff;
|
|
|
|
y_offset += -titlebarHeight() + bw_diff;
|
|
|
|
break;
|
2003-09-11 13:17:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (invert) {
|
|
|
|
x_offset = -x_offset;
|
|
|
|
y_offset = -y_offset;
|
|
|
|
}
|
|
|
|
|
|
|
|
x += x_offset;
|
|
|
|
y += y_offset;
|
2006-07-03 17:18:17 +00:00
|
|
|
|
2003-09-11 13:17:14 +00:00
|
|
|
if (move_frame && (x_offset != 0 || y_offset != 0)) {
|
2004-08-11 13:17:56 +00:00
|
|
|
move(x, y);
|
2003-09-11 13:17:14 +00:00
|
|
|
}
|
|
|
|
}
|
2006-03-20 11:31:24 +00:00
|
|
|
|
2007-07-02 21:26:01 +00:00
|
|
|
unsigned int FbWinFrame::normalHeight() const {
|
|
|
|
if (m_shaded)
|
|
|
|
return m_height_before_shade;
|
|
|
|
return height();
|
|
|
|
}
|
|
|
|
|
2006-03-26 04:02:30 +00:00
|
|
|
int FbWinFrame::widthOffset() const {
|
2006-10-27 06:57:43 +00:00
|
|
|
if (m_tabmode != EXTERNAL || !m_use_tabs)
|
2006-03-20 11:31:24 +00:00
|
|
|
return 0;
|
2006-03-22 12:23:17 +00:00
|
|
|
|
|
|
|
// same height offset for top and bottom tabs
|
2006-03-26 04:02:30 +00:00
|
|
|
switch (m_screen.getTabPlacement()) {
|
|
|
|
case LEFTTOP:
|
|
|
|
case RIGHTTOP:
|
|
|
|
case LEFTBOTTOM:
|
|
|
|
case RIGHTBOTTOM:
|
|
|
|
return m_tab_container.width() + m_window.borderWidth();
|
|
|
|
break;
|
2006-04-16 11:18:22 +00:00
|
|
|
default: // kill warning
|
|
|
|
break;
|
2006-03-26 04:02:30 +00:00
|
|
|
}
|
|
|
|
return 0;
|
2006-03-20 11:31:24 +00:00
|
|
|
}
|
|
|
|
|
2006-03-26 04:02:30 +00:00
|
|
|
int FbWinFrame::heightOffset() const {
|
2006-10-27 06:57:43 +00:00
|
|
|
if (m_tabmode != EXTERNAL || !m_use_tabs)
|
2006-03-22 12:23:17 +00:00
|
|
|
return 0;
|
|
|
|
|
2006-03-22 13:06:00 +00:00
|
|
|
switch (m_screen.getTabPlacement()) {
|
2006-03-22 12:23:17 +00:00
|
|
|
case TOPLEFT:
|
|
|
|
case TOPRIGHT:
|
|
|
|
case BOTTOMLEFT:
|
|
|
|
case BOTTOMRIGHT:
|
2006-03-26 04:02:30 +00:00
|
|
|
return m_tab_container.height() + m_window.borderWidth();
|
|
|
|
break;
|
2006-04-16 11:18:22 +00:00
|
|
|
default: // kill warning
|
|
|
|
break;
|
2006-03-26 04:02:30 +00:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int FbWinFrame::xOffset() const {
|
2006-10-27 06:57:43 +00:00
|
|
|
if (m_tabmode != EXTERNAL || !m_use_tabs)
|
2006-03-20 11:31:24 +00:00
|
|
|
return 0;
|
2006-03-26 04:02:30 +00:00
|
|
|
|
|
|
|
switch (m_screen.getTabPlacement()) {
|
|
|
|
case LEFTTOP:
|
|
|
|
case LEFTBOTTOM:
|
|
|
|
return m_tab_container.width() + m_window.borderWidth();
|
|
|
|
break;
|
2006-04-16 11:18:22 +00:00
|
|
|
default: // kill warning
|
|
|
|
break;
|
2006-03-26 04:02:30 +00:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int FbWinFrame::yOffset() const {
|
2006-10-27 06:57:43 +00:00
|
|
|
if (m_tabmode != EXTERNAL || !m_use_tabs)
|
2006-03-26 04:02:30 +00:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
switch (m_screen.getTabPlacement()) {
|
|
|
|
case TOPLEFT:
|
|
|
|
case TOPRIGHT:
|
|
|
|
return m_tab_container.height() + m_window.borderWidth();
|
2006-03-22 12:23:17 +00:00
|
|
|
break;
|
2006-04-16 11:18:22 +00:00
|
|
|
default: // kill warning
|
|
|
|
break;
|
2006-03-22 12:23:17 +00:00
|
|
|
}
|
2006-03-26 04:02:30 +00:00
|
|
|
return 0;
|
2006-03-20 11:31:24 +00:00
|
|
|
}
|
|
|
|
|