/* *********************************************************************
This source file is a part of the standard library of Scol
For the latest info, see http://www.scolring.org
Copyright (c) 2014 Stephane Bisaro aka Iri.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
Place - Suite 330, Boston, MA 02111-1307, USA, or go to
http://www.gnu.org/copyleft/lesser.txt
********************************************************************* */
/*
* Functions for the widget named 'BrowseText'
* See http://redmine.scolring.org/projects/tutorials/wiki/Scol_usage
* for more informations
*/
/*! \file browseText.pkg
* \author Scol team
* \version 0.1
* \copyright GNU Lesser General Public License 2.0 or later
* \brief New BrowseText widget API
*
* Dependancies :
*
* \image html browsetext.png
**/
/*! \struct BrowseText
*
* \ingroup _2dos_browstext
*
* \brief Opaque internal structure. You should not call it directly, use
* API instead !
*
**/
struct BrowseText = [
bt_oMother : ObjWin,
bt_oWin : ObjWin,
bt_oText : ObjText,
bt_oButton : ObjButton,
bt_oFont : ObjFont,
bt_oChn : Chn,
bt_isLeft : I,
bt_isMulti : I,
bt_initialFlags : I,
bt_flagButton : I,
bt_szTitle : S,
bt_szTip : S,
bt_szFont : S, // font name
bt_iWinWidth : I,
bt_iWinHeight : I,
bt_iButtonWidth : I,
bt_iButtonHeight : I,
bt_iTextWidth : I,
bt_iTextHeight : I,
bt_iWinX : I,
bt_iWinY : I,
bt_iButtonX : I,
bt_iButtonY : I,
bt_iTextX : I,
bt_iTextY : I,
bt_iMaxSize : [I I],
bt_iMinSize : [I I],
bt_iButtonSize : [I I], // fixed size by the developer
bt_oBmp : ObjBitmap,
bt_isEnabled : I,
bt_isShown : I,
bt_hasButtonAction : [I S S S],
bt_cbDialogOpen : fun [BrowseText P] I,
bt_cbDialogOpenMulti : fun [BrowseText [P r1]] I,
bt_cbDialogSave : fun [BrowseText W] I,
bt_cbDialogDir : fun [BrowseText S] I
] mkBrowseText;;
/*! \brief Constante : allow horizontal scrolling in the text field
*
* \ingroup _2dos_browstext
* Prototype : fun [ ] I
*
* \see _CRbrowseTextSingle
* \see _CRbrowseTextSingleEx
* \see _CRbrowseTextMulti
* \see _CRbrowseTextMultiEx
*
* \return I : always the same constante. Never use its numeric value instead.
**/
fun BT_AHSCROLL ()= ET_AHSCROLL;;
/*! \brief Constante : display horizontal scroll box in the text field
*
* \ingroup _2dos_browstext
* Prototype : fun [ ] I
*
* \see _CRbrowseTextSingle
* \see _CRbrowseTextSingleEx
* \see _CRbrowseTextMulti
* \see _CRbrowseTextMultiEx
*
* \return I : always the same constante. Never use its numeric value instead.
**/
fun BT_HSCROLL ()= ET_HSCROLL;;
/*! \brief Constante : allow vertical scrolling in the text field
*
* \ingroup _2dos_browstext
* Prototype : fun [ ] I
*
* \see _CRbrowseTextSingle
* \see _CRbrowseTextSingleEx
* \see _CRbrowseTextMulti
* \see _CRbrowseTextMultiEx
*
* \return I : always the same constante. Never use its numeric value instead.
**/
fun BT_AVSCROLL ()= ET_AVSCROLL;;
/*! \brief Constante : display vertical scroll box in the text field
*
* \ingroup _2dos_browstext
* Prototype : fun [ ] I
*
* \see _CRbrowseTextSingle
* \see _CRbrowseTextSingleEx
* \see _CRbrowseTextMulti
* \see _CRbrowseTextMultiEx
*
* \return I : always the same constante. Never use its numeric value instead.
**/
fun BT_VSCROLL ()= ET_VSCROLL;;
/*! \brief Constante : set the center alignement in the text field
*
* \ingroup _2dos_browstext
* Prototype : fun [ ] I
*
* \see _CRbrowseTextSingle
* \see _CRbrowseTextSingleEx
* \see _CRbrowseTextMulti
* \see _CRbrowseTextMultiEx
*
* \return I : always the same constante. Never use its numeric value instead.
**/
fun BT_ALIGN_CENTER ()= ET_ALIGN_CENTER;;
/*! \brief Constante : set the left alignement in the text field
*
* \ingroup _2dos_browstext
* Prototype : fun [ ] I
*
* \see _CRbrowseTextSingle
* \see _CRbrowseTextSingleEx
* \see _CRbrowseTextMulti
* \see _CRbrowseTextMultiEx
*
* \return I : always the same constante. Never use its numeric value instead.
**/
fun BT_ALIGN_LEFT ()= ET_ALIGN_LEFT;;
/*! \brief Constante : set the right alignement in the text field
*
* \ingroup _2dos_browstext
* Prototype : fun [ ] I
*
* \see _CRbrowseTextSingle
* \see _CRbrowseTextSingleEx
* \see _CRbrowseTextMulti
* \see _CRbrowseTextMultiEx
*
* \return I : always the same constante. Never use its numeric value instead.
**/
fun BT_ALIGN_RIGHT ()= ET_ALIGN_RIGHT;;
/*! \brief Constante : display a border around the text field
*
* \ingroup _2dos_browstext
* Prototype : fun [ ] I
*
* \see _CRbrowseTextSingle
* \see _CRbrowseTextSingleEx
* \see _CRbrowseTextMulti
* \see _CRbrowseTextMultiEx
*
* \return I : always the same constante. Never use its numeric value instead.
**/
fun BT_BORDER ()= ET_BORDER;;
/*! \brief Constante : display a 3d border around the text field
*
* \ingroup _2dos_browstext
* Prototype : fun [ ] I
*
* \see _CRbrowseTextSingle
* \see _CRbrowseTextSingleEx
* \see _CRbrowseTextMulti
* \see _CRbrowseTextMultiEx
*
* \return I : always the same constante. Never use its numeric value instead.
**/
fun BT_DOWN ()= ET_DOWN;;
/*! \brief Constante : hide the browseText when creating
*
* \ingroup _2dos_browstext
* Prototype : fun [ ] I
*
* \see _CRbrowseTextSingle
* \see _CRbrowseTextSingleEx
* \see _CRbrowseTextMulti
* \see _CRbrowseTextMultiEx
*
* \return I : always the same constante. Never use its numeric value instead.
**/
fun BT_HIDDEN ()= ET_HIDDEN;;
/*! \brief Constante : set the lower case content in the text field
*
* \ingroup _2dos_browstext
* Prototype : fun [ ] I
*
* \see _CRbrowseTextSingle
* \see _CRbrowseTextSingleEx
* \see _CRbrowseTextMulti
* \see _CRbrowseTextMultiEx
*
* \return I : always the same constante. Never use its numeric value instead.
**/
fun BT_LOWERCASE ()= ET_LOWERCASE;;
/*! \brief Constante : set the text field no editable
*
* \ingroup _2dos_browstext
* Prototype : fun [ ] I
*
* \see _CRbrowseTextSingle
* \see _CRbrowseTextSingleEx
* \see _CRbrowseTextMulti
* \see _CRbrowseTextMultiEx
*
* \return I : always the same constante. Never use its numeric value instead.
**/
fun BT_NOEDITABLE ()= ET_NOEDIT;;
/*! \brief Constante : set the text field as a password field (display only '*')
*
* \ingroup _2dos_browstext
* Prototype : fun [ ] I
*
* \see _CRbrowseTextSingle
* \see _CRbrowseTextSingleEx
* \see _CRbrowseTextMulti
* \see _CRbrowseTextMultiEx
*
* \return I : always the same constante. Never use its numeric value instead.
**/
fun BT_PASSWORD ()= ET_PASSWORD;;
/*! \brief Constante : set the text field to only numbers
*
* \ingroup _2dos_browstext
* Prototype : fun [ ] I
*
* \see _CRbrowseTextSingle
* \see _CRbrowseTextSingleEx
* \see _CRbrowseTextMulti
* \see _CRbrowseTextMultiEx
*
* \return I : always the same constante. Never use its numeric value instead.
**/
fun BT_NUMBER ()= ET_NUMBER;;
/*! \brief Constante : allow drag and drop inside the browserText
*
* \ingroup _2dos_browstext
* Prototype : fun [ ] I
*
* \see _CRbrowseTextSingle
* \see _CRbrowseTextSingleEx
* \see _CRbrowseTextMulti
* \see _CRbrowseTextMultiEx
*
* \return I : always the same constante. Never use its numeric value instead.
**/
fun BT_DRAGDROP ()= ET_DRAGDROP;;
/*! \brief Constante : enable the browserText
*
* \ingroup _2dos_browstext
* Prototype : fun [ ] I
*
* \see _ENbrowseText
*
* \return I : always the same constante. Never use its numeric value instead.
**/
fun BT_ENABLE ()= 1;;
/*! \brief Constante : disable the browserText
*
* \ingroup _2dos_browstext
* Prototype : fun [ ] I
*
* \see _ENbrowseText
*
* \return I : always the same constante. Never use its numeric value instead.
**/
fun BT_DISABLE ()= !BT_ENABLE;;
/*! \brief Constante : show the browserText
*
* \ingroup _2dos_browstext
* Prototype : fun [ ] I
*
* \see _SHOWbrowseText
*
* \return I : always the same constante. Never use its numeric value instead.
**/
fun BT_SHOW ()= WINDOW_UNHIDDEN;;
/*! \brief Constante : hide the browserText
*
* \ingroup _2dos_browstext
* Prototype : fun [ ] I
*
* \see _SHOWbrowseText
*
* \return I : always the same constante. Never use its numeric value instead.
**/
fun BT_HIDE ()= WINDOW_HIDDEN;;
/*! \brief Maximum fixed size for a browserText. By default, it is 9999 pixels.
*
* \ingroup _2dos_browstext
**/
var BT_MAXSIZE = 9999;;
/*! \brief Minimum fixed size for a browserText. By default, it is 1 pixels.
*
* \ingroup _2dos_browstext
**/
var BT_MINSIZE = 1;;
/* Private functions */
fun browsetext_init ()=
mkBrowseText [
nil nil nil nil nil nil
0 0 nil nil "..." nil "Arial"
200 20 40 20 160 20
0 0 160 0 0 0
[BT_MAXSIZE BT_MAXSIZE] [0 0]
nil nil
1 1 nil
nil nil nil nil
];;
fun BT_DLGOPENSINGLE () = 1;;
fun BT_DLGOPENMULTI () = 2;;
fun BT_DLGSAVE () = 3;;
fun BT_DLGDIR () = 4;;
fun browsetext_cbDlgOpenSingle (o, bt, pFile)=
exec bt.bt_cbDialogOpen with [bt pFile];;
fun browsetext_cbDlgOpenMulti (o, bt, pFiles)=
exec bt.bt_cbDialogOpenMulti with [bt pFiles];;
fun browsetext_cbDlgSave (o, bt, wFile)=
exec bt.bt_cbDialogSave with [bt wFile];;
fun browsetext_cbDlgDir (o, bt, szFile)=
exec bt.bt_cbDialogDir with [bt szFile];;
fun browseText_setDlg (bt, type, initPath, initName, filter)=
if type == BT_DLGOPENSINGLE then
(
set filter = if filter == nil then "All\0*.*\0\0" else filter;
_DLGrflopen
_DLGOpenFile bt.bt_oChn bt.bt_oWin initPath initName filter
@browsetext_cbDlgOpenSingle
bt;
bt
)
else if type == BT_DLGOPENMULTI then
(
set filter = if filter == nil then "All\0*.*\0\0" else filter;
_DLGrflopenMulti
_DLGOpenFileMulti bt.bt_oChn bt.bt_oWin initPath initName filter
@browsetext_cbDlgOpenMulti
bt;
bt
)
else if type == BT_DLGSAVE then
(
set filter = if filter == nil then "All\0*.*\0\0" else filter;
_DLGrflsave
_DLGSaveFile bt.bt_oChn bt.bt_oWin initPath initName filter
@browsetext_cbDlgSave
bt;
bt
)
else if type == BT_DLGDIR then
(
_DLGrflopenDir
_DLGOpenDir bt.bt_oChn bt.bt_oWin initPath initName
@browsetext_cbDlgDir
bt;
bt
)
else
nil;;
fun browsertext_cbClick (o, u)=
let u -> [cbfun bt uparam] in
(
if bt.bt_hasButtonAction != nil then
let bt.bt_hasButtonAction -> [dlgType initPath initName filter] in
browseText_setDlg bt dlgType initPath initName filter
else
nil;
exec cbfun with [bt uparam]
);;
fun browsertext_cbClickWin (o, u, paf, pef, pif)=
let u -> [cbfun bt uparam] in
exec cbfun with [bt uparam];;
fun browsertext_cbDragDrop (o, u, paf, pef, pFiles)=
let u -> [cbfun bt uparam] in
exec cbfun with [bt uparam pFiles];;
fun browsertext_cbLineOk (o, u, content)=
let u -> [cbfun bt uparam] in
exec cbfun with [bt uparam content];;
fun browsertext_cbChanged (o, u)=
let u -> [cbfun bt uparam] in
exec cbfun with [bt uparam _GETtext o];;
/*fun browsertext_cbCursor (o, u, x, y, button)=
let u -> [cbfun bt uparam] in
exec cbfun with [bt uparam x y button];;*/
fun browsertext_cbClose (o, u)=
let u -> [cbfun bt uparam] in
exec cbfun with [bt uparam];;
fun browsertext_cbDestroy (o, u)=
let u -> [cbfun bt uparam] in
exec cbfun with [bt uparam];;
fun browsertext_cbMove (o, u, x, y)=
let u -> [cbfun bt uparam] in
exec cbfun with [bt uparam x y];;
fun browsertext_cbSize (o, u, w, h)=
let u -> [cbfun bt uparam] in
exec cbfun with [bt uparam w h];;
fun browsertext_cbPaint (o, u)=
let u -> [cbfun bt uparam] in
exec cbfun with [bt uparam];;
fun browsetext_calculSize (bt)=
let _GETstringSize bt.bt_oFont bt.bt_szTitle -> [wf hf] in
let bt.bt_iButtonSize -> [bfw bfh] in
(
set bt.bt_iButtonWidth =
if bt.bt_iButtonSize == nil then
if wf > (bt.bt_iWinWidth/2) then bt.bt_iWinWidth/2 else wf+10
else
bfw;
set bt.bt_iButtonHeight = if bt.bt_iButtonSize == nil then bt.bt_iWinHeight else bfh;
set bt.bt_iTextWidth = bt.bt_iWinWidth-bt.bt_iButtonWidth;
set bt.bt_iTextHeight = bt.bt_iWinHeight;
set bt.bt_iButtonX = if bt.bt_isLeft then 0 else bt.bt_iWinWidth-bt.bt_iButtonWidth;
set bt.bt_iButtonY = 0;
set bt.bt_iTextX = if bt.bt_isLeft then bt.bt_iButtonWidth else 0;
set bt.bt_iTextY = 0;
0
);;
fun browsetext_resize (bt, neww, newh)=
let bt.bt_iMaxSize -> [Mw Mh] in
let bt.bt_iMinSize -> [mw mh] in
(
set bt.bt_iWinWidth = if neww < mw then mw
else if neww > Mw then mw
else neww ;
set bt.bt_iWinHeight = if newh < mh then mh
else if newh > Mh then Mh
else newh;
);
browsetext_calculSize bt;
_SIZEwindow bt.bt_oWin bt.bt_iWinWidth bt.bt_iWinHeight bt.bt_iWinX bt.bt_iWinY;
_SIZEbutton bt.bt_oButton bt.bt_iButtonWidth bt.bt_iButtonHeight bt.bt_iButtonX bt.bt_iButtonY;
_SIZEtext bt.bt_oText bt.bt_iTextWidth bt.bt_iTextHeight bt.bt_iTextX bt.bt_iTextY;
0;;
fun browsetext_move (bt, newx, newy)=
set bt.bt_iWinX = if newx == nil then bt.bt_iWinX else newx;
set bt.bt_iWinY = if newy == nil then bt.bt_iWinY else newy;
_MVwindow bt.bt_oWin bt.bt_iWinX bt.bt_iWinY;
0;;
fun browsetext_font (bt)=
if bt.bt_oFont != nil then
(
_AFFfontButton bt.bt_oButton bt.bt_oFont;
_AFFfontText bt.bt_oText bt.bt_oFont;
)
else
nil;
bt;;
fun browsetext_dsBitmap (bt)=
_DSbutton bt.bt_oButton;
_DSbitmap bt.bt_oBmp;
set bt.bt_oBmp = nil;
bt;;
fun browsertext_destroy (bt)=
browsetext_dsBitmap bt;
_DStext bt.bt_oText;
_DSfont bt.bt_oFont;
_DSwindow bt.bt_oWin;
set bt = nil;
0;;
fun browsetext_createButtonBitamp (bt)=
_DSbutton bt.bt_oButton;
set bt.bt_oButton = nil;
if bt.bt_oBmp != nil then
set bt.bt_oButton = _CRbuttonBitmap bt.bt_oChn bt.bt_oWin bt.bt_oBmp bt.bt_iButtonX bt.bt_iButtonY bt.bt_iButtonWidth bt.bt_iButtonHeight PB_TABFOCUS
else
set bt.bt_oButton = _CRbutton bt.bt_oChn bt.bt_oWin bt.bt_iButtonX bt.bt_iButtonY bt.bt_iButtonWidth bt.bt_iButtonHeight bt.bt_flagButton bt.bt_szTitle;
//_CBbutton bt.bt_oButton @browsertext_cbClick [nil bt nil];
bt;;
fun browsetext_create (bt, chn, mother, x, y, w, h, flagMulti, flagsText, leftButton, fonte)= _fooId flagsText;
let flagsText -> fT in
let let _CRfont chn 14 0 0 fonte -> f in
if f == nil then
(
set bt.bt_szFont = "Arial";
_CRfont chn 14 0 0 "Arial"
)
else
(
set bt.bt_szFont = fonte;
f
)
-> font in
let if (flagsText & BT_DRAGDROP) then
(
set flagsText = flagsText&(~BT_DRAGDROP);
set flagsText = flagsText|ET_DRAGDROP;
1
)
else
0
-> flagdd in
let if (flagsText & BT_HIDDEN) then
(
set flagsText = flagsText&(~BT_HIDDEN);
1
)
else
0
-> flaghide in
let if flagdd then WN_DRAGDROP|WN_CHILDINSIDE else WN_CHILDINSIDE -> flagwin in
let if flagdd then PB_DRAGDROP|PB_TABFOCUS else PB_TABFOCUS -> flagbutton in
(
set flagwin = if flaghide then flagwin|WN_HIDDEN else flagwin;
set bt.bt_oChn = chn;
set bt.bt_oMother = mother;
set bt.bt_oFont = font;
set bt.bt_isLeft = if (leftButton == 0) || (leftButton == 1) then leftButton else 0;
set bt.bt_isMulti = if (flagMulti == 0) || (flagMulti == 1) then flagMulti else 0;
set bt.bt_initialFlags = fT;
set bt.bt_flagButton = flagbutton;
set bt.bt_iWinX = x;
set bt.bt_iWinY = y;
set bt.bt_iWinWidth = w;
set bt.bt_iWinHeight = h;
browsetext_calculSize bt;
set bt.bt_oWin = _CRwindow bt.bt_oChn bt.bt_oMother bt.bt_iWinX bt.bt_iWinY bt.bt_iWinWidth bt.bt_iWinHeight flagwin nil;
set bt.bt_oText = if bt.bt_isMulti then
_CReditText bt.bt_oChn bt.bt_oWin bt.bt_iTextX bt.bt_iTextY bt.bt_iTextWidth bt.bt_iTextHeight flagsText ""
else
_CReditLine bt.bt_oChn bt.bt_oWin bt.bt_iTextX bt.bt_iTextY bt.bt_iTextWidth bt.bt_iTextHeight flagsText|ET_TRANSPARENT "";
// set bt.bt_oButton = _CRbutton bt.bt_oChn bt.bt_oWin bt.bt_iButtonX bt.bt_iButtonY bt.bt_iButtonWidth bt.bt_iButtonHeight flagbutton bt.bt_szTitle;
browsetext_createButtonBitamp bt;
browsetext_font bt;
_SETfocus bt.bt_oWin;
if (bt.bt_oWin == nil) || (bt.bt_oText == nil) || (bt.bt_oButton == nil) then
(
_fooS "BrowserText : Error during creation process";
browsertext_destroy bt;
nil
)
else
bt
);;
fun browsetext_reset (bt)=
let _GETtext bt.bt_oText -> content in
(
_DSbutton bt.bt_oButton;
_DStext bt.bt_oText;
_DSwindow bt.bt_oWin;
browsetext_create bt bt.bt_oChn bt.bt_oMother bt.bt_iWinX bt.bt_iWinY bt.bt_iWinWidth bt.bt_iWinHeight bt.bt_isMulti bt.bt_initialFlags bt.bt_isLeft bt.bt_szFont;
_SETtext bt.bt_oText content
);
bt;;
/* Public functions */
/*! \brief Create a default browseText with a single line.
*
* \ingroup _2dos_browstext
* Prototype : fun [Chn ObjWin I I I I] BrowseText
*
* \see _CRbrowseTextSingleEx
*
* \param Chn : the channel where the browserText is created
* \param ObjWin : the parent window (should not be nil)
* \param I : the X coordinate
* \param I : the Y coordinate
* \param I : the width
* \param I : the height
*
* \return BrowseText : The new BrowseText object or nil if an error occurs
**/
fun _CRbrowseTextSingle (chn, mother, x, y, w, h)=
if chn == nil then nil
else browsetext_create browsetext_init chn mother x y w h 0 0 0 nil;;
/*! \brief Create a browseText with a single line.
*
* \ingroup _2dos_browstext
* Prototype : fun [Chn ObjWin I I I I I I] BrowseText
*
* \see _CRbrowseTextSingle
*
* \param Chn : the channel where the browserText is created
* \param ObjWin : the parent window (should not be nil)
* \param I : the X coordinate
* \param I : the Y coordinate
* \param I : the width
* \param I : the height
* \param I : a combinaison of these available flags :
* - BT_AHSCROLL
* - BT_HSCROLL
* - BT_AVSCROLL
* - BT_VSCROLL
* - BT_ALIGN_CENTER
* - BT_ALIGN_LEFT
* - BT_ALIGN_RIGHT
* - BT_BORDER
* - BT_DOWN
* - BT_HIDDEN
* - BT_LOWERCASE
* - BT_NOEDITABLE
* - BT_PASSWORD
* - BT_NUMBER
* - BT_DRAGDROP
* \param I : define if the button is at left (1) or at right (0)
*
* \return BrowseText : The new BrowseText object or nil if an error occurs
**/
fun _CRbrowseTextSingleEx (chn, mother, x, y, w, h, flags, leftButton)=
if chn == nil then nil
else browsetext_create browsetext_init chn mother x y w h 0 flags leftButton nil;;
/*! \brief Create a default multi-line browseText
*
* \ingroup _2dos_browstext
* Prototype : fun [Chn ObjWin I I I I] BrowseText
*
* \see _CRbrowseTextMultiEx
*
* \param Chn : the channel where the browserText is created
* \param ObjWin : the parent window (should not be nil)
* \param I : the X coordinate
* \param I : the Y coordinate
* \param I : the width
* \param I : the height
*
* \return BrowseText : The new BrowseText object or nil if an error occurs
**/
fun _CRbrowseTextMulti (chn, mother, x, y, w, h)=
if chn == nil then nil
else browsetext_create browsetext_init chn mother x y w h 1 0 0 nil;;
/*! \brief Create a multi-line browseText.
*
* \ingroup _2dos_browstext
* Prototype : fun [Chn ObjWin I I I I I I] BrowseText
*
* \see _CRbrowseTextMulti
*
* \param Chn : the channel where the browserText is created
* \param ObjWin : the parent window (should not be nil)
* \param I : the X coordinate
* \param I : the Y coordinate
* \param I : the width
* \param I : the height
* \param I : a combinaison of these available flags :
* - BT_AHSCROLL
* - BT_HSCROLL
* - BT_AVSCROLL
* - BT_VSCROLL
* - BT_ALIGN_CENTER
* - BT_ALIGN_LEFT
* - BT_ALIGN_RIGHT
* - BT_BORDER
* - BT_DOWN
* - BT_HIDDEN
* - BT_LOWERCASE
* - BT_NOEDITABLE
* - BT_PASSWORD
* - BT_NUMBER
* - BT_DRAGDROP
* \param I : define if the button is at left (1) or at right (0)
*
* \return BrowseText : The new BrowseText object or nil if an error occurs
**/
fun _CRbrowseTextMultiEx (chn, mother, x, y, w, h, flags, leftButton)=
if chn == nil then nil
else browsetext_create browsetext_init chn mother x y w h 1 flags leftButton nil;;
/*! \brief Rebuild a browseText
*
* \ingroup _2dos_browstext
* Prototype : fun [BrowseText] BrowseText
*
* The 'close' and 'destroy' callback can be called during this event.
*
* \param BrowseText : a BrowseText object
*
* \return BrowseText : The same BrowseText object or nil if an error occurs
**/
fun _REBUILDbrowseText (bt)=
browsetext_reset bt;;
/*! \brief Destroy a browseText control.
*
* It should be explicitely destroyed by this function, especially if a
* bitmap button is displayed.
*
* \see _SETbrowseTextButtonBitmap
*
* \ingroup _2dos_browstext
* Prototype : fun [BrowseText] I
*
* \param BrowseText : a BrowseText object
*
* \return BrowseText : Always 0.
**/
fun _DSbrowseText (bt)=
browsertext_destroy bt;;
/*! \brief Define the title of the button inside the BrowseText
*
* \ingroup _2dos_browstext
* Prototype : fun [BrowseText S] BrowseText
*
* If the previous button was a bitmap button, it will be destroyed and a
* new button will be created. It is not need to set the callbacks again.
* It is not also need to rebuild the object.
*
* \param BrowseText : a BrowseText object
* \param S : the new title
*
* \see _SETbrowseTextButtonBitmap
*
* \return BrowseText : The same BrowseText object
**/
fun _SETbrowseTextTitle (bt, szNewTitle)=
set bt.bt_szTitle = szNewTitle;
if bt.bt_oBmp != nil then
(
browsetext_dsBitmap bt;
browsetext_createButtonBitamp bt;
)
else
(
_SETbuttonName bt.bt_oButton bt.bt_szTitle;
bt
);;
/*! \brief Return the current title of the button inside the BrowseText
*
* \ingroup _2dos_browstext
* Prototype : fun [BrowseText] S
*
* \param BrowseText : a BrowseText object
*
* \return S : The title
**/
fun _GETbrowseTextTitle (bt)=
bt.bt_szTitle;;
/*! \brief Set a font object to the control (the text field and the button)
*
* It is not required to rebuild the control after that.
*
* \ingroup _2dos_browstext
* Prototype : fun [BrowseText ObjFont] BrowseText
*
* \param BrowseText : a BrowseText object
* \param ObjFont : a font object already created
*
* \return BrowseText : The same BrowseText object
**/
fun _SETbrowseTextFont (bt, font)=
set bt.bt_oFont = font;
browsetext_font bt;;
/*! \brief Return the current font object used by the BrowseText
*
* \ingroup _2dos_browstext
* Prototype : fun [BrowseText] ObjFont
*
* \param BrowseText : a BrowseText object
*
* \return ObjFont : The current font object
**/
fun _GETbrowseTextFont (bt)=
bt.bt_oFont;;
/*! \brief Define a new font to the control (the text field and the button)
*
* It is not required to rebuild the control after that.
*
* \ingroup _2dos_browstext
* Prototype : fun [BrowseText S I I I] BrowseText
*
* \param BrowseText : a BrowseText object
* \param S : a font name. It should be already installed in the system.
* \param I : the font size
* \param I : the rotation to apply to the font
* \param I : a flag :
* - FF_WEIGHT
* - FF_ITALIC
* - FF_UNDERLINE
* - FF_STRIKED
* - FF_PIXEL
* - FF_HOLLOW
* - FF_CLEARTYPE
*
* See _CRfont in the Scol documentation for more explanations about these parameters.
*
* \return BrowseText : The same BrowseText object or nil if error (typically a bad font name)
**/
fun _SETbrowseTextFontName (bt, szFont, iSize, iRotation, iFlag)=
set bt.bt_szFont = szFont;
if nil == set bt.bt_oFont = _CRfont bt.bt_oChn iSize iRotation iFlag bt.bt_szFont then
nil
else
browsetext_font bt;;
/*! \brief Return the current font name used by the BrowseText
*
* If a font is set by _SETbrowseTextFont the returned name might be wrong.
*
* \ingroup _2dos_browstext
* Prototype : fun [BrowseText] S
*
* \param BrowseText : a BrowseText object
*
* \return S : the font name
**/
fun _GETbrowseTextFontName (bt)=
bt.bt_szFont;;
/*! \brief (Re)Define a new content to the text field
*
* The previous content will be lost. To set empty, the parameter could be "" or nil.
*
* \ingroup _2dos_browstext
* Prototype : fun [BrowseText S] BrowseText
*
* \param BrowseText : a BrowseText object
* \param S : a new content.
*
* \return BrowseText : The same BrowseText object or nil if error
**/
fun _SETbrowseTextContent (bt, szNewContent)=
_SETtext bt.bt_oText szNewContent;
bt;;
/*! \brief Return the current text in the BrowseText
*
* \ingroup _2dos_browstext
* Prototype : fun [BrowseText] S
*
* \param BrowseText : a BrowseText object
*
* \return S : the content
**/
fun _GETbrowseTextContent (bt)=
_GETtext bt.bt_oText;;
/*! \brief Add (append) a content to the text field
*
* The previous content will not be lost.
*
* \ingroup _2dos_browstext
* Prototype : fun [BrowseText S] BrowseText
*
* \param BrowseText : a BrowseText object
* \param S : a content to append.
*
* \return BrowseText : The same BrowseText object or nil if error
**/
fun _ADDbrowseTextContent (bt, szAddContent)=
_ADDtext bt.bt_oText szAddContent;
bt;;
/*! \brief Set a new size to a BrowseText control
*
* \ingroup _2dos_browstext
* Prototype : fun [BrowseText I I] BrowseText
*
* \param BrowseText : a BrowseText object
* \param I : a new width.
* \param I : a new height
*
* \see _SETbrowseTextSizeMax
* \see _SETbrowseTextSizeMin
*
* \return BrowseText : The same BrowseText object or nil if error
**/
fun _SIZEbrowseText (bt, neww, newh)=
/*set neww = if (neww == nil) || (neww <= 0) then bt.bt_iWinHeight bt.bt_iWinWidth else neww;
set newh = if (newh == nil) || (newh <= 0)then bt.bt_iWinHeight bt.bt_iWinWidth else newh;*/
browsetext_resize bt neww newh;
bt;;
/*! \brief Move a BrowseText control in its parent window
*
* If one coordinate is nil, it will be unchanged.
*
* \ingroup _2dos_browstext
* Prototype : fun [BrowseText I I] BrowseText
*
* \param BrowseText : a BrowseText object
* \param I : a new x coordinate.
* \param I : a new y coordinate.
*
* \return BrowseText : The same BrowseText object or nil if error
**/
fun _MOVEbrowseText (bt, newx, newy)=
browsetext_move bt newx newy;
bt;;
/*! \brief Enable or Disable a BrowseText control
*
* \ingroup _2dos_browstext
* Prototype : fun [BrowseText I] BrowseText
*
* \param BrowseText : a BrowseText object
* \param I : the new state : BT_ENABLE or BT_DISABLE. Other value is ignored.
*
* \return BrowseText : The same BrowseText object or nil if error
**/
fun _ENbrowseText (bt, flag)=
if (flag == BT_ENABLE) || (flag == BT_DISABLE) then set bt.bt_isEnabled = flag else nil;
_ENwindow bt.bt_oWin bt.bt_isEnabled;
bt;;
/*! \brief Return the current state of a BrowseText control
*
* \ingroup _2dos_browstext
* Prototype : fun [BrowseText] I
*
* \param BrowseText : a BrowseText object
*
* \return I : the current state (BT_ENABLE or BT_DISABLE).
**/
fun _GETbrowseTextEnabled (bt)=
bt.bt_isEnabled;;
/*! \brief Return the current position of a BrowseText control in its parent window
*
* \ingroup _2dos_browstext
* Prototype : fun [BrowseText] [I I]
*
* \param BrowseText : a BrowseText object
*
* \return [I I] : the current x and y coordinates.
**/
fun _GETbrowseTextPosition (bt)=
[bt.bt_iWinX bt.bt_iWinY];;
/*! \brief Return the current size of a BrowseText control
*
* \ingroup _2dos_browstext
* Prototype : fun [BrowseText] [I I]
*
* \param BrowseText : a BrowseText object
*
* \return [I I] : the current width and the height.
**/
fun _GETbrowseTextSize (bt)=
[bt.bt_iWinWidth bt.bt_iWinHeight];;
/*! \brief Return the current maxi absolute size of a BrowseText control
*
* \ingroup _2dos_browstext
* Prototype : fun [BrowseText] I
*
* \param BrowseText : a BrowseText object
*
* \return I : the current maxi absolute size.
**/
fun _GETbrowseTextSizeMaxDefault ()=
BT_MAXSIZE;;
/*! \brief Return the current mini absolute size of a BrowseText control
*
* \ingroup _2dos_browstext
* Prototype : fun [BrowseText] I
*
* \param BrowseText : a BrowseText object
*
* \return I : the current mini absolute size.
**/
fun _GETbrowseTextSizeMinDefault ()=
BT_MINSIZE;;
/*! \brief Set the maximale size to a BrowseText control
*
* Each value can not be greater than the value returned by _GETbrowseTextSizeMaxDefault
* and lesser than the returned value by _GETbrowseTextSizeMinDefault. Otherwise
* if greater, the maxi(mini) absolute value will be set instead.
*
* \ingroup _2dos_browstext
* Prototype : fun [BrowseText I I] BrowseText
*
* \param BrowseText : a BrowseText object
* \param I : a maxi width.
* \param I : a maxi height.
*
* \see _SIZEbrowseText
* \see _SETbrowseTextSizeMin
* \see _GETbrowseTextSizeMaxDefault
* \see _GETbrowseTextSizeMinDefault
*
* \return BrowseText : The same BrowseText object or nil if error
**/
fun _SETbrowseTextSizeMax (bt, maxw, mawh)=
set maxw = if (maxw < BT_MINSIZE) || (maxw == nil) || (maxw > BT_MAXSIZE) then BT_MAXSIZE else maxw;
set mawh = if (mawh < BT_MINSIZE) || (mawh == nil) || (mawh > BT_MAXSIZE) then BT_MAXSIZE else mawh;
set bt.bt_iMaxSize = [maxw mawh];
bt;;
/*! \brief Set the minimale size to a BrowseText control
*
* Each value can not be greater than the value returned by _GETbrowseTextSizeMaxDefault
* and lesser than the returned value by _GETbrowseTextSizeMinDefault. Otherwise
* if greater, the maxi(mini) absolute value will be set instead.
*
* \ingroup _2dos_browstext
* Prototype : fun [BrowseText I I] BrowseText
*
* \param BrowseText : a BrowseText object
* \param I : a mini width.
* \param I : a mini height.
*
* \see _SIZEbrowseText
* \see _SETbrowseTextSizeMax
* \see _GETbrowseTextSizeMaxDefault
* \see _GETbrowseTextSizeMinDefault
*
* \return BrowseText : The same BrowseText object or nil if error
**/
fun _SETbrowseTextSizeMin (bt, minw, minh)=
set minw = if (minw < BT_MINSIZE) || (minw == nil) || (minw > BT_MAXSIZE) then BT_MINSIZE else minw;
set minh = if (minh < BT_MINSIZE) || (minh == nil) || (minh > BT_MAXSIZE) then BT_MINSIZE else minh;
set bt.bt_iMinSize = [minw minh];
bt;;
/*! \brief Return the current maxi size of a BrowseText control
*
* \ingroup _2dos_browstext
* Prototype : fun [BrowseText] [I I]
*
* \param BrowseText : a BrowseText object
*
* \return [I I] : the current maxi size.
**/
fun _GETbrowseTextSizeMax (bt)=
bt.bt_iMaxSize;;
/*! \brief Return the current mini size of a BrowseText control
*
* \ingroup _2dos_browstext
* Prototype : fun [BrowseText] [I I]
*
* \param BrowseText : a BrowseText object
*
* \return [I I] : the current mini size.
**/
fun _GETbrowseTextSizeMin (bt)=
bt.bt_iMinSize;;
/*! \brief Define if a BrowseText control is shown or hide.
*
* \ingroup _2dos_browstext
* Prototype : fun [BrowseText I] BrowseText
*
* \param BrowseText : a BrowseText object
* \param I : a flag
* - BT_SHOW
* - BT_HIDE
* - another value will be ignored.
*
* \return BrowseText : The same BrowseText object
**/
fun _SHOWbrowseText (bt, state)=
if (state == BT_SHOW) || (state == BT_HIDE) then
(
set bt.bt_isShown = state;
_SHOWwindow bt.bt_oWin bt.bt_isShown
)
else
nil;
bt;;
/*! \brief Return if a BrowseText control is shown or hidden
*
* \ingroup _2dos_browstext
* Prototype : fun [BrowseText] I
*
* \param BrowseText : a BrowseText object
*
* \return I : the current state : BT_SHOW or BT_HIDE (nil if no control)
**/
fun _GETbrowseTextShown (bt)=
bt.bt_isShown;;
/*! \brief Set the size to the button of a BrowseText control
*
* The button size can not be greater than the size of the BrowseText
* control itself.
*
* \ingroup _2dos_browstext
* Prototype : fun [BrowseText [I I]] BrowseText
*
* \param BrowseText : a BrowseText object
* \param [I I] : the width and the height.
*
* \see _SIZEbrowseText
*
* \return BrowseText : The same BrowseText object
**/
fun _SIZEbrowseTextButton (bt, buttonSizeW, buttonSizeH)=
set buttonSizeW = if buttonSizeW > bt.bt_iWinWidth then
bt.bt_iWinWidth
else if buttonSizeW < 1 then
1
else
buttonSizeW;
set buttonSizeH = if buttonSizeH > bt.bt_iWinHeight then
bt.bt_iWinHeight
else if buttonSizeH < 1 then
1
else
buttonSizeH;
set bt.bt_iButtonSize = [buttonSizeW buttonSizeH];
browsetext_resize bt bt.bt_iWinWidth bt.bt_iWinHeight;
bt;;
/*! \brief Return the current button size of a BrowseText control.
*
* \ingroup _2dos_browstext
* Prototype : fun [BrowseText] [I I]
*
* \param BrowseText : a BrowseText object
*
* \return [I I] : this size.
**/
fun _GETbrowseTextSizeButton (bt)=
bt.bt_iButtonSize;;
/*! \brief Display a bitmap instead of the title in the button of a BrowseText control.
*
* The given ObjBitmap is internally copied. So, it can be destroyed.
* The internal Bitmap object will be automatically destroyed when
* the control object is destroyed or a button title is set.
*
* To remove this, you can set 'nil' or define a title string.
*
* \ingroup _2dos_browstext
* Prototype : fun [BrowseText ObjBitmap] BrowseText
*
* \param BrowseText : a BrowseText object
* \param ObjBitmap : an ObjBitmap already created or nil to remove the previous bitmap.
*
* \see _SETbrowseTextTitle
*
* \return BrowseText : The same BrowseText object
**/
fun _SETbrowseTextButtonBitmap (bt, oBmp)=
let _GETbitmapSize oBmp -> [ow oh] in
set bt.bt_oBmp =
if oBmp == nil then
nil
else
_CPbitmap24
_CRbitmap bt.bt_oChn ow oh
0
0
oBmp
0
0
ow
oh
nil;
browsetext_createButtonBitamp bt;
bt;;
/*! \brief Return the current ObjBitmap button of a BrowseText control.
*
* \ingroup _2dos_browstext
* Prototype : fun [BrowseText] ObjBitmap
*
* \param BrowseText : a BrowseText object
*
* \return ObjBitmap : this bitmap or nil if no bitmap displayed.
**/
fun _GETbrowseTextButtonBitmap (bt)=
bt.bt_oBmp;;
/*! \brief Enable or Disable the button of a BrowseText control
*
* \ingroup _2dos_browstext
* Prototype : fun [BrowseText I] BrowseText
*
* \param BrowseText : a BrowseText object
* \param I : the new state : BT_ENABLE or BT_DISABLE. Other value is ignored.
*
* \return BrowseText : The same BrowseText object or nil if error
**/
fun _ENbrowseTextButton (bt, state)=
if (state == BT_ENABLE) || (state == BT_DISABLE) then _ENbutton bt.bt_oButton state else nil;
bt;;
/*! \brief Enable or Disable the text field of a BrowseText control
*
* \ingroup _2dos_browstext
* Prototype : fun [BrowseText I] BrowseText
*
* \param BrowseText : a BrowseText object
* \param I : the new state : BT_ENABLE or BT_DISABLE. Other value is ignored.
*
* \return BrowseText : The same BrowseText object or nil if error
**/
fun _ENbrowseTextText (bt, state)=
if (state == BT_ENABLE) || (state == BT_DISABLE) then _ENtext bt.bt_oText state else nil;
bt;;
/*! \brief Return the current position and size of the button of a BrowseText control.
*
* \ingroup _2dos_browstext
* Prototype : fun [BrowseText] [I I I I]
*
* \see _GETbrowseTextSize
* \see _GETbrowseTextPosition
*
* \param BrowseText : a BrowseText object
*
* \return [I I I I] : x coordinate, y coordinate, width, height.
**/
fun _GETbrowseTextButtonCoord (bt)=
[bt.bt_iButtonX bt.bt_iButtonY bt.bt_iButtonWidth bt.bt_iButtonHeight];;
/*! \brief Return the current position and size of the text field of a
* BrowseText control.
*
* \ingroup _2dos_browstext
* Prototype : fun [BrowseText] [I I I I]
*
* \see _GETbrowseTextSize
* \see _GETbrowseTextPosition
*
* \param BrowseText : a BrowseText object
*
* \return [I I I I] : x coordinate, y coordinate, width, height.
**/
fun _GETbrowseTextTextCoord (bt)=
[bt.bt_iTextX bt.bt_iTextY bt.bt_iTextWidth bt.bt_iTextHeight];;
/*! \brief Display a 'tip' on the button of a BrowseText control.
*
* \ingroup _2dos_browstext
* Prototype : fun [BrowseText S] BrowseText
*
* \param BrowseText : a BrowseText object
* \param S : a string
*
* \bug the tip can not to appear on the screen. Check that !
*
* \return BrowseText : The same BrowseText object
**/
fun _SETbrowseTextTip (bt, szTip)=
set bt.bt_szTip = szTip;
_TIPbutton bt.bt_oButton bt.bt_szTip;
bt;;
/*! \brief Return the current button tip of a BrowseText control.
*
* \ingroup _2dos_browstext
* Prototype : fun [BrowseText] S
*
* \param BrowseText : a BrowseText object
*
* \return S : this tip
**/
fun _GETbrowseTextTip (bt)=
bt.bt_szTip;;
/*! \brief Remove a line in the text of a BrowseText control.
*
* \ingroup _2dos_browstext
* Prototype : fun [BrowseText I] BrowseText
*
* \param BrowseText : a BrowseText object
* \param I : a number line (0 is the first line).
*
* \return BrowseText : The same BrowseText object
**/
fun _REMOVEbrowseTextLine (bt, iNumber)=
_DELline bt.bt_oText iNumber;
bt;;
/*! \brief Return the number of the first visible text line of a BrowseText control.
*
* \ingroup _2dos_browstext
* Prototype : fun [BrowseText] I
*
* \param BrowseText : a BrowseText object
*
* \return I : this number line, can be different from 0 if the text field is scrolled.
**/
fun _GETbrowseTextFirstLine (bt)=
_GETfirstLine bt.bt_oText;;
/*! \brief Set the number of the first visible line from a text of a BrowseText control.
*
* \ingroup _2dos_browstext
* Prototype : fun [BrowseText I] BrowseText
*
* \param BrowseText : a BrowseText object
* \param I : the number line
*
* \return BrowseText : The same BrowseText object.
**/
fun _SETbrowseTextFirstLine (bt, iLine)=
_SETfirstLine bt.bt_oText iLine;
bt;;
/*! \brief Return the content of a line from a text of a BrowseText control.
*
* \ingroup _2dos_browstext
* Prototype : fun [BrowseText] S
*
* \param BrowseText : a BrowseText object
*
* \return S : this content.
**/
fun _GETbrowseTextContentLine (bt, iNumber)=
_GETline bt.bt_oText iNumber;;
/*! \brief Return the number of lines from a text of a BrowseText control.
*
* \ingroup _2dos_browstext
* Prototype : fun [BrowseText] I
*
* \param BrowseText : a BrowseText object
*
* \return I : this number.
**/
fun _GETbrowseTextLines (bt)=
_GETlineCount bt.bt_oText;;
/*! \brief Perform a scrolling to the character defined by its colummn
* and line coordinates from a text of a BrowseText control.
*
* \ingroup _2dos_browstext
* Prototype : fun [BrowseText I I] BrowseText
*
* \param BrowseText : a BrowseText object
* \param I : the column number
* \param I : the line number
*
* \return BrowseText : The same BrowseText object.
**/
fun _SCROLLbrowseText (bt, iColumn, iLine)=
_SCROLLtext bt.bt_oText iColumn iLine;;
/*! \brief Perform a scrolling to the line defined by its number from a
* text of a BrowseText control.
*
* \see _SETbrowseTextFirstLine
*
* \ingroup _2dos_browstext
* Prototype : fun [BrowseText I] BrowseText
*
* \param BrowseText : a BrowseText object
* \param I : the line number
*
* \return BrowseText : The same BrowseText object.
**/
fun _SCROLLbrowseTextV (bt, iLine)=
_SCROLLtext bt.bt_oText 0 iLine;;
/*! \brief Define the click event callback to a BrowseText control.
*
* \ingroup _2dos_browstext
* Prototype : fun [BrowseText fun [BrowseText u0] u1 u0] BrowseText
*
* \param BrowseText : a BrowseText object
* \param fun [BrowseText u0] u1 : the callback
* \param u0 : an user parameter, at your convenience
*
* \return BrowseText : The same BrowseText object.
*
* \todo event click on the text field
**/
fun _CBbrowseTextClick (bt, cbfun, uparam)=
_CBbutton bt.bt_oButton @browsertext_cbClick [cbfun bt uparam];
_CBwinClick bt.bt_oWin @browsertext_cbClickWin [cbfun bt uparam];
bt;;
/*! \brief Define the drag & drop event callback to a BrowseText control.
*
* \ingroup _2dos_browstext
* Prototype : fun [BrowseText fun [BrowseText u0 [P r1]] u1 u0] BrowseText
*
* \param BrowseText : a BrowseText object
* \param fun [BrowseText u0 [P r1]] u1 : the callback. The supplemental argument
* is the list of read-reference files
* \param u0 : an user parameter, at your convenience
*
* \return BrowseText : The same BrowseText object.
*
* \remark The flag BT_DRAGDROP must be set when the control is created.
*
* \see BT_DRAGDROP
**/
fun _CBbrowseTextDragDrop (bt, cbfun, uparam)=
_CBtextDropFile bt.bt_oText @browsertext_cbDragDrop [cbfun bt uparam];
_CBbuttonDropFile bt.bt_oButton @browsertext_cbDragDrop [cbfun bt uparam];
_CBwinDropFile bt.bt_oWin @browsertext_cbDragDrop [cbfun bt uparam];
bt;;
/*! \brief Define the key return pushed event callback to the text field
* of a BrowseText control.
*
* \ingroup _2dos_browstext
* Prototype : fun [BrowseText fun [BrowseText u0 S] u1 u0] BrowseText
*
* \param BrowseText : a BrowseText object
* \param fun [BrowseText u0 S] u1 : the callback. The supplemental argument
* is the current content
* \param u0 : an user parameter, at your convenience
*
* \return BrowseText : The same BrowseText object.
**/
fun _CBbrowseTextLineOk (bt, cbfun, uparam)=
_CBlineOk bt.bt_oText @browsertext_cbLineOk [cbfun bt uparam];
bt;;
/*! \brief Define the content changed event callback to the text field
* of a BrowseText control.
*
* \ingroup _2dos_browstext
* Prototype : fun [BrowseText fun [BrowseText u0 S] u1 u0] BrowseText
*
* \param BrowseText : a BrowseText object
* \param fun [BrowseText u0 S] u1 : the callback. The supplemental argument
* is the current content
* \param u0 : an user parameter, at your convenience
*
* \return BrowseText : The same BrowseText object.
**/
fun _CBbrowseTextChanged (bt, cbfun, uparam)=
_CBtext bt.bt_oText @browsertext_cbChanged [cbfun bt uparam];
bt;;
/*fun _CBbrowseTextCursor (bt, cbfun, uparam)=
_CBcursorMove bt.bt_oWin @browsertext_cbCursor [cbfun bt uparam];
bt;;*/
/*! \brief Define the close event callback to a BrowseText control.
*
* \ingroup _2dos_browstext
* Prototype : fun [BrowseText fun [BrowseText u0] u1 u0] BrowseText
*
* \param BrowseText : a BrowseText object
* \param fun [BrowseText u0] u1 : the callback.
* \param u0 : an user parameter, at your convenience
*
* \return BrowseText : The same BrowseText object.
*
* \remark This event occurs before the destroy event.
**/
fun _CBbrowseTextClose (bt, cbfun, uparam)=
_CBwinClose bt.bt_oWin @browsertext_cbClose [cbfun bt uparam];
bt;;
/*! \brief Define the destroy event callback to a BrowseText control.
*
* \ingroup _2dos_browstext
* Prototype : fun [BrowseText fun [BrowseText u0] u1 u0] BrowseText
*
* \param BrowseText : a BrowseText object
* \param fun [BrowseText u0] u1 : the callback.
* \param u0 : an user parameter, at your convenience
*
* \return BrowseText : The same BrowseText object.
**/
fun _CBbrowseTextDestroy (bt, cbfun, uparam)=
_CBwinDestroy bt.bt_oWin @browsertext_cbDestroy [cbfun bt uparam];
bt;;
/*! \brief Define the move event callback to a BrowseText control.
*
* \ingroup _2dos_browstext
* Prototype : fun [BrowseText fun [BrowseText u0 I I] u1 u0] BrowseText
*
* \param BrowseText : a BrowseText object
* \param fun [BrowseText u0 I I] u1 : the callback. The supplemental
* arguments are the new x and the y coordinates.
* \param u0 : an user parameter, at your convenience
*
* \return BrowseText : The same BrowseText object.
**/
fun _CBbrowseTextMove (bt, cbfun, uparam)=
_CBwinMove bt.bt_oWin @browsertext_cbMove [cbfun bt uparam];
bt;;
/*! \brief Define the resize event callback to a BrowseText control.
*
* \ingroup _2dos_browstext
* Prototype : fun [BrowseText fun [BrowseText u0 I I] u1 u0] BrowseText
*
* \param BrowseText : a BrowseText object
* \param fun [BrowseText u0 I I] u1 : the callback. The supplemental
* arguments are the new width and height.
* \param u0 : an user parameter, at your convenience
*
* \return BrowseText : The same BrowseText object.
**/
fun _CBbrowseTextSize (bt, cbfun, uparam)=
_CBwinSize bt.bt_oWin @browsertext_cbSize [cbfun bt uparam];
bt;;
/*! \brief Define the paint event callback to a BrowseText control.
*
* \ingroup _2dos_browstext
* Prototype : fun [BrowseText fun [BrowseText u0] u1 u0] BrowseText
*
* \param BrowseText : a BrowseText object
* \param fun [BrowseText u0] u1 : the callback.
* \param u0 : an user parameter, at your convenience
*
* \return BrowseText : The same BrowseText object.
**/
fun _CBbrowseTextPaint (bt, cbfun, uparam)=
_CBwinPaint bt.bt_oWin @browsertext_cbPaint [cbfun bt uparam];
bt;;
/*! \brief Build a predefined dialog box to a BrowseText control.
*
* \ingroup _2dos_browstext
* Prototype : fun [BrowseText I S S S] BrowseText
*
* \param BrowseText : a BrowseText object
* \param I : A flag. One of these following values :
* - BT_DLGOPENSINGLE : build a single file selection box for reading.
* - BT_DLGOPENMULTI : build a multiple file selection box for reading.
* - BT_DLGSAVE : build a file selection box for writing.
* - BT_DLGDIR : build a directory selection box.
* - Other values will be ignored and the function will return 'nil'.
* \param S : an initial path (relative to Scol first partition).
* nil for root directory.
* \param S : a default file (or directory) name. Can be nil.
* \param S : a file name filter, such as "text\0*.txt\0ASCII\0*.asc\0All\0*.*\0\0".
* Do not forget the terminal double "\0". If nil then "All\0*.*\0\0".
*
* \return BrowseText : The same BrowseText object.
*
* \remark The callback should be defined before to build the dialog. This
* definition can be kept until the called function is unchanged.
*
* \see _CBbrowseTextDialogOpen with BT_DLGOPENSINGLE flag
* \see _CBbrowseTextDialogOpenMulti with BT_DLGOPENMULTI flag
* \see _CBbrowseTextDialogSave with BT_DLGSAVE flag
* \see _CBbrowseTextDialogDir with BT_DLGDIR flag
**/
fun _BUILDbrowseTextDialog (bt, dlgType, initPath, initName, filter)=
if (bt == nil) then
nil
else
browseText_setDlg bt dlgType initPath initName filter;;
/* Cette fonction devrait permettre d'automatiser davantage le click
* sur le bouton du control. Mais ça pose pb pour l'heure car je dois
* redéfinir la CB. Enfin à suivre, y a sans doute pas grand chose à faire,
* juste s'y pencher 2 mn ! :)
*/
fun _SETbrowseTextButtonAction (bt, dlgType, initPath, initName, filter)=
if dlgType == nil then
set bt.bt_hasButtonAction = nil
else
set bt.bt_hasButtonAction = [dlgType initPath initName filter];
bt;;
/*! \brief Define the open single file dialog event callback to a BrowseText control.
*
* \ingroup _2dos_browstext
* Prototype : fun [BrowseText fun [BrowseText P] I] BrowseText
*
* \param BrowseText : a BrowseText object
* \param fun [BrowseText P] I : the callback. Parameters are :
* - BrowseText : the BrowseText object itself
* - P : the choosen read-reference file
*
* To add an user parameter, use 'mkfun3' function to obtain a callback with
* a prototype such as fun [BrowseText P u0] I
* Be carefull, this user parameter will be third argument.
*
* \see _BUILDbrowseTextDialog with BT_DLGOPENSINGLE flag
*
* \return BrowseText : The same BrowseText object.
**/
fun _CBbrowseTextDialogOpen (bt, cbfun)=
set bt.bt_cbDialogOpen = cbfun;
bt;;
/*! \brief Define the open multi file dialog event callback to a BrowseText control.
*
* \ingroup _2dos_browstext
* Prototype : fun [BrowseText fun [BrowseText [P r1]] I] BrowseText
*
* \param BrowseText : a BrowseText object
* \param fun [BrowseText [P r1]] I : the callback. Parameters are :
* - BrowseText : the BrowseText object itself
* - [P r1] : the choosen read-reference files list
*
* To add an user parameter, use 'mkfun3' function to obtain a callback with
* a prototype such as fun [BrowseText [P r1] u0] I
* Be carefull, this user parameter will be third argument.
*
* \see _BUILDbrowseTextDialog with BT_DLGOPENMULTI flag
*
* \return BrowseText : The same BrowseText object.
**/
fun _CBbrowseTextDialogOpenMulti (bt, cbfun)=
set bt.bt_cbDialogOpenMulti = cbfun;
bt;;
/*! \brief Define the save file dialog event callback to a BrowseText control.
*
* \ingroup _2dos_browstext
* Prototype : fun [BrowseText fun [BrowseText W] I] BrowseText
*
* \param BrowseText : a BrowseText object
* \param fun [BrowseText W] I : the callback. Parameters are :
* - BrowseText : the BrowseText object itself
* - W : the choosen write-reference file
*
* To add an user parameter, use 'mkfun3' function to obtain a callback with
* a prototype such as fun [BrowseText W u0] I
* Be carefull, this user parameter will be third argument.
*
* \see _BUILDbrowseTextDialog with BT_DLGSAVE flag
*
* \return BrowseText : The same BrowseText object.
**/
fun _CBbrowseTextDialogSave (bt, cbfun)=
set bt.bt_cbDialogSave = cbfun;
bt;;
/*! \brief Define the open directory dialog event callback to a BrowseText control.
*
* \ingroup _2dos_browstext
* Prototype : fun [BrowseText fun [BrowseText S] I] BrowseText
*
* \param BrowseText : a BrowseText object
* \param fun [BrowseText S] I : the callback. Parameters are :
* - BrowseText : the BrowseText object itself
* - S : the choosen filename
*
* To add an user parameter, use 'mkfun3' function to obtain a callback with
* a prototype such as fun [BrowseText S u0] I
* Be carefull, this user parameter will be third argument.
*
* \see _BUILDbrowseTextDialog with BT_DLGDIR flag
*
* \return BrowseText : The same BrowseText object.
**/
fun _CBbrowseTextDialogDir (bt, cbfun)=
set bt.bt_cbDialogDir = cbfun;
bt;;