2003-01-05 22:14:10 +00:00
|
|
|
// FbWinFrame.hh for Fluxbox Window Manager
|
2005-01-24 18:34:57 +00:00
|
|
|
// Copyright (c) 2003 - 2005 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.
|
|
|
|
|
2004-11-19 11:37:27 +00:00
|
|
|
// $Id$
|
2003-01-05 22:14:10 +00:00
|
|
|
|
|
|
|
#ifndef FBWINFRAME_HH
|
|
|
|
#define FBWINFRAME_HH
|
|
|
|
|
2003-09-10 09:53:21 +00:00
|
|
|
#include "FbTk/FbWindow.hh"
|
|
|
|
#include "FbTk/EventHandler.hh"
|
|
|
|
#include "FbTk/RefCount.hh"
|
|
|
|
#include "FbTk/Observer.hh"
|
|
|
|
#include "FbTk/Color.hh"
|
|
|
|
#include "FbTk/FbPixmap.hh"
|
|
|
|
#include "FbTk/Timer.hh"
|
2003-01-05 22:14:10 +00:00
|
|
|
|
|
|
|
#include <vector>
|
2003-07-28 12:11:57 +00:00
|
|
|
#include <list>
|
2003-01-05 22:14:10 +00:00
|
|
|
#include <string>
|
2003-07-10 11:36:21 +00:00
|
|
|
#include <memory>
|
2003-01-05 22:14:10 +00:00
|
|
|
|
2003-07-10 11:36:21 +00:00
|
|
|
class Shape;
|
2003-01-05 22:14:10 +00:00
|
|
|
class FbWinFrameTheme;
|
2003-08-13 16:36:37 +00:00
|
|
|
|
2003-01-09 22:08:27 +00:00
|
|
|
namespace FbTk {
|
2003-08-19 16:15:32 +00:00
|
|
|
class TextButton;
|
2003-01-09 22:08:27 +00:00
|
|
|
class ImageControl;
|
2003-07-10 11:36:21 +00:00
|
|
|
class Command;
|
|
|
|
class Button;
|
|
|
|
class Texture;
|
2003-12-16 23:36:06 +00:00
|
|
|
}
|
2003-01-05 22:14:10 +00:00
|
|
|
|
2003-04-16 12:27:49 +00:00
|
|
|
/// holds a window frame with a client window
|
|
|
|
/// (see: <a href="fluxbox_fbwinframe.png">image</a>)
|
2003-01-05 22:14:10 +00:00
|
|
|
class FbWinFrame:public FbTk::EventHandler {
|
|
|
|
public:
|
|
|
|
|
|
|
|
/// create a top level window
|
2003-12-18 18:03:23 +00:00
|
|
|
FbWinFrame(FbWinFrameTheme &theme, FbTk::ImageControl &imgctrl,
|
|
|
|
int x, int y,
|
2003-01-05 22:14:10 +00:00
|
|
|
unsigned int width, unsigned int height);
|
|
|
|
|
|
|
|
/// create a frame window inside another FbWindow, NOT IMPLEMENTED!
|
2003-02-15 01:54:54 +00:00
|
|
|
FbWinFrame(FbWinFrameTheme &theme, FbTk::ImageControl &imgctrl,
|
|
|
|
const FbTk::FbWindow &parent,
|
2003-01-05 22:14:10 +00:00
|
|
|
int x, int y,
|
|
|
|
unsigned int width, unsigned int height);
|
|
|
|
|
|
|
|
/// destroy frame
|
|
|
|
~FbWinFrame();
|
|
|
|
|
2003-01-07 01:30:57 +00:00
|
|
|
/// setup actions for titlebar
|
|
|
|
bool setOnClickTitlebar(FbTk::RefCount<FbTk::Command> &cmd, int button_num,
|
|
|
|
bool double_click=false, bool pressed=false);
|
|
|
|
|
2003-01-05 22:14:10 +00:00
|
|
|
void hide();
|
|
|
|
void show();
|
2003-05-01 13:19:36 +00:00
|
|
|
inline bool isVisible() const { return m_visible; }
|
2003-01-05 22:14:10 +00:00
|
|
|
/// shade frame (ie resize to titlebar size)
|
|
|
|
void shade();
|
2005-03-16 23:19:36 +00:00
|
|
|
void move(int x, int y, int win_gravity=ForgetGravity);
|
|
|
|
void resize(unsigned int width, unsigned int height, int win_gravity=ForgetGravity);
|
2003-01-05 22:14:10 +00:00
|
|
|
/// resize client to specified size and resize frame to it
|
2005-03-16 23:19:36 +00:00
|
|
|
void resizeForClient(unsigned int width, unsigned int height, int win_gravity=ForgetGravity);
|
2003-09-24 14:02:25 +00:00
|
|
|
|
|
|
|
// for when there needs to be an atomic move+resize operation
|
2005-03-16 23:19:36 +00:00
|
|
|
void moveResizeForClient(int x, int y, unsigned int width, unsigned int height, bool move = true, bool resize = true, int win_gravity=ForgetGravity);
|
2003-09-24 14:02:25 +00:00
|
|
|
|
|
|
|
// can elect to ignore move or resize (mainly for use of move/resize individual functions
|
2005-03-16 23:19:36 +00:00
|
|
|
void moveResize(int x, int y, unsigned int width, unsigned int height, bool move = true, bool resize = true, int win_gravity=ForgetGravity);
|
2003-09-14 10:32:31 +00:00
|
|
|
|
2003-01-05 22:14:10 +00:00
|
|
|
/// set focus/unfocus style
|
|
|
|
void setFocus(bool newvalue);
|
2003-01-07 01:30:57 +00:00
|
|
|
void setDoubleClickTime(unsigned int time);
|
2003-09-12 23:38:50 +00:00
|
|
|
|
2003-01-05 22:14:10 +00:00
|
|
|
/// add a button to the left of the label
|
|
|
|
void addLeftButton(FbTk::Button *btn);
|
|
|
|
/// add a button to the right of the label
|
|
|
|
void addRightButton(FbTk::Button *btn);
|
|
|
|
/// remove all buttons from titlebar
|
|
|
|
void removeAllButtons();
|
2003-04-14 15:01:55 +00:00
|
|
|
/// adds a button to label window
|
2003-08-19 16:15:32 +00:00
|
|
|
void addLabelButton(FbTk::TextButton &btn);
|
2003-04-14 15:01:55 +00:00
|
|
|
/// removes a specific button from label window
|
2003-08-19 16:15:32 +00:00
|
|
|
void removeLabelButton(FbTk::TextButton &btn);
|
2003-07-28 12:11:57 +00:00
|
|
|
/// move label button to the left
|
2003-08-19 16:15:32 +00:00
|
|
|
void moveLabelButtonLeft(const FbTk::TextButton &btn);
|
2003-07-28 12:11:57 +00:00
|
|
|
/// move label button to the right
|
2003-08-19 16:15:32 +00:00
|
|
|
void moveLabelButtonRight(const FbTk::TextButton &btn);
|
2004-11-24 23:27:28 +00:00
|
|
|
/// move label button to the given location( x and y are relative to the root window)
|
|
|
|
void moveLabelButtonTo(FbTk::TextButton &btn, int x, int y);
|
|
|
|
/// move the first label button to the left of the second
|
|
|
|
void moveLabelButtonLeftOf(const FbTk::TextButton &btn, const FbTk::TextButton &dest);
|
|
|
|
//move the first label button to the right of the second
|
|
|
|
void moveLabelButtonRightOf(const FbTk::TextButton &btn, const FbTk::TextButton &dest);
|
2003-04-16 12:27:49 +00:00
|
|
|
/// which button is to be rendered focused
|
2003-08-19 16:15:32 +00:00
|
|
|
void setLabelButtonFocus(FbTk::TextButton &btn);
|
2003-01-05 22:14:10 +00:00
|
|
|
/// attach a client window for client area
|
2003-04-14 15:01:55 +00:00
|
|
|
void setClientWindow(FbTk::FbWindow &win);
|
2003-01-05 22:14:10 +00:00
|
|
|
/// remove attached client window
|
|
|
|
void removeClient();
|
|
|
|
/// redirect events to another eventhandler
|
|
|
|
void setEventHandler(FbTk::EventHandler &evh);
|
|
|
|
/// remove any handler for the windows
|
|
|
|
void removeEventHandler();
|
2003-09-10 09:53:21 +00:00
|
|
|
|
2003-10-05 09:03:43 +00:00
|
|
|
// these return true/false for if something changed
|
|
|
|
bool hideTitlebar();
|
|
|
|
bool showTitlebar();
|
|
|
|
bool hideHandle();
|
|
|
|
bool showHandle();
|
|
|
|
bool hideAllDecorations();
|
|
|
|
bool showAllDecorations();
|
2003-01-05 22:14:10 +00:00
|
|
|
|
2003-09-11 13:15:58 +00:00
|
|
|
// this function translates its arguments according to win_gravity
|
|
|
|
// if win_gravity is negative, it does an inverse translation
|
2003-09-11 13:17:14 +00:00
|
|
|
void gravityTranslate(int &x, int &y, int win_gravity, bool move_frame = false);
|
2005-03-16 23:19:36 +00:00
|
|
|
//use width and height given instead of the real values, allows figuring out where to place a window before doing a moveResize
|
|
|
|
void gravityTranslate(int &x, int &y, unsigned int width, unsigned int height, int win_gravity, bool move_frame = false);
|
2003-07-26 16:17:02 +00:00
|
|
|
void setBorderWidth(unsigned int borderW);
|
|
|
|
|
2003-01-05 22:14:10 +00:00
|
|
|
/**
|
|
|
|
@name Event handlers
|
|
|
|
*/
|
|
|
|
//@{
|
|
|
|
void buttonPressEvent(XButtonEvent &event);
|
2003-01-07 01:30:57 +00:00
|
|
|
void buttonReleaseEvent(XButtonEvent &event);
|
2003-01-05 22:14:10 +00:00
|
|
|
void exposeEvent(XExposeEvent &event);
|
|
|
|
void configureNotifyEvent(XConfigureEvent &event);
|
|
|
|
void handleEvent(XEvent &event);
|
|
|
|
//@}
|
|
|
|
|
|
|
|
void reconfigure();
|
2003-08-24 15:18:09 +00:00
|
|
|
void setUseShape(bool value);
|
2003-09-10 09:53:21 +00:00
|
|
|
|
|
|
|
void setUpdateDelayTime(long t) { m_update_timer.setTimeout(t); }
|
|
|
|
|
2003-01-05 22:14:10 +00:00
|
|
|
/**
|
|
|
|
@name accessors
|
|
|
|
*/
|
|
|
|
//@{
|
|
|
|
inline int x() const { return m_window.x(); }
|
|
|
|
inline int y() const { return m_window.y(); }
|
|
|
|
inline unsigned int width() const { return m_window.width(); }
|
|
|
|
inline unsigned int height() const { return m_window.height(); }
|
|
|
|
inline const FbTk::FbWindow &window() const { return m_window; }
|
|
|
|
inline FbTk::FbWindow &window() { return m_window; }
|
|
|
|
/// @return titlebar window
|
|
|
|
inline const FbTk::FbWindow &titlebar() const { return m_titlebar; }
|
|
|
|
inline FbTk::FbWindow &titlebar() { return m_titlebar; }
|
|
|
|
inline const FbTk::FbWindow &label() const { return m_label; }
|
|
|
|
inline FbTk::FbWindow &label() { return m_label; }
|
|
|
|
/// @return clientarea window
|
|
|
|
inline const FbTk::FbWindow &clientArea() const { return m_clientarea; }
|
|
|
|
inline FbTk::FbWindow &clientArea() { return m_clientarea; }
|
|
|
|
/// @return handle window
|
|
|
|
inline const FbTk::FbWindow &handle() const { return m_handle; }
|
|
|
|
inline FbTk::FbWindow &handle() { return m_handle; }
|
|
|
|
inline const FbTk::FbWindow &gripLeft() const { return m_grip_left; }
|
|
|
|
inline FbTk::FbWindow &gripLeft() { return m_grip_left; }
|
|
|
|
inline const FbTk::FbWindow &gripRight() const { return m_grip_right; }
|
|
|
|
inline FbTk::FbWindow &gripRight() { return m_grip_right; }
|
2003-09-12 22:49:14 +00:00
|
|
|
inline const FbTk::TextButton *currentLabel() const { return m_current_label; }
|
2003-01-05 22:14:10 +00:00
|
|
|
inline bool focused() const { return m_focused; }
|
|
|
|
inline bool isShaded() const { return m_shaded; }
|
2003-04-14 15:01:55 +00:00
|
|
|
inline const FbWinFrameTheme &theme() const { return m_theme; }
|
2003-01-07 01:30:57 +00:00
|
|
|
/// @return titlebar height
|
2003-05-21 23:59:54 +00:00
|
|
|
unsigned int titlebarHeight() const { return m_titlebar.height(); }
|
2003-01-07 01:30:57 +00:00
|
|
|
/// @return size of button
|
2003-01-05 22:14:10 +00:00
|
|
|
unsigned int buttonHeight() const;
|
|
|
|
|
|
|
|
//@}
|
|
|
|
|
|
|
|
private:
|
|
|
|
void redrawTitlebar();
|
2003-09-12 22:49:14 +00:00
|
|
|
void redrawTitle();
|
|
|
|
|
2003-01-05 22:14:10 +00:00
|
|
|
/// reposition titlebar items
|
|
|
|
void reconfigureTitlebar();
|
|
|
|
/**
|
|
|
|
@name render helper functions
|
|
|
|
*/
|
|
|
|
//@{
|
|
|
|
void renderTitlebar();
|
|
|
|
void renderHandles();
|
|
|
|
void renderButtons();
|
2003-12-09 08:48:08 +00:00
|
|
|
// focused => has focus
|
2003-08-19 16:15:32 +00:00
|
|
|
void renderButtonFocus(FbTk::TextButton &button);
|
2003-12-09 08:48:08 +00:00
|
|
|
// unfocus => has no focus, label not the active one
|
2003-08-19 16:15:32 +00:00
|
|
|
void renderButtonUnfocus(FbTk::TextButton &button);
|
2003-12-09 08:48:08 +00:00
|
|
|
// active => doesn't have keybaord focus, but is the active tab
|
|
|
|
void renderButtonActive(FbTk::TextButton &button);
|
2003-01-05 22:14:10 +00:00
|
|
|
void renderLabel();
|
|
|
|
/// renders to pixmap or sets color
|
|
|
|
void render(const FbTk::Texture &tex, FbTk::Color &col, Pixmap &pm,
|
|
|
|
unsigned int width, unsigned int height);
|
2003-12-09 08:48:08 +00:00
|
|
|
void getActiveLabelPixmap(Pixmap &label_pm, Pixmap &title_pm,
|
|
|
|
FbTk::Color &label_color, FbTk::Color &title_color);
|
2003-04-16 12:27:49 +00:00
|
|
|
void getCurrentFocusPixmap(Pixmap &label_pm, Pixmap &title_pm,
|
|
|
|
FbTk::Color &label_color, FbTk::Color &title_color);
|
|
|
|
void renderLabelButtons();
|
2003-01-05 22:14:10 +00:00
|
|
|
//@}
|
|
|
|
|
|
|
|
/// initiate some commont variables
|
|
|
|
void init();
|
|
|
|
/// initiate inserted buttons for current theme
|
|
|
|
void setupButton(FbTk::Button &btn);
|
2003-09-10 09:53:21 +00:00
|
|
|
void updateTransparent();
|
2003-01-05 22:14:10 +00:00
|
|
|
|
|
|
|
FbWinFrameTheme &m_theme; ///< theme to be used
|
2003-01-09 22:08:27 +00:00
|
|
|
FbTk::ImageControl &m_imagectrl; ///< Image control for rendering
|
2003-01-05 22:14:10 +00:00
|
|
|
/**
|
|
|
|
@name windows
|
|
|
|
*/
|
|
|
|
//@{
|
|
|
|
FbTk::FbWindow m_window; ///< base window that holds each decorations (ie titlebar, handles)
|
|
|
|
FbTk::FbWindow m_titlebar; ///< titlebar window
|
|
|
|
FbTk::FbWindow m_label; ///< holds title
|
2003-10-02 14:14:46 +00:00
|
|
|
FbTk::FbWindow m_handle; ///< handle between grips
|
2003-01-05 22:14:10 +00:00
|
|
|
FbTk::FbWindow m_grip_right, ///< rightgrip
|
|
|
|
m_grip_left; ///< left grip
|
2003-10-28 02:17:03 +00:00
|
|
|
FbTk::FbWindow m_clientarea; ///< window that sits behind client window to fill gaps @see setClientWindow
|
2003-01-05 22:14:10 +00:00
|
|
|
//@}
|
|
|
|
typedef std::vector<FbTk::Button *> ButtonList;
|
|
|
|
ButtonList m_buttons_left, ///< buttons to the left
|
|
|
|
m_buttons_right; ///< buttons to the right
|
2003-08-19 16:15:32 +00:00
|
|
|
typedef std::list<FbTk::TextButton *> LabelList;
|
2003-07-28 12:11:57 +00:00
|
|
|
LabelList m_labelbuttons; ///< holds label buttons inside label window
|
2003-08-19 16:15:32 +00:00
|
|
|
FbTk::TextButton *m_current_label; ///< which client button is focused at the moment
|
2003-01-05 22:14:10 +00:00
|
|
|
std::string m_titletext; ///< text to be displayed int m_label
|
|
|
|
int m_bevel; ///< bevel between titlebar items and titlebar
|
|
|
|
bool m_use_titlebar; ///< if we should use titlebar
|
2003-01-07 01:30:57 +00:00
|
|
|
bool m_use_handle; ///< if we should use handle
|
2003-01-05 22:14:10 +00:00
|
|
|
bool m_focused; ///< focused/unfocused mode
|
2003-05-01 13:19:36 +00:00
|
|
|
bool m_visible; ///< if we are currently showing
|
2003-01-07 01:30:57 +00:00
|
|
|
|
2003-01-05 22:14:10 +00:00
|
|
|
/**
|
|
|
|
@name pixmaps and colors for rendering
|
|
|
|
*/
|
|
|
|
//@{
|
|
|
|
Pixmap m_title_focused_pm; ///< pixmap for focused title
|
|
|
|
FbTk::Color m_title_focused_color; ///< color for focused title
|
|
|
|
Pixmap m_title_unfocused_pm; ///< pixmap for unfocused title
|
|
|
|
FbTk::Color m_title_unfocused_color; ///< color for unfocued title
|
|
|
|
|
|
|
|
Pixmap m_label_focused_pm; ///< pixmap for focused label
|
|
|
|
FbTk::Color m_label_focused_color; ///< color for focused label
|
|
|
|
Pixmap m_label_unfocused_pm; ///< pixmap for unfocused label
|
|
|
|
FbTk::Color m_label_unfocused_color; ///< color for unfocued label
|
2003-12-09 08:48:08 +00:00
|
|
|
Pixmap m_label_active_pm; ///< pixmap for active label
|
|
|
|
FbTk::Color m_label_active_color; ///< color for active label
|
2003-01-05 22:14:10 +00:00
|
|
|
|
|
|
|
FbTk::Color m_handle_focused_color, m_handle_unfocused_color;
|
|
|
|
Pixmap m_handle_focused_pm, m_handle_unfocused_pm;
|
|
|
|
|
|
|
|
|
|
|
|
Pixmap m_button_pm; ///< normal button
|
|
|
|
FbTk::Color m_button_color; ///< normal color button
|
|
|
|
Pixmap m_button_unfocused_pm; ///< unfocused button
|
|
|
|
FbTk::Color m_button_unfocused_color; ///< unfocused color button
|
|
|
|
Pixmap m_button_pressed_pm; ///< pressed button
|
|
|
|
FbTk::Color m_button_pressed_color; ///< pressed button color
|
|
|
|
|
|
|
|
Pixmap m_grip_focused_pm;
|
|
|
|
FbTk::Color m_grip_focused_color; ///< if no pixmap is given for grip, use this color
|
|
|
|
Pixmap m_grip_unfocused_pm; ///< unfocused pixmap for grip
|
|
|
|
FbTk::Color m_grip_unfocused_color; ///< unfocused color for grip if no pixmap is given
|
|
|
|
//@}
|
|
|
|
|
|
|
|
int m_button_size; ///< size for all titlebar buttons
|
|
|
|
unsigned int m_width_before_shade, ///< width before shade, so we can restore it when we unshade
|
|
|
|
m_height_before_shade; ///< height before shade, so we can restore it when we unshade
|
|
|
|
bool m_shaded; ///< wheter we're shaded or not
|
2003-01-07 01:30:57 +00:00
|
|
|
unsigned int m_double_click_time; ///< the time period that's considerd to be a double click
|
|
|
|
struct MouseButtonAction {
|
|
|
|
FbTk::RefCount<FbTk::Command> click; ///< what to do when we release mouse button
|
|
|
|
FbTk::RefCount<FbTk::Command> click_pressed; ///< what to do when we press mouse button
|
|
|
|
FbTk::RefCount<FbTk::Command> double_click; ///< what to do when we double click
|
|
|
|
};
|
2003-02-15 01:54:54 +00:00
|
|
|
MouseButtonAction m_commands[5]; ///< hardcoded to five ... //!! TODO, change this
|
|
|
|
|
|
|
|
class ThemeListener: public FbTk::Observer {
|
|
|
|
public:
|
|
|
|
ThemeListener(FbWinFrame &frame):m_frame(frame) { }
|
2003-12-16 23:36:06 +00:00
|
|
|
void update(FbTk::Subject *) {
|
2003-02-15 01:54:54 +00:00
|
|
|
m_frame.reconfigure();
|
|
|
|
}
|
|
|
|
private:
|
|
|
|
FbWinFrame &m_frame;
|
|
|
|
};
|
|
|
|
ThemeListener m_themelistener;
|
2003-07-10 11:36:21 +00:00
|
|
|
std::auto_ptr<Shape> m_shape;
|
2003-08-24 15:18:09 +00:00
|
|
|
bool m_disable_shape;
|
2003-09-10 09:53:21 +00:00
|
|
|
FbTk::Timer m_update_timer;
|
2003-01-05 22:14:10 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // FBWINFRAME_HH
|