home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 22 gnu / 22-gnu.zip / gwm18a.zip / data / mwm-win.gwm < prev    next >
Text File  |  1995-07-03  |  28KB  |  950 lines

  1. ;;File: mwm-win.gwm -- mwm-like frame
  2. ;;Author: Frederic CHARTON
  3. ;;Revision: 1.1 -- Marc 2 1990
  4.  
  5. (: mwm-ed-borderwidth 0)
  6.  
  7. ; STANDARD BEHAVIOR OF WINDOWS :
  8. ; ============================
  9. (: window-std-behavior
  10.    (state-make
  11.         (on focus-out (progn ;(? "focus leaving window " window-name "\n") 
  12.                  (maintain-focus-out)))
  13.         (on focus-in (progn ;(? "focus entering window " window-name "\n")
  14.                 (maintain-focus-in)))
  15.         (on (user-event 'resize-by-menu)
  16.                 (progn
  17.                 (set-focus)
  18.                 (warp-pointer (/ window-width 2) (/ window-height 2) window)
  19.                 (with  (cursor cross-cursor) (grab-server window 'only))
  20.                 (: resize-flag window)))
  21.         (if (= keyboardFocusPolicy 'explicit)
  22.         (on leave-window
  23.          (if (not (current-event-from-grab))
  24.           (progn
  25.                 (if (= resize-flag window)
  26.                 (progn  (: resize-flag ())
  27.                         (ungrab-server)
  28.                         (with (mwm-resize-style-catch-corners 1 
  29.                    old mwm-resize-style-corner-size)
  30.                   (: mwm-resize-style-corner-size 
  31.                 (# 'resize-corner-size window))
  32.                   (resize-window)
  33.                   (: mwm-resize-style-corner-size old)
  34.             )
  35.                 )
  36.                              (send-user-event 'leave-window))
  37.           )
  38.      )
  39.     )
  40.         (on leave-window
  41.          (if (not (current-event-from-grab))
  42.           (progn
  43.                 (if (= resize-flag window)
  44.                  (progn  (: resize-flag ())
  45.                          (ungrab-server)
  46.                          (with (mwm-resize-style-catch-corners 1
  47.                 old mwm-resize-style-corner-size) 
  48.                    (: mwm-resize-style-corner-size 
  49.                     (# 'resize-corner-size window))
  50.                 (resize-window)
  51.                   (: mwm-resize-style-corner-size old)
  52.             )
  53.  
  54.                  )
  55.                 )
  56.                 (set-focus ())
  57.           )
  58.       (with (cmp (current-mouse-position)
  59.          cmpx (- (# 0 cmp) window-x) cmpy (- (# 1 cmp) window-y)
  60.         )
  61.        (if (not (and (> cmpx 0) (> cmpy 0) 
  62.              (< cmpx window-width) 
  63.              (< cmpy window-height)))
  64.         (set-focus ())
  65.        )
  66.       )
  67.          )
  68.         )
  69.         )
  70.  
  71.         (if (= keyboardFocusPolicy 'explicit)
  72.          (on enter-window
  73.           (if (not (# 'got-focus window-property))
  74.             (set-grabs (replayable-event (buttonpress 1 alone)))
  75.       )
  76.      )
  77.          (on enter-window (set-focus)) 
  78.     )
  79.  
  80.         (if (= keyboardFocusPolicy 'explicit)
  81.          (on (buttonpress 1 alone)
  82.                (if (not (# 'got-focus window-property))
  83.                 (progn
  84.                  (set-focus)
  85.                  (if (not (= resize-flag window)) (: resize-flag ()))
  86.                  (if passSelectButton 
  87.                      (ungrab-server-and-replay-event ())
  88.                    (allow-event-processing))
  89.                  (unset-grabs (buttonpress 1 alone) )
  90.                 )
  91.                 (progn ; has focus already, got this by mistake
  92.                   (ungrab-server-and-replay-event ())
  93.                   (unset-grabs (buttonpress 1 alone) )))
  94.      )
  95.         )
  96.         (on name-change (send-user-event 'name-change))
  97.     (on (property-change "WM_ICON_NAME")
  98.         (if (window-icon?)
  99.         (send-user-event 'name-change window-icon)))
  100.         (on window-icon-pixmap-change
  101.                 (send-user-event 'icon-pixmap-change window-icon))
  102.        )
  103. )
  104.  
  105. ;-------------------------------------------------------------------------
  106.  
  107.  
  108. ; THE TILES :
  109. ; =========
  110.  
  111. (: shadowed-vbar-tile 
  112.     (with (foreground clientBackground theTile (pixmap-make resizeBorderWidth 1))
  113.         (with (foreground clientTopShadowColor) 
  114.          (draw-line theTile 0 0 1 0))
  115.         (with (foreground clientBottomShadowColor) 
  116.          (draw-line theTile (- resizeBorderWidth 1) 0  (- resizeBorderWidth 2) 0))
  117.      theTile
  118.     )
  119. )
  120.  
  121. (: active-shadowed-vbar-tile 
  122.     (with (foreground clientActiveBackground theTile (pixmap-make resizeBorderWidth 1))
  123.         (with (foreground clientActiveTopShadowColor) 
  124.          (draw-line theTile 0 0 1 0))
  125.         (with (foreground clientActiveBottomShadowColor) 
  126.          (draw-line theTile (- resizeBorderWidth 1) 0  (- resizeBorderWidth 2) 0))
  127.      theTile
  128.     )
  129. )
  130.  
  131. (: shadowed-hbar-tile 
  132.     (with (foreground clientBackground theTile (pixmap-make 1 resizeBorderWidth))
  133.         (with (foreground clientTopShadowColor) 
  134.          (draw-line theTile 0 0 0 1))
  135.         (with (foreground clientBottomShadowColor) 
  136.          (draw-line theTile 0 (- resizeBorderWidth 1) 0  (- resizeBorderWidth 2)))
  137.      theTile
  138.     )
  139. )
  140.  
  141. (: active-shadowed-hbar-tile 
  142.     (with (foreground clientActiveBackground theTile (pixmap-make 1 resizeBorderWidth))
  143.         (with (foreground clientActiveTopShadowColor) 
  144.          (draw-line theTile 0 0 0 1))
  145.         (with (foreground clientActiveBottomShadowColor) 
  146.          (draw-line theTile 0 (- resizeBorderWidth 1) 0  (- resizeBorderWidth 2)))
  147.      theTile
  148.     )
  149. )
  150.  
  151. (: border-vbar-tile
  152.     (with (foreground clientBackground theTile (pixmap-make frameBorderwidth 1)
  153.            foreground clientTopShadowColor)
  154.      (draw-line theTile 0 0 1 0)
  155.      (with (foreground clientBottomShadowColor)
  156.       (draw-line theTile (- frameBorderwidth 1) 0 (- frameBorderwidth 2) 0)
  157.      )
  158.     theTile
  159.     )
  160. )
  161.  
  162. (: active-border-vbar-tile
  163.     (with (foreground clientActiveBackground theTile (pixmap-make frameBorderwidth 1)
  164.            foreground clientActiveTopShadowColor)
  165.      (draw-line theTile 0 0 1 0)
  166.      (with (foreground clientActiveBottomShadowColor)
  167.       (draw-line theTile (- frameBorderwidth 1) 0 (- frameBorderwidth 2) 0)
  168.      )
  169.     theTile
  170.     )
  171. )
  172.  
  173. (: border-hbar-tile
  174.         (with (foreground clientBackground theTile (pixmap-make 1 frameBorderwidth)
  175.                foreground clientTopShadowColor)
  176.          (draw-line theTile 0 0 0 1)
  177.          (with (foreground clientBottomShadowColor)
  178.           (draw-line theTile  0 (- frameBorderwidth 1) 0 (- frameBorderwidth 2))
  179.          )
  180.         theTile
  181.         )
  182. )
  183.  
  184. (: active-border-hbar-tile
  185.         (with (foreground clientActiveBackground theTile (pixmap-make 1 frameBorderwidth)
  186.                foreground clientActiveTopShadowColor)
  187.          (draw-line theTile 0 0 0 1)
  188.          (with (foreground clientActiveBottomShadowColor)
  189.           (draw-line theTile 0 (- frameBorderwidth 1) 0 (- frameBorderwidth 2))
  190.          )
  191.         theTile
  192.         )
  193. )
  194.  
  195.  
  196. (de border-tl-pixmap-make (active)
  197.         (with (
  198.                 foreground (if active clientActiveBackground  clientBackground )
  199.                 tSC        (if active clientActiveTopShadowColor    clientTopShadowColor   )
  200.                 bSC        (if active clientActiveBottomShadowColor clientBottomShadowColor)
  201.                 w          frameBorderwidth
  202.                 h          frameBorderwidth
  203.                 theTile    (pixmap-make w h)
  204.               )
  205.          (with (foreground bSC) 
  206.         (draw-line theTile (- w 2) (- h 2) (- w 1) (- h 2))
  207.         (draw-line theTile (- w 2) (- h 1) (- w 1) (- h 1))
  208.      )
  209.      (with (foreground tSC)
  210.         (draw-line theTile 0 0 (- w 1) 0)
  211.         (draw-line theTile 0 1 (- w 1) 1)
  212.         (draw-line theTile 0 0 0 (- h 1))
  213.         (draw-line theTile 1 0 1 (- h 1))
  214.      )
  215.     theTile
  216.     )
  217. )
  218.  
  219. (de border-tr-pixmap-make (active)
  220.         (with (
  221.                 foreground (if active clientActiveBackground  clientBackground )
  222.                 tSC        (if active clientActiveTopShadowColor    clientTopShadowColor   )
  223.                 bSC        (if active clientActiveBottomShadowColor clientBottomShadowColor)
  224.                 w          frameBorderwidth
  225.                 h          frameBorderwidth
  226.                 theTile    (pixmap-make w h)
  227.               )
  228.          (with (foreground tSC)
  229.         (draw-line theTile 0 (- h 1) 1 (- h 1))
  230.      )
  231.          (with (foreground bSC)
  232.                 (draw-line theTile (- w 2) 0 (- w 2) (- h 1))
  233.                 (draw-line theTile (- w 1) 0 (- w 1) (- h 1))
  234.         (draw-line theTile 0 (- h 2) 1 (- h 2))
  235.         (draw-line theTile 0 (- h 2) 0 (- h 1))
  236.          )
  237.          (with (foreground tSC)
  238.                 (draw-line theTile 0 0 (- w 1) 0)
  239.                 (draw-line theTile 0 1 (- w 2) 1)
  240.          )
  241.         theTile
  242.         )
  243. )
  244.  
  245.  
  246. (de border-bl-pixmap-make (active)
  247.         (with (
  248.                 foreground (if active clientActiveBackground  clientBackground )
  249.                 tSC        (if active clientActiveTopShadowColor    clientTopShadowColor   )
  250.                 bSC        (if active clientActiveBottomShadowColor clientBottomShadowColor)
  251.                 w          frameBorderwidth
  252.                 h          frameBorderwidth
  253.                 theTile    (pixmap-make w h)
  254.               )
  255.          (with (foreground tSC)
  256.                 (draw-line theTile (- w 2) 1 (- w 1) 1)
  257.          )
  258.          (with (foreground bSC)
  259.                 (draw-line theTile (- w 2) 0 (- w 2) 1)
  260.                 (draw-line theTile (- w 1) 0 (- w 2) 0)
  261.                 (draw-line theTile 0 (- h 2) (- w 1) (- h 2))
  262.                 (draw-line theTile 0 (- h 1) (- w 1) (- h 1))
  263.          )
  264.          (with (foreground tSC)
  265.                 (draw-line theTile 0 0 0 (- h 1))
  266.                 (draw-line theTile 1 0 1 (- h 2))
  267.          )
  268.         theTile
  269.         )
  270. )
  271.  
  272. (de border-br-pixmap-make (active)
  273.         (with (
  274.                 foreground (if active clientActiveBackground  clientBackground )
  275.                 tSC        (if active clientActiveTopShadowColor    clientTopShadowColor   )
  276.                 bSC        (if active clientActiveBottomShadowColor clientBottomShadowColor)
  277.                 w          frameBorderwidth
  278.                 h          frameBorderwidth
  279.                 theTile    (pixmap-make w h)
  280.               )
  281.          (with (foreground bSC)
  282.                 (draw-line theTile 0 (- h 2) (- w 1) (- h 2))
  283.                 (draw-line theTile 0 (- h 1) (- w 1) (- h 1))
  284.         (draw-line theTile (- w 2) 0 (- w 2) (- h 1))
  285.         (draw-line theTile (- w 1) 0 (- w 1) (- h 1))
  286.          )
  287.          (with (foreground tSC)
  288.                 (draw-line theTile 0 0 1 0)
  289.                 (draw-line theTile 0 1 1 1)
  290.          )
  291.         theTile
  292.         )
  293. )
  294.  
  295. ; RESIZE HANDLE'S FSM :
  296. ; ===================
  297.  
  298. (: resize-plug.fsm
  299.  (fsm-make 
  300.   (state-make
  301.     (on (user-event 'focus-in) (: wob-tile (# 'activepixmap wob-property)) )
  302.         (on (user-event 'focus-out) (: wob-tile (# 'pixmap wob-property)) )
  303.     (on (buttonpress 1 any) (progn
  304.                  (do-binding-button 1 (current-event-modifier)
  305.                             'press '(frame border))
  306.                  (resize-window)) )
  307.     (do-bindings-state '(frame border))
  308.   )
  309.  )
  310. )
  311.  
  312.  
  313. ; BORDER'S FSM :
  314. ; ============
  315.  
  316. (: border.fsm
  317.  (fsm-make
  318.   (state-make
  319.         (on (user-event 'focus-in) (: wob-tile (# 'activepixmap wob-property)) )
  320.         (on (user-event 'focus-out) (: wob-tile (# 'pixmap wob-property)) )
  321.         (do-bindings-state '(frame border))
  322.   )
  323.  )
  324. )
  325.  
  326.  
  327.  
  328. (: border-v-bar
  329.   (with (
  330.         fsm border.fsm
  331.         borderwidth 0
  332.         cursor frame-cursor
  333.         tile border-vbar-tile
  334.         property (list 'pixmap border-vbar-tile
  335.                        'activepixmap active-border-vbar-tile)
  336.     bar-min-width frameBorderwidth
  337.        )
  338.    (bar-make)
  339.   )
  340. )
  341.  
  342. (: border-plug-tl
  343.         (with (
  344.                borderwidth 0
  345.                fsm border.fsm
  346.                pixmap (border-tl-pixmap-make ())
  347.                activepixmap (border-tl-pixmap-make t)
  348.                property (list 'pixmap pixmap 'activepixmap activepixmap)
  349.               )
  350.          (plug-make pixmap)
  351.         )
  352. )
  353.  
  354. (: border-plug-tr
  355.         (with (
  356.                borderwidth 0
  357.                fsm border.fsm
  358.                pixmap (border-tr-pixmap-make ())
  359.                activepixmap (border-tr-pixmap-make t)
  360.                property (list 'pixmap pixmap 'activepixmap activepixmap)
  361.               )
  362.          (plug-make pixmap)
  363.         )
  364. )
  365.  
  366. (: border-plug-bl
  367.         (with (
  368.                borderwidth 0
  369.                fsm border.fsm
  370.                pixmap (border-bl-pixmap-make ())
  371.                activepixmap (border-bl-pixmap-make t)
  372.                property (list 'pixmap pixmap 'activepixmap activepixmap)
  373.               )
  374.          (plug-make pixmap)
  375.         )
  376. )
  377.  
  378. (: border-plug-br
  379.         (with (
  380.                borderwidth 0
  381.                fsm border.fsm
  382.                pixmap (border-br-pixmap-make ())
  383.                activepixmap (border-br-pixmap-make t)
  384.                property (list 'pixmap pixmap 'activepixmap activepixmap)
  385.               )
  386.          (plug-make pixmap)
  387.         )
  388. )
  389.  
  390.  
  391.  
  392. (: border-top-bar
  393.   (with (
  394.         fsm border.fsm
  395.         borderwidth 0
  396.         cursor frame-cursor
  397.         tile border-hbar-tile
  398.         property (list 'pixmap border-hbar-tile
  399.                        'activepixmap active-border-hbar-tile)
  400.     bar-min-width frameBorderwidth
  401.        )
  402.    (bar-make border-plug-tl () border-plug-tr)
  403.   )
  404.  
  405. )
  406.  
  407. (: border-bottom-bar
  408.   (with (
  409.         fsm border.fsm
  410.         borderwidth 0
  411.         cursor frame-cursor
  412.         tile border-hbar-tile
  413.         property (list 'pixmap border-hbar-tile
  414.                        'activepixmap active-border-hbar-tile)
  415.     bar-min-width frameBorderwidth
  416.        )
  417.    (bar-make border-plug-bl () border-plug-br)
  418.   )
  419.  
  420. )
  421.      
  422.  
  423. (de bottom-pixmap-make (active)
  424.     (with (
  425.         foreground (if active clientActiveBackground  clientBackground )
  426.         tSC        (if active clientActiveTopShadowColor    clientTopShadowColor   )
  427.         bSC       (if active clientActiveBottomShadowColor clientBottomShadowColor)
  428.         w       resizeBorderWidth
  429.         h       (- mwm-resize-style-corner-size w)
  430.         theTile       (pixmap-make w h)
  431.           )
  432.      (with (foreground bSC) (draw-line theTile 0 0 (- w 1) 0))
  433.      (with (foreground tSC) 
  434.             (draw-line theTile 0 1 (- w 1) 1)
  435.             (draw-line theTile 0 0 0 (- h 1))
  436.             (draw-line theTile 1 0 1 (- h 1))
  437.      )
  438.      (with (foreground bSC) 
  439.             (draw-line theTile (- w 1) 0 (- w 1) (- h 1))
  440.             (draw-line theTile (- w 2) 2 (- w 2) (- h 1))
  441.      )
  442.      theTile
  443.     )
  444. )
  445.  
  446. (de top-pixmap-make (active)
  447.     (with (
  448.         foreground (if active clientActiveBackground clientBackground)
  449.         tSC        (if active  clientActiveTopShadowColor    clientTopShadowColor   )
  450.                 bSC        (if active clientActiveBottomShadowColor clientBottomShadowColor)
  451.         w       resizeBorderWidth
  452.         h       (- mwm-resize-style-corner-size w)
  453.         theTile       (pixmap-make w h)
  454.           )
  455.          (with (foreground tSC)
  456.                         (draw-line theTile 0 0 0 (- h 1))
  457.                         (draw-line theTile 1 0 1 (- h 1))
  458.             (draw-line theTile 0 (- h 1) (- w 2) (- h 1))
  459.          )
  460.          (with (foreground bSC)
  461.                         (draw-line theTile (- w 2) 0 (- w 2) (- h 2))
  462.                         (draw-line theTile (- w 1) 0 (- w 1) (- h 1))
  463.             (draw-line theTile 1 (- h 2) (- w 1) (- h 2))
  464.          )
  465.      theTile
  466.     )
  467. )
  468.  
  469. (de top-right-h-pixmap-make (active)
  470.         (with (
  471.                 foreground (if active clientActiveBackground  clientBackground )
  472.                 tSC        (if active clientActiveTopShadowColor    clientTopShadowColor   )
  473.                 bSC        (if active clientActiveBottomShadowColor clientBottomShadowColor)
  474.                 h          resizeBorderWidth
  475.                 w          mwm-resize-style-corner-size
  476.                 theTile    (pixmap-make w h)
  477.               )
  478.          (with (foreground tSC)
  479.                 (draw-line theTile 0 0 (- w 1) 0)
  480.                 (draw-line theTile 1 1 (- w 2) 1)
  481.         (draw-line theTile 1 0 1 (- h 2))
  482.         (draw-line theTile (+ (- w h) 1) (- h 2) (+ (- w h) 1) (- h 1))
  483.          )
  484.          (with (foreground bSC)
  485.                 (draw-line theTile 0 1 0 (- h 1))
  486.         (draw-line theTile 0 (- h 1) (- w h) (- h 1))
  487.         (draw-line theTile 2 (- h 2) (+ (- w h) 1) (- h 2))
  488.         (draw-line theTile (- w 1) 1 (- w 1) (- h 1))
  489.         (draw-line theTile (- w 2) 2 (- w 2) (- h 1))
  490.          )
  491.          theTile
  492.         )
  493. )
  494.  
  495. (de top-left-h-pixmap-make (active)
  496.         (with (
  497.                 foreground (if active clientActiveBackground  clientBackground )
  498.                 tSC        (if active clientActiveTopShadowColor    clientTopShadowColor   )
  499.                 bSC        (if active clientActiveBottomShadowColor clientBottomShadowColor)
  500.                 h          resizeBorderWidth
  501.                 w          mwm-resize-style-corner-size
  502.                 theTile    (pixmap-make w h)
  503.               )
  504.          (with (foreground tSC)
  505.                 (draw-line theTile 0 0 (- w 1) 0)
  506.         (draw-line theTile 0 1 (- w 3) 1)
  507.         (draw-line theTile (- w 1) 0 (- w 1) (- h 2))
  508.         (draw-line theTile 0 0 0 (- h 1))
  509.         (draw-line theTile 1 0 1 (- h 1))
  510.          )
  511.          (with (foreground bSC)
  512.                 (draw-line theTile (- h 2) (- h 2) (- w 2) (- h 2))
  513.                 (draw-line theTile (- h 2) (- h 1) (- w 1) (- h 1))
  514.         (draw-line theTile (- w 2) 1 (- w 2) (- h 1))
  515.          )
  516.          theTile
  517.         )
  518. )
  519.  
  520.  
  521.  
  522.  
  523. (de bottom-right-h-pixmap-make (active)
  524.     (with (
  525.         foreground (if active clientActiveBackground  clientBackground )
  526.         tSC        (if active clientActiveTopShadowColor    clientTopShadowColor   )
  527.         bSC       (if active clientActiveBottomShadowColor clientBottomShadowColor)
  528.         h       resizeBorderWidth
  529.         w       mwm-resize-style-corner-size
  530.         theTile       (pixmap-make w h)
  531.           )
  532.      (with (foreground tSC)
  533.         (draw-line theTile 0 0 (+ (- mwm-resize-style-corner-size resizeBorderWidth) 1) 0)
  534.         (draw-line theTile 0 1 (+ (- mwm-resize-style-corner-size resizeBorderWidth) 1) 1)
  535.         (draw-line theTile 1 0 1 (- h 2))
  536.      )
  537.      (with (foreground bSC) 
  538.         (draw-line theTile 0 2 0 (- h 1))
  539.         (draw-line theTile 0 (- h 1) (- w 1) (- h 1))
  540.         (draw-line theTile 2 (- h 2) (- w 1) (- h 2))
  541.         (draw-line theTile (- w 1)  0 (- w 1) (- h 1))
  542.         (draw-line theTile (- w 2)  0 (- w 2) (- h 2))
  543.      )
  544.      theTile
  545.     )
  546. )
  547.  
  548. (de bottom-left-h-pixmap-make (active)
  549.     (with (
  550.         foreground (if active clientActiveBackground  clientBackground )
  551.         tSC        (if active clientActiveTopShadowColor    clientTopShadowColor   )
  552.         bSC       (if active clientActiveBottomShadowColor clientBottomShadowColor)
  553.         h       resizeBorderWidth
  554.         w       mwm-resize-style-corner-size
  555.         theTile       (pixmap-make w h)
  556.           )
  557.      (with (foreground tSC)
  558.         (draw-line theTile 0 0 0 (- h 1))
  559.         (draw-line theTile 1 0 1 (- h 2))
  560.         (draw-line theTile resizeBorderWidth 0 (- w 1) 0)
  561.         (draw-line theTile (- resizeBorderWidth 1) 1 (- w 1) 1)
  562.         (draw-line theTile (- w 1) 0 (- w 1) (- h 1))
  563.      )
  564.      (with (foreground bSC) 
  565.         (draw-line theTile 1 (- h 1) (- w 1) (- h 1))
  566.         (draw-line theTile 2 (- h 2) (- w 2) (- h 2))
  567.         (draw-line theTile (- w 2) 2 (- w 2) (- h 2))
  568.         (draw-line theTile (- resizeBorderWidth 2) 0 (- resizeBorderWidth 1) 0)
  569.         (draw-line theTile (- resizeBorderWidth 2) 0 (- resizeBorderWidth 2) 1)
  570.      )
  571.      theTile
  572.     )
  573. )
  574.  
  575.  
  576. ; THE PLUGS :
  577. ; =========
  578.  
  579. (: top-resize-vplug-left
  580.     (with (cursor (if resizeCursors cursor-NW frame-cursor)
  581.            borderwidth 0
  582.            fsm resize-plug.fsm
  583.            pixmap (top-pixmap-make ())
  584.            activepixmap (top-pixmap-make t)
  585.            property (list 'pixmap pixmap 'activepixmap activepixmap)
  586.           )
  587.      (plug-make pixmap)
  588.     )
  589. )
  590.  
  591. (: top-resize-vplug-right
  592.         (with (cursor (if resizeCursors cursor-NE frame-cursor)
  593.                borderwidth 0
  594.                fsm resize-plug.fsm
  595.                pixmap (top-pixmap-make ())
  596.                activepixmap (top-pixmap-make t)
  597.                property (list 'pixmap pixmap 'activepixmap activepixmap)
  598.               )
  599.          (plug-make pixmap)
  600.         )
  601. )
  602.  
  603.  
  604. (: bottom-resize-vplug-left
  605.     (with (cursor (if resizeCursors cursor-SW frame-cursor)
  606.            borderwidth 0
  607.            fsm resize-plug.fsm
  608.            pixmap (bottom-pixmap-make ())
  609.            activepixmap (bottom-pixmap-make t)
  610.            property (list 'pixmap pixmap 'activepixmap activepixmap)
  611.           )
  612.      (plug-make pixmap)
  613.     )
  614. )
  615.  
  616.  
  617. (: bottom-resize-vplug-right
  618.     (with (cursor (if resizeCursors cursor-SE frame-cursor)
  619.            borderwidth 0
  620.            fsm resize-plug.fsm
  621.            pixmap (bottom-pixmap-make ())
  622.            activepixmap (bottom-pixmap-make t)
  623.            property (list 'pixmap pixmap 'activepixmap activepixmap)
  624.           )
  625.      (plug-make pixmap)
  626.     )
  627. )
  628.  
  629.  
  630.  
  631. (: bottom-resize-hplug-right
  632.     (with (cursor (if resizeCursors cursor-SE frame-cursor)
  633.            borderwidth 0
  634.            fsm resize-plug.fsm
  635.            pixmap (bottom-right-h-pixmap-make ())
  636.            activepixmap (bottom-right-h-pixmap-make t)
  637.            property (list 'pixmap pixmap 'activepixmap activepixmap)
  638.           )
  639.      (plug-make pixmap)
  640.     )
  641. )
  642.  
  643.  
  644. (: bottom-resize-hplug-left
  645.     (with (cursor (if resizeCursors cursor-SW frame-cursor)
  646.            borderwidth 0
  647.            fsm resize-plug.fsm
  648.            pixmap (bottom-left-h-pixmap-make ())
  649.            activepixmap (bottom-left-h-pixmap-make t)
  650.            property (list 'pixmap pixmap 'activepixmap activepixmap)
  651.           )
  652.      (plug-make pixmap)
  653.     )
  654. )
  655.  
  656. (: top-resize-hplug-right
  657.         (with (cursor (if resizeCursors cursor-NE frame-cursor)
  658.                borderwidth 0
  659.                fsm resize-plug.fsm
  660.                pixmap (top-right-h-pixmap-make ())
  661.                activepixmap (top-right-h-pixmap-make t)
  662.                property (list 'pixmap pixmap 'activepixmap activepixmap)
  663.               )
  664.          (plug-make pixmap)
  665.         )
  666. )
  667.  
  668.  
  669. (: top-resize-hplug-left
  670.         (with (cursor (if resizeCursors cursor-NW frame-cursor)
  671.                borderwidth 0
  672.                fsm resize-plug.fsm
  673.                pixmap (top-left-h-pixmap-make ())
  674.                activepixmap (top-left-h-pixmap-make t)
  675.                property (list 'pixmap pixmap 'activepixmap activepixmap)
  676.               )
  677.          (plug-make pixmap)
  678.         )
  679. )
  680.  
  681.  
  682. ; THE BARS :
  683. ; ========
  684.  
  685. (df left-bar ()
  686.  (if deco.border
  687.  (if deco.resizeh
  688.  (with (
  689.     fsm resize-plug.fsm
  690.     borderwidth 0
  691.     cursor (if resizeCursors cursor-W frame-cursor)
  692.     tile shadowed-vbar-tile
  693.     property (list 'pixmap shadowed-vbar-tile 
  694.                'activepixmap active-shadowed-vbar-tile)
  695.        )
  696.  (bar-make (if (not deco.title) top-resize-vplug-left) () bottom-resize-vplug-left )
  697.  )
  698.  border-v-bar
  699.  )
  700.  )
  701. )
  702.  
  703. (df right-bar ()
  704.  (if deco.border
  705.  (if deco.resizeh
  706.  (with (
  707.     fsm resize-plug.fsm
  708.     borderwidth 0
  709.     cursor (if resizeCursors cursor-E frame-cursor)
  710.     tile shadowed-vbar-tile
  711.     property (list 'pixmap shadowed-vbar-tile 
  712.                'activepixmap active-shadowed-vbar-tile)
  713.        )
  714.  (bar-make (if (not deco.title) top-resize-vplug-right) () bottom-resize-vplug-right)
  715.  )
  716.  border-v-bar
  717.  )
  718.  )
  719. )
  720.  
  721.  
  722.  
  723. (df bottom-bar ()
  724.  (if deco.border
  725.  (if deco.resizeh
  726.  (with (
  727.     fsm resize-plug.fsm
  728.     borderwidth 0
  729.     cursor (if resizeCursors cursor-S frame-cursor)
  730.     tile shadowed-hbar-tile
  731.     plug-separator 0
  732.     property (list 'pixmap shadowed-hbar-tile 
  733.                'activepixmap active-shadowed-hbar-tile)
  734.        )
  735.  (bar-make bottom-resize-hplug-left 
  736.        () 
  737.        bottom-resize-hplug-right
  738.  )
  739.  )
  740.  border-bottom-bar
  741.  )
  742.  )
  743. )
  744.  
  745. (df top-bar ()
  746.  (if deco.border
  747.  (if deco.resizeh
  748.  (with (
  749.         fsm resize-plug.fsm
  750.         borderwidth 0
  751.         cursor (if resizeCursors cursor-N frame-cursor)
  752.         tile shadowed-hbar-tile
  753.         plug-separator 0
  754.         property (list 'pixmap shadowed-hbar-tile
  755.                        'activepixmap active-shadowed-hbar-tile)
  756.        )
  757.  (bar-make top-resize-hplug-left
  758.            ()
  759.            top-resize-hplug-right
  760.  )
  761.  )
  762.  border-top-bar
  763.  )
  764.  )
  765. )
  766.  
  767.  
  768. ;==============================================================================
  769.  
  770.  
  771. ; FSM of the text field :
  772. ; =====================
  773. (: edit-fsm  
  774.     (fsm-make 
  775.     (: sed.edit-fsm.normal 
  776.        (state-make
  777.            (on (user-event 'focus-in) 
  778.            (progn
  779.              (: wob-background clientActiveBackground)
  780.              (wob-tile (with (foreground clientActiveForeground)
  781.                      (active-label-make window-name clientFontList)))
  782.            ) )
  783.            (on (user-event 'focus-out)
  784.            (progn
  785.              (: wob-background clientBackground)
  786.              (wob-tile (with (foreground clientForeground)
  787.                      (active-label-make window-name clientFontList)))
  788.            ) )
  789.            (on (user-event 'name-change)
  790.            (progn
  791.              (wob-tile 
  792.                (with (foreground ;(if (# 'got-focus (property-of-wob window))
  793.                   (if (= wob-background clientActiveBackground)
  794.                         clientActiveForeground clientForeground))
  795.                 (active-label-make window-name clientFontList)))
  796.            ))
  797.         (on (buttonpress 1 alone) (progn (do-binding-button 1 alone 'press '(title frame))
  798.                          (with (cursor cross-cursor) (move-window))))
  799.            (do-bindings-state '(title frame))
  800.            )
  801. ))))))
  802.     
  803.  
  804. (: title-bar.width (+ 6 clientFontHeight))
  805.  
  806. ; THE TITLE-BAR :
  807. ; =============
  808.  
  809. (: shadowed-title-bar-tile 
  810.     (with (foreground clientBackground theTile (pixmap-make 1 title-bar.width))
  811.         (with (foreground clientTopShadowColor) 
  812.          (draw-line theTile 0 0 0 1))
  813.         (with (foreground clientBottomShadowColor) 
  814.          (draw-line theTile 0 (- title-bar.width 1) 0  (- title-bar.width 2)))
  815.      theTile
  816.     )
  817. )
  818.  
  819. (: active-shadowed-title-bar-tile 
  820.     (with (foreground clientActiveBackground theTile (pixmap-make 1 title-bar.width))
  821.         (with (foreground clientActiveTopShadowColor) 
  822.          (draw-line theTile 0 0 0 1))
  823.         (with (foreground clientActiveBottomShadowColor) 
  824.          (draw-line theTile 0 (- title-bar.width 1) 0  (- title-bar.width 2)))
  825.      theTile
  826.     )
  827. )
  828.  
  829. (: titlebar-fsm 
  830.     (fsm-make
  831.     (state-make
  832.         (on (user-event 'focus-in) (: wob-tile (# 'activepixmap wob-property)) )
  833.             (on (user-event 'focus-out) (: wob-tile (# 'pixmap wob-property)) )
  834.         (on (buttonpress 1 alone) (progn (do-binding-button 1 alone 'press '(title frame))
  835.                          (with (cursor cross-cursor) (move-window))))
  836.         (do-bindings-state '(title frame))
  837. )))
  838.     
  839.  
  840. (: editable-plug '(with (borderwidth 0
  841.              background clientBackground 
  842.              foreground clientForeground
  843.              font clientFontList
  844.              menu ()
  845.              property (list 'name window-name) fsm edit-fsm)
  846.             (plug-make (label-make window-name)))))
  847.  
  848. (df titlebar ()
  849.  (if deco.title
  850.            (with (
  851.               menu ()
  852.               cursor frame-cursor
  853.               borderwidth 0 background clientBackground fsm titlebar-fsm
  854.               plug-separator 0
  855.                      pixmap shadowed-title-bar-tile
  856.                   activepixmap  active-shadowed-title-bar-tile
  857.               property (list 'pixmap pixmap 'activepixmap activepixmap)
  858.               tile pixmap
  859.               borderpixel black
  860.               bar-min-width title-bar.width
  861.               params 
  862.             (list
  863.               (if deco.menu button-of-menu)
  864.              () 
  865.              editable-plug 
  866.              () 
  867.              (if deco.minimize button-iconify)
  868.             )
  869.               params (if deco.maximize (+ params '(button-zoom)) params)
  870.              )
  871.              (eval (+ '(bar-make) params))
  872.         )
  873.  (if deco.border (top-bar))
  874.  )
  875. )
  876.  
  877. (df mwm-window-fsm ()
  878.           (fsm-make 
  879.             (state-make 
  880.             (# 0 (# 'window keyBindings))
  881.             (# 'wfsm (menu-wob menu))
  882.             window-std-behavior
  883.             (do-bindings-state '(window))
  884.             )
  885.           )
  886. )
  887.  
  888.  
  889. ; THE MWM-LIKE WINDOW :
  890. ; ===================
  891.  
  892.  
  893. (df mwm-win-deco-make ()
  894.           (with (inner-borderwidth 1 
  895.             menu (eval (atom (get-res-value 'windowMenu)))
  896.             fsm (mwm-window-fsm)
  897.             cursor frame-cursor
  898.             borderwidth mwm-ed-borderwidth
  899.             borderpixel white
  900.             property (list 'resize-corner-size
  901.                 (if deco.resizeh mwm-resize-style-corner-size 1) )
  902.             grabs  
  903.             (+      (# 1 (# 'window keyBindings))
  904.                 (# 'app-grabs buttonBindings)
  905.                 (# 'wgrabs (menu-wob menu))
  906.                 window-std-grabs
  907.             )
  908.             )
  909.              (window-make (titlebar) (left-bar) (right-bar) (bottom-bar) ())
  910.          )
  911. )
  912.  
  913. (defname 'mwm-win.data screen. ())
  914.  
  915. (: default-deco ())
  916.  
  917. (: mwm-win
  918.    '(with (deco-string (get-res-value "clientDecoration")
  919.        deco-list ())
  920.       (if window-is-transient-for (: deco-list transientDecoration)
  921.     (if (= deco-string "all")
  922.         (: deco-list '(border maximize minimize resizeh menu title))
  923.  
  924.         (= deco-string "none") (: deco-list ())
  925.         (: deco-list (listify-string deco-string))))
  926.       (get-deco-ctxt deco-list)
  927.       (mwm-win-deco-make)))
  928.  
  929. (: all '(maximize minimize menu resizeh border title))
  930.  
  931. (de get-deco-ctxt (theDeco)
  932.  (: deco.title ())
  933.  (: deco.border ())
  934.  (: deco.maximize ())
  935.  (: deco.minimize ())
  936.  (: deco.menu ())
  937.  (: deco.resizeh ())
  938.  
  939.  (if (= theDeco 'none) ()
  940.      (= theDeco 'all) (get-deco-ctxt (eval theDeco))
  941.      (while theDeco
  942.       (set (atom (+ "deco." (# 0 theDeco))) t)
  943.       (: theDeco (sublist 1 (length theDeco) theDeco))
  944.      )
  945.  )
  946. )
  947.  
  948.  
  949.  
  950.