1 /** 2 * File name: RkWindowX.h 3 * Project: Redkite (A small GUI toolkit) 4 * 5 * Copyright (C) 2019 Iurie Nistor (http://quamplex.com/redkite) 6 * 7 * This file is part of Redkite. 8 * 9 * Redkite is free software; you can redistribute it and/or modify 10 * it under the terms of the GNU General Public License as published by 11 * the Free Software Foundation; either version 3 of the License, or 12 * (at your option) any later version. 13 * 14 * This program is distributed in the hope that it will be useful, 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 * GNU General Public License for more details. 18 * 19 * You should have received a copy of the GNU General Public License 20 * along with this program; if not, write to the Free Software 21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 */ 23 24 #ifndef RK_WINDOW_X_H 25 #define RK_WINDOW_X_H 26 27 #include "Rk.h" 28 #include "RkPlatform.h" 29 #include "RkSize.h" 30 #include "RkPoint.h" 31 #include "RkColor.h" 32 33 #include <X11/Xutil.h> 34 35 struct RkCanvasInfo; 36 37 class RkWindowX { 38 public: 39 explicit RkWindowX(const RkNativeWindowInfo *parent, 40 Rk::WindowFlags flags = Rk::WindowFlags::Widget, 41 bool isTop = false); 42 explicit RkWindowX(const RkNativeWindowInfo &parent, 43 Rk::WindowFlags flags = Rk::WindowFlags::Widget, 44 bool isTop = false); 45 ~RkWindowX(); 46 Rk::WindowFlags flags() const; 47 bool init(); 48 void show(bool b); 49 const RkNativeWindowInfo* nativeWindowInfo() const; 50 void setTitle(const std::string &title); 51 Display* display() const; 52 RkSize size() const; 53 void setSize(const RkSize &size); 54 RkPoint position() const; 55 void setPosition(const RkPoint &position); 56 RkWindowId id() const; 57 void setBorderWidth(int width); 58 int borderWidth() const; 59 void setBorderColor(const RkColor &color); 60 const RkColor& borderColor() const; 61 void setBackgroundColor(const RkColor &color); 62 const RkColor& background() const; 63 void resizeCanvas(); 64 const RkCanvasInfo* getCanvasInfo() const; 65 void update(); 66 void setFocus(bool b); 67 bool hasFocus() const; 68 void setPointerShape(Rk::PointerShape shape); 69 bool pointerIsOverWindow() const; 70 void setScaleFactor(double factor); 71 double getScaleFactor() const; 72 73 protected: 74 bool openDisplay(); 75 bool isWindowCreated() const; 76 bool hasParent() const; 77 void createCanvasInfo(); 78 void freeCanvasInfo(); 79 80 private: 81 RK_DISABLE_COPY(RkWindowX); 82 RK_DISABLE_MOVE(RkWindowX); 83 RkNativeWindowInfo parentWindowInfo; 84 Rk::WindowFlags windowFlags; 85 Display *xDisplay; 86 int screenNumber; 87 Window xWindow; 88 Atom deleteWindowAtom; 89 mutable RkPoint windowPosition; 90 mutable RkSize windowSize; 91 int winBorderWidth; 92 RkColor winBorderColor; 93 RkColor winBackgroundColor; 94 std::unique_ptr<RkCanvasInfo> canvasInfo; 95 std::unique_ptr<RkNativeWindowInfo> windowInfo; 96 XVisualInfo visualInfo; 97 double scaleFactor; 98 bool isTopWindow; 99 }; 100 101 #endif // RK_WIDGET_XWIN_H 102