// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
#ifndef __renderstyle_hh
#define __renderstyle_hh

#include "rendertexture.hh"
#include "rendercolor.hh"
#include "font.hh"

#include <string>
#include <list>

namespace otk {

struct PixmapMask {
  Pixmap mask;
  unsigned int w, h;
  PixmapMask() { mask = None; w = h = 0; }
};

class RenderStyle;

class StyleNotify {
public:
  //! Called when the style is changed on the same screen as the handler.
  virtual void styleChanged(const RenderStyle &) {}
};

class RenderStyle {
  static RenderStyle **_styles;
  static std::list<StyleNotify*> *_notifies;
public:
  static void initialize();
  static void destroy();
  static void registerNotify(int screen, StyleNotify *n);
  static void unregisterNotify(int screen, StyleNotify *n);
  static RenderStyle *style(int screen);
  
  enum Justify {
    LeftTopJustify,
    RightBottomJustify,
    CenterJustify
  };

private:
  int _screen;
  std::string _file;

  RenderColor *_root_color;
  
  RenderColor *_text_color_focus;
  RenderColor *_text_color_unfocus;

  RenderColor *_button_color_focus;
  RenderColor *_button_color_unfocus;

  RenderColor *_frame_border_color;
  int _frame_border_width;

  RenderColor *_client_border_color_focus; 
  RenderColor *_client_border_color_unfocus;
  int _client_border_width;
 
  RenderTexture *_titlebar_focus;
  RenderTexture *_titlebar_unfocus;

  RenderTexture *_label_focus;
  RenderTexture *_label_unfocus;

  RenderTexture *_handle_focus;
  RenderTexture *_handle_unfocus;

  RenderTexture *_button_unpress_focus;
  RenderTexture *_button_unpress_unfocus;
  RenderTexture *_button_press_focus;
  RenderTexture *_button_press_unfocus;

  RenderTexture *_grip_focus;
  RenderTexture *_grip_unfocus;

  Font *_label_font;
  Justify _label_justify;

  PixmapMask *_max_mask;
  PixmapMask *_icon_mask;
  PixmapMask *_alldesk_mask;
  PixmapMask *_close_mask;

  int _handle_width;
  int _bevel_width;

public:
  RenderStyle(int screen, const std::string &stylefile);
  virtual ~RenderStyle();

  inline int screen() const { return _screen; }
  
  inline RenderColor *rootColor() const { return _root_color; }
  
  inline RenderColor *textFocusColor() const { return _text_color_focus; }
  inline RenderColor *textUnfocusColor() const { return _text_color_unfocus; }

  inline RenderColor *buttonFocusColor() const { return _button_color_focus; }
  inline RenderColor *buttonUnfocusColor() const
    { return _button_color_unfocus; }

  inline RenderColor *frameBorderColor() const { return _frame_border_color; }
  inline int frameBorderWidth() const { return _frame_border_width; }

  inline RenderColor *clientBorderFocusColor() const
    { return _client_border_color_focus; }
  inline RenderColor *clientBorderUnfocusColor() const
    { return _client_border_color_unfocus; }
  inline int clientBorderWidth() const { return _client_border_width; }
 
  inline RenderTexture *titlebarFocusBackground() const
    { return _titlebar_focus; }
  inline RenderTexture *titlebarUnfocusBackground() const
    { return _titlebar_unfocus; }

  inline RenderTexture *labelFocusBackground() const { return _label_focus; }
  inline RenderTexture *labelUnfocusBackground() const { return _label_unfocus;}

  inline RenderTexture *handleFocusBackground() const { return _handle_focus; }
  inline RenderTexture *handleUnfocusBackground() const
    { return _handle_unfocus; }

  inline RenderTexture *buttonUnpressFocusBackground() const
    { return _button_unpress_focus; }
  inline RenderTexture *buttonUnpressUnfocusBackground() const
    { return _button_unpress_unfocus; }
  inline RenderTexture *buttonPressFocusBackground() const
    { return _button_press_focus; }
  inline RenderTexture *buttonPressUnfocusBackground() const
    { return _button_press_unfocus; }

  inline RenderTexture *gripFocusBackground() const { return _grip_focus; }
  inline RenderTexture *gripUnfocusBackground() const { return _grip_unfocus; }

  inline Font *labelFont() const { return _label_font; }
  inline Justify labelTextJustify() const { return _label_justify; }

  inline PixmapMask *maximizeMask() const { return _max_mask; }
  inline PixmapMask *iconifyMask() const { return _icon_mask; }
  inline PixmapMask *alldesktopsMask() const { return _alldesk_mask; }
  inline PixmapMask *closeMask() const { return _close_mask; }
  
  inline int handleWidth() const { return _handle_width; }
  inline int bevelWidth() const { return _bevel_width; }
};

}

#endif // __rendertexture_hh