Lisp HUG Maillist Archive

Richer set of border styles for CAPI?

Hi list,

I'm interested in having access to a richer set of border styles - like the ones listed here for Windows, for example:

http://msdn.microsoft.com/en-us/library/bb226804(VS.85).aspx

In my application I am currently using a pinboard-layout with an object which draws a 1-pixel border (similar to the 'status field' style listed above). This works OK, but does anyone know a better way of doing this kind of thing? I suppose the only other way is to directly access the native styles through the FLI (presumably with DrawEdge on Windows).

It would be really nice if more border styles could be available through the CAPI.

Cheers,
Chris

Do you want a Hotmail account? Sign-up now - Free

Re: Richer set of border styles for CAPI?

Christopher Melen <relativeflux <at> hotmail.co.uk> writes:

>
> Hi list,I'm interested in having access to a richer set of border styles -
like the ones listed here for Windows, for
example:http://msdn.microsoft.com/en-us/library/bb226804(VS.85).aspx
> 

OK, so I've been investigating this a bit and now I do it (on Windows at least)
using DrawEdge rather than a pinboard-object:

(fli:define-c-typedef HDC (:unsigned :long))
(fli:define-c-typedef HWND (:unsigned :long))
(fli:define-c-typedef PTR (:unsigned :long))
	
(fli:define-c-struct sRECT 
  (left :long)
  (top  :long)
  (right :long)
  (bottom :long))

(fli:define-c-typedef RECT sRECT)

(fli:define-foreign-function (get-client-rect "GetClientRect")
  ((hwnd HWND)
   (lprect PTR))
  :calling-convention :stdcall
  :result-type :boolean)

(fli:define-foreign-function (draw-edge "DrawEdge")
  ((hdc HDC)
   (qrc PTR)
   (edge (:unsigned :int))
   (flags (:unsigned :int)))
  :calling-convention :stdcall
  :result-type :boolean)

; The following flags specify border types.
(defconstant BDR_RAISEDOUTER 1)
(defconstant BDR_SUNKENOUTER 2)
(defconstant BDR_RAISEDINNER 4)
(defconstant BDR_SUNKENINNER 8)
(defconstant EDGE_BUMP 9) ; Combines BDR_RAISEDOUTER and BDR_SUNKENINNER
(defconstant EDGE_ETCHED 6) ; Combines BDR_SUNKENOUTER and BDR_RAISEDINNER
(defconstant EDGE_RAISED 5) ; Combines BDR_RAISEDOUTER and BDR_RAISEDINNER
(defconstant EDGE_SUNKEN 10) ; Combines BDR_SUNKENOUTER and BDR_SUNKENINNER

; Edge flags.	
(defconstant BF_LEFT 1)
(defconstant BF_TOP 2)
(defconstant BF_RIGHT 4)
(defconstant BF_BOTTOM 8)
(defconstant BF_RECT 15) ; Combines BF_LEFT, BF_TOP, BF_RIGHT and BF_BOTTOM)

(defun draw-sunken-border (pane x y width height)
  (declare (ignore x y width height))
  (fli:with-dynamic-foreign-objects ((rect RECT))
    (let* ((representation (gp:port-representation pane))
	   (hdc (slot-value representation 'capi-win32-lib::hdc))
	   (ptr (fli:pointer-address rect)))
      (get-client-rect (capi:simple-pane-handle pane) ptr)
      (draw-edge hdc ptr BDR_SUNKENOUTER BF_RECT))))

(capi:contain (make-instance 'capi:output-pane
                             :display-callback 'draw-sunken-border
			     :background :color_3dface
			     :visible-border nil)
	       :internal-border 5)

So all I do is to call DrawEdge from the pane's display-callback. This technique
works nicely, but is it the only way to mix CAPI and GDI calls?
And how would I implement it with a scrolling pane?

How exactly does a CAPI pane draw its border, anyway?

Many thanks,
Christopher




Updated at: 2020-12-10 08:39 UTC