fixed new image loading

This commit is contained in:
fluxgen 2003-08-22 21:35:40 +00:00
parent 834645f545
commit dc3f13d2fc
3 changed files with 74 additions and 132 deletions

View file

@ -19,7 +19,7 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
/// $Id: WinButton.cc,v 1.9 2003/08/22 15:04:18 fluxgen Exp $ /// $Id: WinButton.cc,v 1.10 2003/08/22 21:33:13 fluxgen Exp $
#include "WinButton.hh" #include "WinButton.hh"
#include "App.hh" #include "App.hh"
@ -52,23 +52,23 @@ void WinButton::drawType() {
switch (m_type) { switch (m_type) {
case MAXIMIZE: case MAXIMIZE:
if (m_theme.maximizePixmap().pixmap.drawable() != 0) { if (m_theme.maximizePixmap().pixmap().drawable() != 0) {
if (pressed()) { if (pressed()) {
FbTk::FbWindow::setBackgroundPixmap(m_theme. FbTk::FbWindow::setBackgroundPixmap(m_theme.
maximizePressedPixmap(). maximizePressedPixmap().
pixmap.drawable()); pixmap().drawable());
} else if (m_theme.maximizePixmap().pixmap.drawable()) { } else if (m_theme.maximizePixmap().pixmap().drawable()) {
// check focus // check focus
if (!m_listen_to.isFocused() && if (!m_listen_to.isFocused() &&
m_theme.maximizeUnfocusPixmap().pixmap.drawable() != 0) { m_theme.maximizeUnfocusPixmap().pixmap().drawable() != 0) {
// not focused // not focused
FbTk::FbWindow::setBackgroundPixmap(m_theme. FbTk::FbWindow::setBackgroundPixmap(m_theme.
maximizeUnfocusPixmap(). maximizeUnfocusPixmap().
pixmap.drawable()); pixmap().drawable());
} else { // focused } else { // focused
FbTk::FbWindow::setBackgroundPixmap(m_theme. FbTk::FbWindow::setBackgroundPixmap(m_theme.
maximizePixmap(). maximizePixmap().
pixmap.drawable()); pixmap().drawable());
} }
} }
@ -84,23 +84,23 @@ void WinButton::drawType() {
} }
break; break;
case MINIMIZE: case MINIMIZE:
if (m_theme.iconifyPixmap().pixmap.drawable() != 0) { if (m_theme.iconifyPixmap().pixmap().drawable() != 0) {
if (pressed()) { if (pressed()) {
FbTk::FbWindow::setBackgroundPixmap(m_theme. FbTk::FbWindow::setBackgroundPixmap(m_theme.
iconifyPressedPixmap(). iconifyPressedPixmap().
pixmap.drawable()); pixmap().drawable());
} else if (m_theme.iconifyPixmap().pixmap.drawable()){ } else if (m_theme.iconifyPixmap().pixmap().drawable()){
// check focus // check focus
if (!m_listen_to.isFocused() && if (!m_listen_to.isFocused() &&
m_theme.iconifyUnfocusPixmap().pixmap.drawable() != 0) { m_theme.iconifyUnfocusPixmap().pixmap().drawable() != 0) {
// not focused // not focused
FbTk::FbWindow::setBackgroundPixmap(m_theme. FbTk::FbWindow::setBackgroundPixmap(m_theme.
iconifyUnfocusPixmap(). iconifyUnfocusPixmap().
pixmap.drawable()); pixmap().drawable());
} else { // focused } else { // focused
FbTk::FbWindow::setBackgroundPixmap(m_theme. FbTk::FbWindow::setBackgroundPixmap(m_theme.
iconifyPixmap(). iconifyPixmap().
pixmap.drawable()); pixmap().drawable());
} }
} }
@ -114,41 +114,41 @@ void WinButton::drawType() {
} }
break; break;
case STICK: case STICK:
if (m_theme.stickPixmap().pixmap.drawable() != 0) { if (m_theme.stickPixmap().pixmap().drawable() != 0) {
if (m_listen_to.isStuck() && if (m_listen_to.isStuck() &&
m_theme.stuckPixmap().pixmap.drawable() && m_theme.stuckPixmap().pixmap().drawable() &&
! pressed()) { // we're using the same pixmap for pressed as in not stuck ! pressed()) { // we're using the same pixmap for pressed as in not stuck
// check focus // check focus
if (!m_listen_to.isFocused() && if (!m_listen_to.isFocused() &&
m_theme.stuckUnfocusPixmap().pixmap.drawable() != 0) { m_theme.stuckUnfocusPixmap().pixmap().drawable() != 0) {
// not focused // not focused
FbTk::FbWindow::setBackgroundPixmap(m_theme. FbTk::FbWindow::setBackgroundPixmap(m_theme.
stuckUnfocusPixmap(). stuckUnfocusPixmap().
pixmap.drawable()); pixmap().drawable());
} else { // focused } else { // focused
FbTk::FbWindow::setBackgroundPixmap(m_theme. FbTk::FbWindow::setBackgroundPixmap(m_theme.
stuckPixmap(). stuckPixmap().
pixmap.drawable()); pixmap().drawable());
} }
} else { // not stuck } else { // not stuck
if (pressed()) { if (pressed()) {
FbTk::FbWindow::setBackgroundPixmap(m_theme. FbTk::FbWindow::setBackgroundPixmap(m_theme.
stickPressedPixmap(). stickPressedPixmap().
pixmap.drawable()); pixmap().drawable());
} else if (m_theme.stickPixmap().pixmap.drawable()) { } else if (m_theme.stickPixmap().pixmap().drawable()) {
// check focus // check focus
if (!m_listen_to.isFocused() && if (!m_listen_to.isFocused() &&
m_theme.stickUnfocusPixmap().pixmap.drawable() != 0) { m_theme.stickUnfocusPixmap().pixmap().drawable() != 0) {
// not focused // not focused
FbTk::FbWindow::setBackgroundPixmap(m_theme. FbTk::FbWindow::setBackgroundPixmap(m_theme.
stickUnfocusPixmap(). stickUnfocusPixmap().
pixmap.drawable()); pixmap().drawable());
} else { // focused } else { // focused
FbTk::FbWindow::setBackgroundPixmap(m_theme. FbTk::FbWindow::setBackgroundPixmap(m_theme.
stickPixmap(). stickPixmap().
pixmap.drawable()); pixmap().drawable());
} }
} }
@ -172,24 +172,24 @@ void WinButton::drawType() {
break; break;
case CLOSE: case CLOSE:
if (m_theme.closePixmap().pixmap.drawable() != 0) { if (m_theme.closePixmap().pixmap().drawable() != 0) {
if (pressed()) { if (pressed()) {
FbTk::FbWindow::setBackgroundPixmap(m_theme. FbTk::FbWindow::setBackgroundPixmap(m_theme.
closePressedPixmap(). closePressedPixmap().
pixmap.drawable()); pixmap().drawable());
} else if (m_theme.closePixmap().pixmap.drawable()) { } else if (m_theme.closePixmap().pixmap().drawable()) {
// check focus // check focus
if (!m_listen_to.isFocused() && if (!m_listen_to.isFocused() &&
m_theme.closeUnfocusPixmap().pixmap.drawable() != 0) { m_theme.closeUnfocusPixmap().pixmap().drawable() != 0) {
// not focused // not focused
FbTk::FbWindow::setBackgroundPixmap(m_theme. FbTk::FbWindow::setBackgroundPixmap(m_theme.
closeUnfocusPixmap(). closeUnfocusPixmap().
pixmap.drawable()); pixmap().drawable());
} else { // focused } else { // focused
FbTk::FbWindow::setBackgroundPixmap(m_theme. FbTk::FbWindow::setBackgroundPixmap(m_theme.
closePixmap(). closePixmap().
pixmap.drawable()); pixmap().drawable());
} }
} }
@ -207,23 +207,23 @@ void WinButton::drawType() {
} }
break; break;
case SHADE: case SHADE:
if (m_theme.shadePixmap().pixmap.drawable() != 0) { if (m_theme.shadePixmap().pixmap().drawable() != 0) {
if (pressed()) { if (pressed()) {
FbTk::FbWindow::setBackgroundPixmap(m_theme. FbTk::FbWindow::setBackgroundPixmap(m_theme.
shadePressedPixmap(). shadePressedPixmap().
pixmap.drawable()); pixmap().drawable());
} else if (m_theme.shadePixmap().pixmap.drawable()) { } else if (m_theme.shadePixmap().pixmap().drawable()) {
// check focus // check focus
if (!m_listen_to.isFocused() && if (!m_listen_to.isFocused() &&
m_theme.shadeUnfocusPixmap().pixmap.drawable() != 0) { m_theme.shadeUnfocusPixmap().pixmap().drawable() != 0) {
// not focused // not focused
FbTk::FbWindow::setBackgroundPixmap(m_theme. FbTk::FbWindow::setBackgroundPixmap(m_theme.
shadeUnfocusPixmap(). shadeUnfocusPixmap().
pixmap.drawable()); pixmap().drawable());
} else { // focused } else { // focused
FbTk::FbWindow::setBackgroundPixmap(m_theme. FbTk::FbWindow::setBackgroundPixmap(m_theme.
shadePixmap(). shadePixmap().
pixmap.drawable()); pixmap().drawable());
} }
} }

View file

@ -19,63 +19,16 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// $Id: WinButtonTheme.cc,v 1.5 2003/08/22 15:19:39 fluxgen Exp $ // $Id: WinButtonTheme.cc,v 1.6 2003/08/22 21:35:40 fluxgen Exp $
#include "WinButtonTheme.hh" #include "WinButtonTheme.hh"
#include "FbTk/App.hh" #include "FbTk/App.hh"
#include "FbTk/Image.hh"
#include "FbTk/PixmapWithMask.hh"
#include "FbWinFrameTheme.hh" #include "FbWinFrameTheme.hh"
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif // HAVE_CONFIG_H
#ifdef HAVE_XPM
#include <X11/xpm.h>
#endif // HAVE_XPM
// not used
template <>
void FbTk::ThemeItem<WinButtonTheme::PixmapWithMask>::
load() { }
template <>
void FbTk::ThemeItem<WinButtonTheme::PixmapWithMask>::
setDefaultValue() {
// create empty pixmap
(*this)->pixmap = FbTk::FbPixmap(); // pixmap
(*this)->mask = FbTk::FbPixmap(); // mask
}
template <>
void FbTk::ThemeItem<WinButtonTheme::PixmapWithMask>::
setFromString(const char *str) {
if (str == 0)
setDefaultValue();
else {
#ifdef HAVE_XPM
XpmAttributes xpm_attr;
xpm_attr.valuemask = 0;
Display *dpy = FbTk::App::instance()->display();
Pixmap pm = 0, mask = 0;
int retvalue = XpmReadFileToPixmap(dpy,
RootWindow(dpy, m_tm.screenNum()),
const_cast<char *>(str),
&pm,
&mask, &xpm_attr);
if (retvalue == 0) { // success
(*this)->pixmap = pm;
(*this)->mask = mask;
} else { // failure
setDefaultValue();
}
#else
setDefaultValue();
#endif // HAVE_XPM
}
}
WinButtonTheme::WinButtonTheme(int screen_num, const FbWinFrameTheme &frame_theme): WinButtonTheme::WinButtonTheme(int screen_num, const FbWinFrameTheme &frame_theme):
FbTk::Theme(screen_num), FbTk::Theme(screen_num),
m_close_pm(*this, "window.close.pixmap", "Window.Close.Pixmap"), m_close_pm(*this, "window.close.pixmap", "Window.Close.Pixmap"),

View file

@ -19,75 +19,64 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// $Id: WinButtonTheme.hh,v 1.3 2003/08/22 14:48:10 fluxgen Exp $ // $Id: WinButtonTheme.hh,v 1.4 2003/08/22 21:35:40 fluxgen Exp $
#ifndef WINBUTTONTHEME_HH #ifndef WINBUTTONTHEME_HH
#define WINBUTTONTHEME_HH #define WINBUTTONTHEME_HH
#include "Theme.hh" #include "Theme.hh"
#include "FbPixmap.hh" #include "FbTk/PixmapWithMask.hh"
class FbWinFrameTheme; class FbWinFrameTheme;
class WinButtonTheme: public FbTk::Theme { class WinButtonTheme: public FbTk::Theme {
public: public:
/// holds pixmap and a mask
struct PixmapWithMask {
/// scale both pixmap and mask to specified size
void scale(unsigned int width, unsigned int height) {
pixmap.scale(width, height);
mask.scale(width, height);
}
FbTk::FbPixmap pixmap;
FbTk::FbPixmap mask;
};
WinButtonTheme(int screen_num, const FbWinFrameTheme &frame_theme); WinButtonTheme(int screen_num, const FbWinFrameTheme &frame_theme);
~WinButtonTheme(); ~WinButtonTheme();
void reconfigTheme(); void reconfigTheme();
inline const PixmapWithMask &closePixmap() const { return *m_close_pm; } inline const FbTk::PixmapWithMask &closePixmap() const { return *m_close_pm; }
inline PixmapWithMask &closePixmap() { return *m_close_pm; } inline FbTk::PixmapWithMask &closePixmap() { return *m_close_pm; }
inline PixmapWithMask &closeUnfocusPixmap() { return *m_close_unfocus_pm; } inline FbTk::PixmapWithMask &closeUnfocusPixmap() { return *m_close_unfocus_pm; }
inline const PixmapWithMask &closePressedPixmap() const { return *m_close_pressed_pm; } inline const FbTk::PixmapWithMask &closePressedPixmap() const { return *m_close_pressed_pm; }
inline PixmapWithMask &closePressedPixmap() { return *m_close_pressed_pm; } inline FbTk::PixmapWithMask &closePressedPixmap() { return *m_close_pressed_pm; }
inline const PixmapWithMask &maximizePixmap() const { return *m_maximize_pm; } inline const FbTk::PixmapWithMask &maximizePixmap() const { return *m_maximize_pm; }
inline PixmapWithMask &maximizePixmap() { return *m_maximize_pm; } inline FbTk::PixmapWithMask &maximizePixmap() { return *m_maximize_pm; }
inline PixmapWithMask &maximizeUnfocusPixmap() { return *m_maximize_unfocus_pm; } inline FbTk::PixmapWithMask &maximizeUnfocusPixmap() { return *m_maximize_unfocus_pm; }
inline const PixmapWithMask &maximizePressedPixmap() const { return *m_maximize_pressed_pm; } inline const FbTk::PixmapWithMask &maximizePressedPixmap() const { return *m_maximize_pressed_pm; }
inline PixmapWithMask &maximizePressedPixmap() { return *m_maximize_pressed_pm; } inline FbTk::PixmapWithMask &maximizePressedPixmap() { return *m_maximize_pressed_pm; }
inline const PixmapWithMask &iconifyPixmap() const { return *m_iconify_pm; } inline const FbTk::PixmapWithMask &iconifyPixmap() const { return *m_iconify_pm; }
inline PixmapWithMask &iconifyPixmap() { return *m_iconify_pm; } inline FbTk::PixmapWithMask &iconifyPixmap() { return *m_iconify_pm; }
inline PixmapWithMask &iconifyUnfocusPixmap() { return *m_iconify_unfocus_pm; } inline FbTk::PixmapWithMask &iconifyUnfocusPixmap() { return *m_iconify_unfocus_pm; }
inline const PixmapWithMask &iconifyPressedPixmap() const { return *m_iconify_pressed_pm; } inline const FbTk::PixmapWithMask &iconifyPressedPixmap() const { return *m_iconify_pressed_pm; }
inline PixmapWithMask &iconifyPressedPixmap() { return *m_iconify_pressed_pm; } inline FbTk::PixmapWithMask &iconifyPressedPixmap() { return *m_iconify_pressed_pm; }
inline const PixmapWithMask &stickPixmap() const { return *m_stick_pm; } inline const FbTk::PixmapWithMask &stickPixmap() const { return *m_stick_pm; }
inline PixmapWithMask &stickPixmap() { return *m_stick_pm; } inline FbTk::PixmapWithMask &stickPixmap() { return *m_stick_pm; }
inline PixmapWithMask &stickUnfocusPixmap() { return *m_stick_unfocus_pm; } inline FbTk::PixmapWithMask &stickUnfocusPixmap() { return *m_stick_unfocus_pm; }
inline const PixmapWithMask &stickPressedPixmap() const { return *m_stick_pressed_pm; } inline const FbTk::PixmapWithMask &stickPressedPixmap() const { return *m_stick_pressed_pm; }
inline PixmapWithMask &stickPressedPixmap() { return *m_stick_pressed_pm; } inline FbTk::PixmapWithMask &stickPressedPixmap() { return *m_stick_pressed_pm; }
inline PixmapWithMask &stuckPixmap() { return *m_stuck_pm; } inline FbTk::PixmapWithMask &stuckPixmap() { return *m_stuck_pm; }
inline PixmapWithMask &stuckUnfocusPixmap() { return *m_stuck_unfocus_pm; } inline FbTk::PixmapWithMask &stuckUnfocusPixmap() { return *m_stuck_unfocus_pm; }
inline const PixmapWithMask &shadePixmap() const { return *m_shade_pm; } inline const FbTk::PixmapWithMask &shadePixmap() const { return *m_shade_pm; }
inline PixmapWithMask &shadePixmap() { return *m_shade_pm; } inline FbTk::PixmapWithMask &shadePixmap() { return *m_shade_pm; }
inline PixmapWithMask &shadeUnfocusPixmap() { return *m_shade_unfocus_pm; } inline FbTk::PixmapWithMask &shadeUnfocusPixmap() { return *m_shade_unfocus_pm; }
inline const PixmapWithMask &shadePressedPixmap() const { return *m_shade_pressed_pm; } inline const FbTk::PixmapWithMask &shadePressedPixmap() const { return *m_shade_pressed_pm; }
inline PixmapWithMask &shadePressedPixmap() { return *m_shade_pressed_pm; } inline FbTk::PixmapWithMask &shadePressedPixmap() { return *m_shade_pressed_pm; }
private: private:
FbTk::ThemeItem<PixmapWithMask> m_close_pm, m_close_unfocus_pm, m_close_pressed_pm; FbTk::ThemeItem<FbTk::PixmapWithMask> m_close_pm, m_close_unfocus_pm, m_close_pressed_pm;
FbTk::ThemeItem<PixmapWithMask> m_maximize_pm, m_maximize_unfocus_pm, m_maximize_pressed_pm; FbTk::ThemeItem<FbTk::PixmapWithMask> m_maximize_pm, m_maximize_unfocus_pm, m_maximize_pressed_pm;
FbTk::ThemeItem<PixmapWithMask> m_iconify_pm, m_iconify_unfocus_pm, m_iconify_pressed_pm; FbTk::ThemeItem<FbTk::PixmapWithMask> m_iconify_pm, m_iconify_unfocus_pm, m_iconify_pressed_pm;
FbTk::ThemeItem<PixmapWithMask> m_shade_pm, m_shade_unfocus_pm, m_shade_pressed_pm; FbTk::ThemeItem<FbTk::PixmapWithMask> m_shade_pm, m_shade_unfocus_pm, m_shade_pressed_pm;
FbTk::ThemeItem<PixmapWithMask> m_stick_pm, m_stick_unfocus_pm, m_stick_pressed_pm; FbTk::ThemeItem<FbTk::PixmapWithMask> m_stick_pm, m_stick_unfocus_pm, m_stick_pressed_pm;
FbTk::ThemeItem<PixmapWithMask> m_stuck_pm, m_stuck_unfocus_pm; FbTk::ThemeItem<FbTk::PixmapWithMask> m_stuck_pm, m_stuck_unfocus_pm;
const FbWinFrameTheme &m_frame_theme; const FbWinFrameTheme &m_frame_theme;
}; };