[futurebasic] [FB^3] Appearance Image Well Demo

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : October 2000 : Group Archive : Group : All Groups

From: Ken Shmidheiser <k.shmidheiser@...>
Date: Tue, 10 Oct 2000 20:36:26 -0400
Alain wrote,

>Hi,

>Following Ken's example, here is a little demo
>that installs a WYSIWYG Font menu using
>the Appearance Manager:

Nice work since I last spoke with you, Alain!  8-)

Following Alain's example, here is a little demo that places a PICT 
resource and a CICN resource into Appearance Manager Image Wells.

Caveat: This demo briefly "borrows" resources from the System File. 
You may prefer to use your own resources. No error checking... use 
with care.

I can see a bright future for Image Wells in FB^3.

Ken

_kWithTheseDangNewLongAppleConstantsBeSureToAdjustForEmailLineBreaks

'---------- Begin FB^3 Code -----------

/*
This demo builds an Appearance Manager-compliant
Image Well on a color theme background and
places two resources-- PICT and ICON-- into
Image Wells.

Following are the constants that are plugged into
the sixth parameter of FN NEWCONTROL, depending
on the kind of PICT or ICON you want to place in
the Image Well:

_kControlContentTextOnly        = 0
_kControlContentIconSuiteRes    = 1
_kControlContentCIconRes        = 2
_kControlContentPictRes         = 3
_kControlContentIconSuiteHandle = 129
_kControlContentCIconHandle     = 130
_kControlContentPictHandle      = 131
_kControlContentIconRef         = 132

The fifth parameter represents the Resource ID
that you want to place. The Resource IDs
in this example -20005 and -20020 are pulled from
the Mac OS System File for the sake of demonstration.
You can replace those with your own PICT and CICN
resources. Just be sure the resource IDs are greater
than 128. You can easily resize the window and
Image Well rect. (Still working on scaling and
cropping.)

Ken Shmidheiser
Somerset, KY
10-10-00
*/

INCLUDE "Tlbx Appearance.Incl"
'RESOURCES "imageWell.rsrc"

BEGIN GLOBALS
END GLOBALS

LOCAL FN initialize
WINDOW-1,"Appearance Compliant Image Well Demo",(0,0)-(400,260),_docNoGrow
BUTTON 1,1,"Quit",(330,222)-(380,245),_kControlBevelButtonNormalBevelProc
BUTTON 2,1,"Build An Image Well 
Window",(75,222)-(323,245),_kControlBevelButtonNormalBevelProc
WINDOW 1
END FN

CLEAR LOCAL MODE
LOCAL FN buildImageWell
DIM err  AS LONG
DIM imageWellH   AS HANDLE
DIM iconWellH    AS HANDLE
DIM textEditH    As Handle
DIM WndPtr       AS windowPtr
DIM theStr       AS STR255
DIM myPICTRect   AS RECT
DIM myCICNRect   As RECT
DIM myTextRect   AS RECT

WndPtr = WINDOW(_wndPointer) : IF WndPtr = _nil THEN EXIT FN

err = FN 
SETTHEMEWINDOWBACKGROUND(WndPtr,_kThemeActiveDialogBackgroundBrush,_true)


'Image Well for a PICT resource
myPICTRect.left   = 20
myPICTRect.top    = 20
myPICTRect.right  = 380
myPICTRect.bottom = 180
'The fifth parameter equals your PICT resource ID
imageWellH = FN 
NEWCONTROL(WndPtr,myPICTRect,"",_true,-20005,_kControlContentPictRes,0,_kControlImageWellProc,1)


'Image Well for a CICN resource
myCICNRect.left   = 20
myCICNRect.top    = 187
myCICNRect.right  = 68
myCICNRect.bottom = 245
'The fifth parameter equals your CICN resource ID
iconWellH = FN 
NEWCONTROL(WndPtr,myCICNRect,"",_true,-20020,_kControlContentCIconRes,0,_kControlImageWellProc,2)


'Text Edit box for a text string
theStr = "CICN resource at left; PICT resource above."
myTextRect.left   = 78
myTextRect.top    = 190
myTextRect.right  = 377
myTextRect.bottom = 213

textEditH = FN 
NEWCONTROL(WndPtr,myTextRect,"",_true,0,0,0,_kControlEditTextProc,3)

err = FN 
SETCONTROLDATA(textEditH,0,_kControlEditTextTextTag,theStr[0],@theStr[1])

END FN

LOCAL FN doDialog
DIM evnt
DIM id

evnt = DIALOG(0)
id = DIALOG(evnt)

SELECT CASE evnt
CASE _wndClose
SELECT id
CASE 1
END
END SELECT

CASE _btnClick
SELECT id
CASE 1
END
CASE 2
BUTTON 2,0
FN buildImageWell
END SELECT

END SELECT
END FN

LOCAL FN doMenu
DIM menuID
DIM itemID
menuID = MENU(_menuID)
itemID = MENU(_itemID)
SELECT CASE menuID

SELECT itemID
CASE 1
CASE 2
END
END SELECT
END SELECT
MENU
END FN

APPLE MENU "(Appearance Compliant Image Well Demo..."
MENU 1,0,_enable,"File"
MENU 1,1,_disable,"-"
MENU 1,2,_enable,"Quit/Q"

ON DIALOG FN doDialog
ON MENU FN doMenu

FN initialize

DO
HANDLEEVENTS
UNTIL 0
END

'----------- End Code -----------