1 /**This file contains the GUI-agnostic base functionality of Figure and Subplot. 2 * FigureBase inherits from it in all GUI ports. 3 * 4 * Copyright (C) 2010-2011 David Simcha 5 * 6 * License: 7 * 8 * Boost Software License - Version 1.0 - August 17th, 2003 9 * 10 * Permission is hereby granted, free of charge, to any person or organization 11 * obtaining a copy of the software and accompanying documentation covered by 12 * this license (the "Software") to use, reproduce, display, distribute, 13 * execute, and transmit the Software, and to prepare derivative works of the 14 * Software, and to permit third-parties to whom the Software is furnished to 15 * do so, all subject to the following: 16 * 17 * The copyright notices in the Software and this entire statement, including 18 * the above license grant, this restriction and the following disclaimer, 19 * must be included in all copies of the Software, in whole or in part, and 20 * all derivative works of the Software, unless such copies or derivative 21 * works are solely in the form of machine-executable object code generated by 22 * a source language processor. 23 * 24 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 25 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 26 * FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT 27 * SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE 28 * FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, 29 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 30 * DEALINGS IN THE SOFTWARE. 31 */ 32 module plot2kill.guiagnosticbase; 33 34 version(dfl) { 35 import plot2kill.dflwrapper; 36 } else { 37 import plot2kill.gtkwrapper; 38 } 39 40 /**This is the base class for all GUI-specific FigureBase objects, and 41 * contains functionality common to Figures and Subplots across all GUIs. 42 */ 43 abstract class GuiAgnosticBase { 44 protected: 45 // These control where on the drawing object the figure is drawn. 46 double xOffset = 0; 47 double yOffset = 0; 48 49 // These control the width and height that we assume we're drawing to. 50 double _width = 0; 51 double _height = 0; 52 53 // Due to bugs in DMD, we can't make the derived classes go through the 54 // official API yet. 55 string _title; 56 string _xLabel; 57 string _yLabel; 58 Font _titleFont; 59 Font _xLabelFont; 60 Font _yLabelFont; 61 62 public: 63 64 abstract void drawImpl() {} 65 abstract int defaultWindowWidth(); 66 abstract int defaultWindowHeight(); 67 abstract int minWindowWidth(); 68 abstract int minWindowHeight(); 69 70 final double width() { 71 return _width; 72 } 73 74 final double height() { 75 return _height; 76 } 77 78 /// 79 final string title()() { 80 return _title; 81 } 82 83 /// 84 final This title(this This)(string newTitle) { 85 _title = newTitle; 86 return cast(This) this; 87 } 88 89 /// 90 final string xLabel()() { 91 return _xLabel; 92 } 93 94 /// 95 final This xLabel(this This)(string newLabel) { 96 _xLabel = newLabel; 97 return cast(This) this; 98 } 99 100 /// 101 final string yLabel()() { 102 return _yLabel; 103 } 104 105 /// 106 final This yLabel(this This)(string newLabel) { 107 _yLabel = newLabel; 108 return cast(This) this; 109 } 110 111 /// 112 final Font titleFont()() { 113 return _titleFont; 114 } 115 116 /// 117 final This titleFont(this This)(Font newTitleFont) { 118 _titleFont = newTitleFont; 119 return cast(This) this; 120 } 121 122 /// 123 final Font xLabelFont()() { 124 return _xLabelFont; 125 } 126 127 /// 128 final This xLabelFont(this This)(Font newLabelFont) { 129 _xLabelFont = newLabelFont; 130 return cast(This) this; 131 } 132 133 /// 134 final Font yLabelFont()() { 135 return _yLabelFont; 136 } 137 138 /// 139 final This yLabelFont(this This)(Font newLabelFont) { 140 _yLabelFont = newLabelFont; 141 return cast(This) this; 142 } 143 } 144 145