aboutsummaryrefslogtreecommitdiff
path: root/src/FbTk
diff options
context:
space:
mode:
authorfluxgen <fluxgen>2004-01-11 12:52:37 (GMT)
committerfluxgen <fluxgen>2004-01-11 12:52:37 (GMT)
commit766a385c831125530ba005735c98c0d3d44a1655 (patch)
tree417cacbe48108f7d5f1722d9f760570ddcc9a870 /src/FbTk
parentabe0204256a567799ea7f97db64e1153c5578660 (diff)
downloadfluxbox-766a385c831125530ba005735c98c0d3d44a1655.zip
fluxbox-766a385c831125530ba005735c98c0d3d44a1655.tar.bz2
cleaning, using FbPixmap
Diffstat (limited to 'src/FbTk')
-rw-r--r--src/FbTk/TextureRender.cc130
1 files changed, 60 insertions, 70 deletions
diff --git a/src/FbTk/TextureRender.cc b/src/FbTk/TextureRender.cc
index f1f1103..669f067 100644
--- a/src/FbTk/TextureRender.cc
+++ b/src/FbTk/TextureRender.cc
@@ -22,12 +22,14 @@
22// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 22// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23// DEALINGS IN THE SOFTWARE. 23// DEALINGS IN THE SOFTWARE.
24 24
25// $Id: TextureRender.cc,v 1.5 2003/10/02 16:14:41 rathnor Exp $ 25// $Id: TextureRender.cc,v 1.6 2004/01/11 12:52:37 fluxgen Exp $
26 26
27#include "TextureRender.hh" 27#include "TextureRender.hh"
28 28
29#include "ImageControl.hh" 29#include "ImageControl.hh"
30#include "App.hh" 30#include "App.hh"
31#include "FbPixmap.hh"
32#include "GContext.hh"
31 33
32#include <iostream> 34#include <iostream>
33#include <string> 35#include <string>
@@ -114,94 +116,85 @@ Pixmap TextureRender::renderSolid(const FbTk::Texture &texture) {
114 116
115 Display *disp = FbTk::App::instance()->display(); 117 Display *disp = FbTk::App::instance()->display();
116 118
117 Pixmap pixmap = XCreatePixmap(disp, 119 FbPixmap pixmap(RootWindow(disp, control.screenNum()),
118 RootWindow(disp, control.screenNum()), width, 120 width, height,
119 height, control.depth()); 121 control.depth());
120 if (pixmap == None) { 122
123 if (pixmap.drawable() == None) {
121 cerr<<"FbTk::TextureRender::render_solid(): error creating pixmap"<<endl; 124 cerr<<"FbTk::TextureRender::render_solid(): error creating pixmap"<<endl;
122 return None; 125 return None;
123 } 126 }
124 127
125 XGCValues gcv;
126 GC gc, hgc, lgc;
127 128
128 gcv.foreground = texture.color().pixel(); 129 FbTk::GContext gc(pixmap),
129 gcv.fill_style = FillSolid; 130 hgc(pixmap), lgc(pixmap);
130 gc = XCreateGC(disp, pixmap, GCForeground | GCFillStyle, &gcv);
131 131
132 gcv.foreground = texture.hiColor().pixel(); 132 gc.setForeground(texture.color());
133 hgc = XCreateGC(disp, pixmap, GCForeground, &gcv); 133 gc.setFillStyle(FillSolid);
134 134
135 gcv.foreground = texture.loColor().pixel(); 135 hgc.setForeground(texture.hiColor());
136 lgc = XCreateGC(disp, pixmap, GCForeground, &gcv);
137 136
138 XFillRectangle(disp, pixmap, gc, 0, 0, width, height); 137 pixmap.fillRectangle(gc.gc(), 0, 0, width, height);
139 138
140 using namespace FbTk; 139 using namespace FbTk;
141 140
142 if (texture.type() & Texture::INTERLACED) { 141 if (texture.type() & Texture::INTERLACED) {
143 gcv.foreground = texture.colorTo().pixel(); 142 lgc.setForeground(texture.colorTo());
144 GC igc = XCreateGC(disp, pixmap,
145 GCForeground, &gcv);
146
147 register unsigned int i = 0; 143 register unsigned int i = 0;
148 for (; i < height; i += 2) 144 for (; i < height; i += 2)
149 XDrawLine(disp, pixmap, igc, 0, i, width, i); 145 pixmap.drawLine(lgc.gc(), 0, i, width, i);
150 146
151 XFreeGC(disp, igc);
152 } 147 }
153 148
149 lgc.setForeground(texture.loColor());
150
154 if (texture.type() & Texture::BEVEL1) { 151 if (texture.type() & Texture::BEVEL1) {
155 if (texture.type() & Texture::RAISED) { 152 if (texture.type() & Texture::RAISED) {
156 XDrawLine(disp, pixmap, lgc, 153 pixmap.drawLine(lgc.gc(),
157 0, height - 1, width - 1, height - 1); 154 0, height - 1, width - 1, height - 1);
158 XDrawLine(disp, pixmap, lgc, 155 pixmap.drawLine(lgc.gc(),
159 width - 1, height - 1, width - 1, 0); 156 width - 1, height - 1, width - 1, 0);
160 157
161 XDrawLine(disp, pixmap, hgc, 158 pixmap.drawLine(hgc.gc(),
162 0, 0, width - 1, 0); 159 0, 0, width - 1, 0);
163 XDrawLine(disp, pixmap, hgc, 160 pixmap.drawLine(hgc.gc(),
164 0, height - 1, 0, 0); 161 0, height - 1, 0, 0);
165 } else if (texture.type() & Texture::SUNKEN) { 162 } else if (texture.type() & Texture::SUNKEN) {
166 XDrawLine(disp, pixmap, hgc, 163 pixmap.drawLine(hgc.gc(),
167 0, height - 1, width - 1, height - 1); 164 0, height - 1, width - 1, height - 1);
168 XDrawLine(disp, pixmap, hgc, 165 pixmap.drawLine(hgc.gc(),
169 width - 1, height - 1, width - 1, 0); 166 width - 1, height - 1, width - 1, 0);
170 167
171 XDrawLine(disp, pixmap, lgc, 168 pixmap.drawLine(lgc.gc(),
172 0, 0, width - 1, 0); 169 0, 0, width - 1, 0);
173 XDrawLine(disp, pixmap, lgc, 170 pixmap.drawLine(lgc.gc(),
174 0, height - 1, 0, 0); 171 0, height - 1, 0, 0);
175 } 172 }
176 } else if (texture.type() & Texture::BEVEL2) { 173 } else if (texture.type() & Texture::BEVEL2) {
177 if (texture.type() & Texture::RAISED) { 174 if (texture.type() & Texture::RAISED) {
178 XDrawLine(disp, pixmap, lgc, 175 pixmap.drawLine(lgc.gc(),
179 1, height - 3, width - 3, height - 3); 176 1, height - 3, width - 3, height - 3);
180 XDrawLine(disp, pixmap, lgc, 177 pixmap.drawLine(lgc.gc(),
181 width - 3, height - 3, width - 3, 1); 178 width - 3, height - 3, width - 3, 1);
182 179
183 XDrawLine(disp, pixmap, hgc, 180 pixmap.drawLine(hgc.gc(),
184 1, 1, width - 3, 1); 181 1, 1, width - 3, 1);
185 XDrawLine(disp, pixmap, hgc, 182 pixmap.drawLine(hgc.gc(),
186 1, height - 3, 1, 1); 183 1, height - 3, 1, 1);
187 } else if (texture.type() & Texture::SUNKEN) { 184 } else if (texture.type() & Texture::SUNKEN) {
188 XDrawLine(disp, pixmap, hgc, 185 pixmap.drawLine(hgc.gc(),
189 1, height - 3, width - 3, height - 3); 186 1, height - 3, width - 3, height - 3);
190 XDrawLine(disp, pixmap, hgc, 187 pixmap.drawLine(hgc.gc(),
191 width - 3, height - 3, width - 3, 1); 188 width - 3, height - 3, width - 3, 1);
192 189
193 XDrawLine(disp, pixmap, lgc, 190 pixmap.drawLine(lgc.gc(),
194 1, 1, width - 3, 1); 191 1, 1, width - 3, 1);
195 XDrawLine(disp, pixmap, lgc, 192 pixmap.drawLine(lgc.gc(),
196 1, height - 3, 1, 1); 193 1, height - 3, 1, 1);
197 } 194 }
198 } 195 }
199 196
200 XFreeGC(disp, gc); 197 return pixmap.release();
201 XFreeGC(disp, hgc);
202 XFreeGC(disp, lgc);
203
204 return pixmap;
205} 198}
206 199
207 200
@@ -666,11 +659,10 @@ return image;
666 659
667Pixmap TextureRender::renderPixmap() { 660Pixmap TextureRender::renderPixmap() {
668 Display *disp = FbTk::App::instance()->display(); 661 Display *disp = FbTk::App::instance()->display();
669 Pixmap pixmap = 662 FbPixmap pixmap(RootWindow(disp, control.screenNum()),
670 XCreatePixmap(disp, 663 width, height, control.depth());
671 RootWindow(disp, control.screenNum()), width, height, control.depth());
672 664
673 if (pixmap == None) { 665 if (pixmap.drawable() == None) {
674 cerr<<"TextureRender::renderPixmap(): error creating pixmap"<<endl; 666 cerr<<"TextureRender::renderPixmap(): error creating pixmap"<<endl;
675 return None; 667 return None;
676 } 668 }
@@ -678,15 +670,13 @@ Pixmap TextureRender::renderPixmap() {
678 XImage *image = renderXImage(); 670 XImage *image = renderXImage();
679 671
680 if (! image) { 672 if (! image) {
681 XFreePixmap(disp, pixmap);
682 return None; 673 return None;
683 } else if (! image->data) { 674 } else if (! image->data) {
684 XDestroyImage(image); 675 XDestroyImage(image);
685 XFreePixmap(disp, pixmap);
686 return None; 676 return None;
687 } 677 }
688 678
689 XPutImage(disp, pixmap, 679 XPutImage(disp, pixmap.drawable(),
690 DefaultGC(disp, control.screenNum()), 680 DefaultGC(disp, control.screenNum()),
691 image, 0, 0, 0, 0, width, height); 681 image, 0, 0, 0, 0, width, height);
692 682
@@ -697,7 +687,7 @@ Pixmap TextureRender::renderPixmap() {
697 687
698 XDestroyImage(image); 688 XDestroyImage(image);
699 689
700 return pixmap; 690 return pixmap.release();
701} 691}
702 692
703 693