PageRenderTime 296ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 0ms

/tags/rxvt-2-7-7/src/scrollbar-xterm.c

#
C | 84 lines | 47 code | 10 blank | 27 comment | 5 complexity | df0ad6d2486d86200dfa83a1b4f6a64a MD5 | raw file
  1. /*--------------------------------*-C-*---------------------------------*
  2. * File: scrollbar-xterm.c
  3. *----------------------------------------------------------------------*
  4. * $Id: scrollbar-xterm.c 1464 2001-07-27 06:38:37Z gcw $
  5. *
  6. * Copyright (c) 1997,1998 mj olesen <olesen@me.QueensU.CA>
  7. * Copyright (c) 1999-2001 Geoff Wing <gcw@pobox.com>
  8. *
  9. * This program 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 2 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., 675 Mass Ave, Cambridge, MA 02139, USA.
  22. *----------------------------------------------------------------------*/
  23. #include "../config.h" /* NECESSARY */
  24. #include "rxvt.h" /* NECESSARY */
  25. #include "scrollbar-xterm.intpro" /* PROTOS for internal routines */
  26. /*----------------------------------------------------------------------*/
  27. #define x_stp_width 8
  28. #define x_stp_height 2
  29. const unsigned char x_stp_bits[] = { 0x55, 0xaa };
  30. #define SB_WIDTH_USE (SB_WIDTH_XTERM - 1)
  31. /* EXTPROTO */
  32. int
  33. rxvt_scrollbar_show_xterm(rxvt_t *r, int update __attribute__((unused)), int last_top, int last_bot, int scrollbar_len)
  34. {
  35. int xsb = 0;
  36. if ((r->scrollBar.init & R_SB_XTERM) == 0) {
  37. XGCValues gcvalue;
  38. r->scrollBar.init |= R_SB_XTERM;
  39. gcvalue.stipple = XCreateBitmapFromData(r->Xdisplay, r->scrollBar.win,
  40. (char *)x_stp_bits, x_stp_width,
  41. x_stp_height);
  42. if (!gcvalue.stipple) {
  43. rxvt_print_error("can't create bitmap");
  44. exit(EXIT_FAILURE);
  45. }
  46. gcvalue.fill_style = FillOpaqueStippled;
  47. gcvalue.foreground = r->PixColors[Color_fg];
  48. gcvalue.background = r->PixColors[Color_bg];
  49. r->h->xscrollbarGC = XCreateGC(r->Xdisplay, r->scrollBar.win,
  50. GCForeground | GCBackground
  51. | GCFillStyle | GCStipple, &gcvalue);
  52. gcvalue.foreground = r->PixColors[Color_border];
  53. r->h->ShadowGC = XCreateGC(r->Xdisplay, r->scrollBar.win, GCForeground,
  54. &gcvalue);
  55. }
  56. /* instead of XClearWindow (r->Xdisplay, r->scrollBar.win); */
  57. xsb = (r->Options & Opt_scrollBar_right) ? 1 : 0;
  58. if (last_top < r->scrollBar.top)
  59. XClearArea(r->Xdisplay, r->scrollBar.win,
  60. r->sb_shadow + xsb, last_top,
  61. SB_WIDTH_USE, (r->scrollBar.top - last_top), False);
  62. if (r->scrollBar.bot < last_bot)
  63. XClearArea(r->Xdisplay, r->scrollBar.win,
  64. r->sb_shadow + xsb, r->scrollBar.bot,
  65. SB_WIDTH_USE, (last_bot - r->scrollBar.bot), False);
  66. /* scrollbar slider */
  67. XFillRectangle(r->Xdisplay, r->scrollBar.win, r->h->xscrollbarGC,
  68. xsb + 1, r->scrollBar.top, SB_WIDTH_USE - 2, scrollbar_len);
  69. XDrawLine(r->Xdisplay, r->scrollBar.win, r->h->ShadowGC,
  70. xsb ? 0 : SB_WIDTH_USE, r->scrollBar.beg, xsb ? 0 : SB_WIDTH_USE,
  71. r->scrollBar.end);
  72. return 1;
  73. }
  74. /*----------------------- end-of-file (C source) -----------------------*/