Commit 4621ec02 authored by Peter Achten's avatar Peter Achten

(PA) setEditControlSelection function added in StdControl.

parent 6e238a91
......@@ -266,9 +266,14 @@ where
// The user request the placement of a word:
placeword :: (PSt *State) -> PSt *State
placeword pst
# (maybeScrabble,pst) = accPIO (getWindow scrabbleId) pst
| isNothing maybeScrabble = abort "placeword could not retrieve WState from Scrabble window."
| otherwise = placeword` (fromJust maybeScrabble) pst
# (maybeScrabble,pst) = accPIO (getWindow scrabbleId) pst
| isNothing maybeScrabble
= abort "placeword could not retrieve WState from Scrabble window."
| otherwise
# pst = placeword` (fromJust maybeScrabble) pst
# pst = setActiveControl editId pst
# pst = appPIO (setEditControlSelection editId 1 0) pst
= pst
placeword` :: WState (PSt *State) -> PSt *State
placeword` info pst=:{ls=t=:{ board
......
......@@ -560,6 +560,8 @@ osSetPopUpControlSize :: !OSWindowPtr !(!Int,!Int) !OSWindowPtr !(!Int,!Int) !
returns the current content of the edit control.
osSetEditControlCursor parentWindow editPtr clipRect itemRect pos
sets the cursor position at pos of the edit control while clipping.
osSetEditControlSelection parentWindow editPtr clipRect itemRect start end
sets the selection of the text in the edit control while clipping.
osSetEditControlSelect parentWindow editPtr clipRect toAble
enables the edit control (if toAble), or disables the edit control (if (not toAble)), while clipping.
osSetEditControlShow parentWindow editPtr clipRect show
......@@ -572,6 +574,7 @@ osSetPopUpControlSize :: !OSWindowPtr !(!Int,!Int) !OSWindowPtr !(!Int,!Int) !
osSetEditControlText :: !OSWindowPtr !OSWindowPtr !OSRect !OSRect !Bool !String !*OSToolbox -> *OSToolbox
osGetEditControlText :: !OSWindowPtr !OSWindowPtr !*OSToolbox -> (!String,!*OSToolbox)
osSetEditControlCursor :: !OSWindowPtr !OSWindowPtr !OSRect !OSRect !Int !*OSToolbox -> *OSToolbox
osSetEditControlSelection :: !OSWindowPtr !OSWindowPtr !OSRect !OSRect !Int !Int !*OSToolbox -> *OSToolbox
osSetEditControlSelect :: !OSWindowPtr !OSWindowPtr !OSRect !Bool !*OSToolbox -> *OSToolbox
osSetEditControlShow :: !OSWindowPtr !OSWindowPtr !OSRect !Bool !*OSToolbox -> *OSToolbox
osSetEditControlPos :: !OSWindowPtr !(!Int,!Int) !OSWindowPtr !(!Int,!Int) !(!Int,!Int) !Bool !*OSToolbox -> *OSToolbox
......
......@@ -1350,6 +1350,10 @@ osSetEditControlCursor :: !OSWindowPtr !OSWindowPtr !OSRect !OSRect !Int !*OSToo
osSetEditControlCursor _ ePtr _ _ pos tb
= winSetEditSelection ePtr pos (pos+1) tb
osSetEditControlSelection :: !OSWindowPtr !OSWindowPtr !OSRect !OSRect !Int !Int !*OSToolbox -> *OSToolbox
osSetEditControlSelection _ ePtr _ _ start end tb
= winSetEditSelection ePtr start end tb
osSetEditControlSelect :: !OSWindowPtr !OSWindowPtr !OSRect !Bool !*OSToolbox -> *OSToolbox
osSetEditControlSelect _ ePtr _ select tb
= winEnableControl ePtr select tb
......
......@@ -6,7 +6,7 @@ definition module StdControl
//
// StdControl specifies all control operations.
// Author: Peter Achten
// Modified: 15 October 2001 for Clean 2.0
// Modified: 20 November 2001 (setEditControlSelection added).
// ********************************************************************************
......@@ -160,6 +160,16 @@ setEditControlCursor :: !Id !Int !(IOSt .l) -> IOSt .l
content.
*/
setEditControlSelection :: !Id !Int !Int !(IOSt .l) -> IOSt .l
/* setEditControlSelection sets the new selection starting at position @2 until
@3 in the current content of the indicated EditControl.
In case @2<=@3, then the selection starts at @2 and ends at @3, with @2
taken to be atleast 0, and @3 taken to be at most (size content).
In case @2> @3, then the whole text is selected.
The indicated control must be the active EditControl (use setActiveControl in
StdWindow), otherwise this function has no effect.
*/
setControlLooks :: ![(Id, Bool,(Bool,Look))] !(IOSt .l) -> IOSt .l
setControlLook :: !Id !Bool (Bool,Look) !(IOSt .l) -> IOSt .l
/* setControlLook(s) sets the (render,look) attribute of the indicated
......
......@@ -662,6 +662,26 @@ where
= {wState & wRep=wH,wTb=tb}
// Set the selection of an EditControl.
setEditControlSelection :: !Id !Int !Int !(IOSt .l) -> IOSt .l
setEditControlSelection cId begin end ioState
# (ioId,ioState) = ioStGetIOId ioState
# (maybeParent,ioState) = ioStGetIdParent cId ioState
| not (fst (isOkControlId ioId (cId,maybeParent)))
= ioState
| otherwise
= setWindow (fromJust maybeParent).idpId (setEditControlSelection` cId begin` end`) ioState
where
(begin`,end`) = if (begin<=end) (begin,end) (0,-1)
setEditControlSelection` :: !Id !Int !Int !*WState -> *WState
setEditControlSelection` id begin end wState=:{wIds={wPtr},wRep,wTb,wMetrics}
# (wH,tb) = seteditcontrolselection id begin end wMetrics wPtr wRep wTb
= {wState & wRep=wH,wTb=tb}
/* Change the Look of the corresponding (Custom(Button)/Compound)Controls and redraw
only if the first Boolean is True.
*/
......
......@@ -277,7 +277,7 @@ where
| not found
= stdWindowFatalError "setActiveControl" "indicated control could not be located"
| otherwise
// # keyfocus = setNewFocusItem itemNr whKeyFocus
// # keyfocus = setNewFocusItem itemNr whKeyFocus This should be done via (de)activate-event
# (delayinfo,tb) = osActivateControl wshIds.wPtr itemPtr tb
= (delayinfo,{wsH & wshHandle=Just {wlsH & wlsHandle={wH & /*whKeyFocus=keyfocus,*/whItems=itemHs}}},tb)
where
......
......@@ -5,7 +5,7 @@ definition module controlinternal
// Clean Standard Object I/O library, version 1.2.2
//
// Author: Peter Achten
// Modified: 7 September 2001 for Clean 2.0
// Modified: 20 November 2001 (seteditcontrolselection added).
// ********************************************************************************
......@@ -19,6 +19,7 @@ setcontrolsshowstate :: ![Id] !Bool !OSWindowMetrics !WIDS
setcontrolsmarkstate :: !Id !MarkState ![Index] !OSWindowMetrics !OSWindowPtr !WindowHandle` !*OSToolbox -> (!WindowHandle`, !*OSToolbox)
setcontroltexts :: ![(Id,String)] !OSWindowMetrics !OSWindowPtr !WindowHandle` !*OSToolbox -> (!WindowHandle`, !*OSToolbox)
seteditcontrolcursor :: !Id !Int !OSWindowMetrics !OSWindowPtr !WindowHandle` !*OSToolbox -> (!WindowHandle`, !*OSToolbox)
seteditcontrolselection :: !Id !Int !Int !OSWindowMetrics !OSWindowPtr !WindowHandle` !*OSToolbox -> (!WindowHandle`, !*OSToolbox)
setcontrolslook :: ![(Id,Bool,(Bool,Look))] !OSWindowMetrics !OSWindowPtr !WindowHandle` !*OSToolbox -> (!WindowHandle`, !*OSToolbox)
drawincontrol :: !Id !.(St *Picture .x) !OSWindowMetrics !OSWindowPtr !WindowHandle` !*OSToolbox -> *(!Maybe .x,!WindowHandle`,!*OSToolbox)
setslidercontrolstates :: ![(Id,IdFun SliderState)] !OSWindowMetrics !OSWindowPtr !WindowHandle` !*OSToolbox -> (!WindowHandle`, !*OSToolbox)
......
......@@ -604,6 +604,44 @@ where
= (False,itemH,tb)
// Set the text selection of an EditControl, and handle proper feedback.
seteditcontrolselection :: !Id !Int !Int !OSWindowMetrics !OSWindowPtr !WindowHandle` !*OSToolbox -> (!WindowHandle`,!*OSToolbox)
seteditcontrolselection id begin end wMetrics wPtr wH`=:{whItems`,whSize`,whWindowInfo`} tb
# (_,itemHs,tb) = setWElement (setEditSelection wMetrics wPtr True clipRect begin end) id whItems` tb
= ({wH` & whItems`=itemHs},tb)
where
clipRect = getContentRect wMetrics whWindowInfo` whSize`
setEditSelection :: !OSWindowMetrics !OSWindowPtr !Bool !OSRect !Int !Int !Id !WItemHandle` !*OSToolbox -> (!Bool,!WItemHandle`,!*OSToolbox)
setEditSelection wMetrics wPtr shownContext clipRect begin end id itemH=:{wItemKind`=IsEditControl} tb
| not (identifyMaybeId id itemH.wItemId`)
= (False,itemH,tb)
| otherwise
# itemRect = posSizeToRect itemH.wItemPos` itemH.wItemSize`
# tb = osSetEditControlSelection wPtr itemH.wItemPtr` clipRect itemRect begin end tb
= (True,itemH,tb)
setEditSelection wMetrics wPtr shownContext clipRect begin end id itemH=:{wItemKind`=IsCompoundControl} tb
# (found,itemHs,tb) = setWElement (setEditSelection wMetrics wPtr shownContext1 clipRect1 begin end) id itemH.wItems` tb
= (found,{itemH & wItems`=itemHs},tb)
where
info = getWItemCompoundInfo` itemH.wItemInfo`
clipRect1 = intersectRectContent wMetrics clipRect info itemH.wItemPos` itemH.wItemSize`
shownContext1 = shownContext && itemH.wItemShow`
setEditSelection wMetrics wPtr shownContext clipRect begin end id itemH=:{wItemKind`=IsLayoutControl} tb
# (found,itemHs,tb) = setWElement (setEditSelection wMetrics wPtr shownContext1 clipRect1 begin end) id itemH.wItems` tb
= (found,{itemH & wItems`=itemHs},tb)
where
clipRect1 = intersectRects clipRect (posSizeToRect itemH.wItemPos` itemH.wItemSize`)
shownContext1 = shownContext && itemH.wItemShow`
setEditSelection _ _ _ _ _ _ _ itemH tb
= (False,itemH,tb)
// Set the look of a control, and handle proper feedback.
setcontrolslook :: ![(Id,Bool,(Bool,Look))] !OSWindowMetrics !OSWindowPtr !WindowHandle` !*OSToolbox -> (!WindowHandle`,!*OSToolbox)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment