Back to index

texmacs  1.0.7.15
layout.cpp
Go to the documentation of this file.
00001 
00002 /******************************************************************************
00003 * MODULE     : layout.cpp
00004 * DESCRIPTION: some general routines for the layout of widgets
00005 * COPYRIGHT  : (C) 1999  Joris van der Hoeven
00006 *******************************************************************************
00007 * This software falls under the GNU general public license version 3 or later.
00008 * It comes WITHOUT ANY WARRANTY WHATSOEVER. For details, see the file LICENSE
00009 * in the root directory or <http://www.gnu.org/licenses/gpl-3.0.html>.
00010 ******************************************************************************/
00011 
00012 #include "window.hpp"
00013 
00014 color layout_pastel (renderer ren) { return rgb_color (228, 228, 220); }
00015 color layout_light (renderer ren) { return light_grey; }
00016 color layout_normal (renderer ren) { return grey; }
00017 color layout_dark (renderer ren) { return dark_grey; }
00018 
00019 void
00020 layout_pastel (renderer ren, SI x1, SI y1, SI x2, SI y2) {
00021   ren->set_background (layout_pastel (ren));
00022   ren->set_color (layout_pastel (ren));
00023   ren->fill (x1, y1, x2, y2);
00024 }
00025 
00026 void
00027 layout_default (renderer ren, SI x1, SI y1, SI x2, SI y2) {
00028   ren->set_background (layout_light (ren));
00029   ren->set_color (layout_light (ren));
00030   ren->fill (x1, y1, x2, y2);
00031 }
00032 
00033 void
00034 layout_dark (renderer ren, SI x1, SI y1, SI x2, SI y2) {
00035   ren->set_background (layout_normal (ren));
00036   ren->set_color (layout_normal (ren));
00037   ren->fill (x1, y1, x2, y2);
00038 }
00039 
00040 void
00041 layout_outline (renderer ren, SI x1, SI y1, SI x2, SI y2) {
00042   ren->set_line_style (PIXEL);
00043   ren->set_color (layout_light (ren));
00044   ren->line (x1, y1, x2, y1);
00045   ren->line (x2- PIXEL, y1, x2- PIXEL, y2- PIXEL);
00046   ren->line (x1, y2- PIXEL, x2, y2- PIXEL);
00047   ren->line (x1, y1, x1, y2- PIXEL);
00048 }
00049 
00050 void
00051 layout_dark_outline (renderer ren, SI x1, SI y1, SI x2, SI y2) {
00052   ren->set_line_style (PIXEL);
00053   ren->set_color (layout_dark (ren));
00054   ren->line (x1, y1, x2, y1);
00055   ren->line (x2- PIXEL, y1, x2- PIXEL, y2- PIXEL);
00056   ren->line (x1, y2- PIXEL, x2, y2- PIXEL);
00057   ren->line (x1, y1, x1, y2- PIXEL);
00058 }
00059 
00060 void
00061 layout_pastel_lower (renderer ren, SI x1, SI y1, SI x2, SI y2) {
00062   layout_pastel (ren, x1, y1, x2, y2);
00063   ren->set_line_style (PIXEL);
00064   ren->set_color (white);
00065   ren->line (x1, y1, x2-PIXEL, y1);
00066   ren->line (x2- PIXEL, y1, x2- PIXEL, y2- PIXEL);
00067   ren->set_color (layout_normal (ren));
00068   ren->line (x1, y2- PIXEL, x2, y2- PIXEL);
00069   ren->line (x1, y1, x1, y2- PIXEL);
00070 }
00071 
00072 void
00073 layout_lower (renderer ren, SI x1, SI y1, SI x2, SI y2) {
00074   ren->set_line_style (PIXEL);
00075   ren->set_color (white);
00076   ren->line (x1, y1, x2-PIXEL, y1);
00077   ren->line (x2- PIXEL, y1, x2- PIXEL, y2- PIXEL);
00078   ren->set_color (layout_dark (ren));
00079   ren->line (x1, y2- PIXEL, x2, y2- PIXEL);
00080   ren->line (x1, y1, x1, y2- PIXEL);
00081 }
00082 
00083 void
00084 layout_higher (renderer ren, SI x1, SI y1, SI x2, SI y2) {
00085   ren->set_line_style (PIXEL);
00086   ren->set_color (layout_dark (ren));
00087   ren->line (x1, y1, x2- PIXEL, y1);
00088   ren->line (x2- PIXEL, y1, x2- PIXEL, y2- PIXEL);
00089   ren->set_color (white);
00090   ren->line (x1, y2- PIXEL, x2, y2- PIXEL);
00091   ren->line (x1, y1, x1, y2- PIXEL);
00092 }
00093 
00094 void
00095 layout_submenu_triangle (renderer ren, SI x, SI y) {
00096   ren->set_line_style (PIXEL);
00097   ren->set_color (layout_normal (ren));
00098   ren->triangle (x, y-3*PIXEL, x, y+3*PIXEL, x+7*PIXEL, y);
00099   ren->set_color (layout_dark (ren));
00100   ren->line (x, y-3*PIXEL, x, y+3*PIXEL);
00101   ren->line (x, y+3*PIXEL, x+7*PIXEL, y);
00102   ren->set_color (white);
00103   ren->line (x, y-3*PIXEL, x+7*PIXEL, y);
00104 }
00105 
00106 void
00107 layout_pulldown_triangle (renderer ren, SI x, SI y) {
00108   ren->set_line_style (PIXEL);
00109   ren->set_color (layout_normal (ren));
00110   ren->triangle (x-4*PIXEL, y, x+4*PIXEL, y, x, y-4*PIXEL);
00111   ren->set_color (layout_dark (ren));
00112   ren->line (x+4*PIXEL, y, x, y-4*PIXEL);
00113   ren->set_color (white);
00114   ren->line (x-4*PIXEL, y, x+4*PIXEL, y);
00115   ren->line (x-4*PIXEL, y, x, y-4*PIXEL);
00116 }
00117 
00118 void
00119 layout_pulldown_dash (renderer ren, SI x, SI y, SI w) {
00120   /*
00121   ren->set_line_style (PIXEL);
00122   ren->set_color (layout_dark (ren));
00123   ren->line (x+PIXEL, y, x+w-PIXEL, y);
00124   ren->set_color (layout_normal (ren));
00125   ren->line (x+PIXEL, y+PIXEL, x+w, y+PIXEL);
00126   ren->set_color (white);
00127   ren->line (x+PIXEL, y, x+PIXEL, y);
00128   ren->line (x, y+PIXEL, x+2*PIXEL, y+PIXEL);
00129   ren->line (x+PIXEL, y+2*PIXEL, x+w-PIXEL, y+2*PIXEL);
00130   */
00131 
00132   SI offset, inc= 3*PIXEL;
00133   bool parity= false;
00134   ren->set_line_style (PIXEL);
00135 
00136   for (offset= 0; offset<w; offset += inc, parity= !parity) {
00137     SI pos= x + offset;
00138     ren->set_color (parity? layout_normal (ren): layout_dark (ren));
00139     ren->line (pos, y, min (pos+inc, x+w), y);
00140     ren->set_color (parity? layout_normal (ren): white);
00141     ren->line (pos, y + PIXEL, min (pos+inc, x+w), y + PIXEL);
00142   }
00143 }
00144 
00145 void
00146 layout_up_arrow (renderer ren, SI x, SI y, SI w, SI h) {
00147   w -= PIXEL; h -= PIXEL; SI hw= ((w/PIXEL)>>1)*PIXEL;
00148   ren->set_line_style (PIXEL);
00149   ren->set_color (layout_normal (ren));
00150   ren->triangle (x, y, x+w, y, x+hw, y+h);
00151   ren->set_color (layout_dark (ren));
00152   ren->line (x, y, x+w, y);
00153   ren->line (x+w, y, x+hw, y+h);
00154   ren->set_color (white);
00155   ren->line (x, y, x+hw, y+h);
00156 }
00157 
00158 void
00159 layout_down_arrow (renderer ren, SI x, SI y, SI w, SI h) {
00160   w -= PIXEL; h -= PIXEL; SI hw= ((w/PIXEL)>>1)*PIXEL;
00161   ren->set_line_style (PIXEL);
00162   ren->set_color (layout_normal (ren));
00163   ren->triangle (x, y+h, x+w, y+h, x+hw, y);
00164   ren->set_color (layout_dark (ren));
00165   ren->line (x+w, y+h, x+hw, y);
00166   ren->set_color (white);
00167   ren->line (x, y+h, x+w, y+h);
00168   ren->line (x, y+h, x+hw, y);
00169 }
00170 
00171 void
00172 layout_left_arrow (renderer ren, SI x, SI y, SI w, SI h) {
00173   w -= PIXEL; h -= PIXEL; SI hh= ((h/PIXEL)>>1)*PIXEL;
00174   ren->set_line_style (PIXEL);
00175   ren->set_color (layout_normal (ren));
00176   ren->triangle (x+w, y+w, x+w, y+h, x, y+hh);
00177   ren->set_color (layout_dark (ren));
00178   ren->line (x+w, y, x+w, y+h);
00179   ren->line (x+w, y, x, y+hh);
00180   ren->set_color (white);
00181   ren->line (x+w, y+h, x, y+hh);
00182 }
00183 
00184 void
00185 layout_right_arrow (renderer ren, SI x, SI y, SI w, SI h) {
00186   w -= PIXEL; h -= PIXEL; SI hh= ((h/PIXEL)>>1)*PIXEL;
00187   ren->set_line_style (PIXEL);
00188   ren->set_color (layout_normal (ren));
00189   ren->triangle (x, y, x, y+h, x+w, y+hh);
00190   ren->set_color (layout_dark (ren));
00191   ren->line (x, y, x+w, y+hh);
00192   ren->set_color (white);
00193   ren->line (x, y+h, x+w, y+hh);
00194   ren->line (x, y, x, y+h);
00195 }