00001 /* 00002 libwt - Vassilis Virvilis Toolkit - a widget library 00003 Copyright (C) 2006 Vassilis Virvilis <vasvir2@fastmail.fm> 00004 00005 This library is free software; you can redistribute it and/or 00006 modify it under the terms of the GNU Lesser General Public 00007 License as published by the Free Software Foundation; either 00008 version 2.1 of the License, or (at your option) any later version. 00009 00010 This library is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 Lesser General Public License for more details. 00014 00015 You should have received a copy of the GNU Lesser General Public 00016 License along with this library; if not, write to the 00017 Free Software Foundation, Inc., 59 Temple Place - Suite 330, 00018 Boston, MA 02111-1307, SA. 00019 */ 00020 00021 #ifndef WT_WINDOW_H 00022 #define WT_WINDOW_H 00023 00024 #include <wt/box.h> 00025 00026 namespace Wt { 00027 class Label; 00028 00029 class Window : public Widget { 00030 public: 00031 Window(Widget *parent = 0, const std::string &name = "Window::anon", int wflags = 0); 00032 00033 // Including the window frame 00034 // if frame is NULL then window is a sytem top level. 00035 /// \todo query SDL when frame_ == NULL 00036 Rect frameGeometry() const { 00037 return (frame_) ? frame_->geometry() : geometry(); 00038 } 00039 00040 int x() const { 00041 return frameGeometry().x(); 00042 } 00043 00044 int y() const { 00045 return frameGeometry().y(); 00046 } 00047 00048 Point pos() const { 00049 return frameGeometry().topLeft(); 00050 } 00051 00052 Size frameSize() const { 00053 return frameGeometry().size(); 00054 } 00055 00056 virtual void setTitleFont(const Font& font); 00057 const Font& titleFont() const; 00058 virtual void setTitle(const std::string& text); 00059 std::string title() const; 00060 void setTitleColor(const Color& color); 00061 const Color& titleColor() const; 00062 void setTitleBarColor(const Color& color); 00063 const Color& titleBarColor() const; 00064 virtual void setBackgroundColor(const Color& color); 00065 00066 void raise(); 00067 void lower(); 00068 00069 virtual void hide(); 00070 virtual void show(); 00071 00072 protected: 00073 // Layout needs to distinguish Window::Frames 00074 friend class Layout; 00075 00076 class Frame : public VBox { 00077 public: 00078 Frame(Widget *parent = 0, 00079 const std::string &name = "WindowFrame::anon", int wflags = 0); 00080 00081 virtual void setFont(const Font& font); 00082 const Font& font() const; 00083 void setText(const std::string& text); 00084 std::string text() const; 00085 virtual void setForegroundColor(const Color& color); 00086 const Color& foregroundColor() const; 00087 virtual void setBackgroundColor(const Color& color); 00088 const Color& backgroundColor() const; 00089 00090 protected: 00091 virtual void childEvent(ChildEvent *); 00092 virtual void mouseMoveEvent(MouseEvent *); 00093 virtual void mousePressEvent(MouseEvent *); 00094 virtual void mouseReleaseEvent(MouseEvent *); 00095 virtual void enterEvent(Event *); 00096 virtual void leaveEvent(Event *); 00097 00098 private: 00099 HBox *titlebar_b; 00100 Label *title_; 00101 Point pos_start_; 00102 Point topleft_start_; 00103 bool pressed_; 00104 }; 00105 00106 private: 00107 Frame *frame_; 00108 }; 00109 00110 } 00111 #endif // WT_WINDOW_H
This document is licensed under the terms of the GNU Free Documentation License and may be freely distributed under the conditions given by this license.