home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
DP Tool Club 16
/
CD_ASCQ_16_0994.iso
/
news
/
4611
/
fw16d.ins
/
IDE
/
SOURCE
/
DIALOG.PRG
< prev
next >
Wrap
Text File
|
1994-06-07
|
11KB
|
358 lines
// Dialog Tools
// (c) FiveWin IDE
#include "FiveWin.ch"
//----------------------------------------------------------------------------//
function DlgNew()
DlgOpen( cGetNewFileName( "dialogs\DIALOG", "scr" ) )
return nil
//----------------------------------------------------------------------------//
function DlgOpen( cDlgName )
local oWndDlg, oIco, oBar, oBrw, oBmp, oControl
local cAlias
DEFAULT cDlgName := cGetFile( "FiveWin IDE Dialog ( *.scr ) | *.scr",;
"Select a Dialog" )
DEFINE ICON oIco RESOURCE "Dialog"
if Empty( cDlgName )
MsgInfo( "I can't find that file!" )
return nil
endif
if File( cDlgName )
USE ( cDlgName ) NEW SHARED
cAlias = Alias()
if RecCount() > 0
DEFINE WINDOW oWndDlg PIXEL ;
FROM ( cAlias )->Top, ( cAlias )->Left TO ;
( cAlias )->Top + ( cAlias )->Height - 1,;
( cAlias )->Left + ( cAlias )->Width - 1 ;
TITLE "Dialog: " + cNoExt( cNoPath( cDlgName ) ) MDICHILD ;
ICON oIco COLOR ( cAlias )->ClrFore, ( cAlias )->ClrBack
endif
else
DEFINE WINDOW oWndDlg FROM 2, 15 TO 20, 65 ;
TITLE "Dialog: " + cNoExt( cNoPath( cDlgName ) ) MDICHILD ;
ICON oIco
endif
DEFINE BUTTONBAR oBar OF oWndDlg
DEFINE BUTTON OF oBar RESOURCE "Static" ;
ACTION LabelAdd( oBmp, .t., cAlias )
DEFINE BUTTON OF oBar RESOURCE "Btn1" ;
ACTION BtnAdd( oBmp, .t., cAlias )
DEFINE BUTTON OF oBar RESOURCE "Check" ;
ACTION CheckAdd( oBmp, .t., cAlias )
DEFINE BUTTON OF oBar RESOURCE "ListBox" ;
ACTION LbxAdd( oBmp, .t., cAlias )
DEFINE BUTTON OF oBar RESOURCE "Get" ;
ACTION GetAdd( oBmp, .t., cAlias )
DEFINE BUTTON OF oBar RESOURCE "Radio" ;
ACTION RadioAdd( oBmp, .t., cAlias )
DEFINE BUTTON OF oBar RESOURCE "Shade" ;
ACTION ShadeAdd( oBmp, .t., cAlias )
DEFINE BUTTON OF oBar RESOURCE "Bitmap"
DEFINE BUTTON GROUP OF oBar RESOURCE "Clr" ;
ACTION oBmp:SelColor()
DEFINE BUTTON OF oBar RESOURCE "PRG" ;
ACTION ( oBmp:cGenPRG( "Dlg.prg" ), PrgOpen( "Dlg.prg" ) )
DEFINE BUTTON GROUP OF oBar RESOURCE "ToDisk" ;
ACTION lDlgSave( oWndDlg, cDlgName )
@ 0, 0 BITMAP oBmp OF oWndDlg
oBmp:SetColor( oWndDlg:nClrText, oWndDlg:nClrPane )
oWndDlg:SetControl( oBmp )
if ! Empty( cAlias )
while ! EoF()
do case
case AllTrim( ( cAlias )->Control ) == "TSAY"
LabelAdd( oBmp, .f., cAlias )
case AllTrim( ( cAlias )->Control ) == "TBUTTON"
BtnAdd( oBmp, .f., cAlias )
case AllTrim( ( cAlias )->Control ) == "TGET"
GetAdd( oBmp, .f., cAlias )
case AllTrim( ( cAlias )->Control ) == "TCHECKBOX"
CheckAdd( oBmp, .f., cAlias )
case AllTrim( ( cAlias )->Control ) == "TLISTBOX"
LbxAdd( oBmp, .f., cAlias )
endcase
SKIP
end
USE
endif
ACTIVATE WINDOW oWndDlg ;
VALID lDlgSave( oWndDlg, cDlgName )
return nil
//----------------------------------------------------------------------------//
static function LabelAdd( oWnd, lNew, cAlias )
local oSay
local cLabel
DEFAULT lNew := .t.
if lNew
@ 2, 2 SAY oSay PROMPT "&Label" DESIGN SIZE 70, 28 OF oWnd
else
cLabel = AllTrim( ( cAlias )->Caption )
@ ( cAlias )->Top, ( cAlias )->Left SAY oSay PROMPT cLabel ;
DESIGN SIZE ( cAlias )->Width, ( cAlias )->Height PIXEL OF oWnd ;
COLOR ( cAlias )->ClrFore, ( cAlias )->ClrBack ;
FONT BuildFont( cAlias )
endif
oSay:bRClicked = { || ThisInspect( oSay ) }
return nil
//----------------------------------------------------------------------------//
static function BtnAdd( oWnd, lNew, cAlias )
local oBtn
if lNew
@ 2, 2 BUTTON oBtn PROMPT "&Button" SIZE 80, 27 DESIGN OF oWnd
else
@ ( cAlias )->Top, ( cAlias )->Left BUTTON oBtn ;
PROMPT AllTrim( ( cAlias )->Caption ) ;
DESIGN SIZE ( cAlias )->Width, ( cAlias )->Height PIXEL OF oWnd ;
FONT BuildFont( cAlias )
endif
oBtn:bRClicked = { || ThisInspect( oBtn ) }
return nil
//----------------------------------------------------------------------------//
static function CheckAdd( oWnd, lNew, cAlias )
local oCheck
local lStatus := .f.
if lNew
@ 2, 2 CHECKBOX oCheck VAR lStatus PROMPT "&CheckBox" ;
SIZE 115, 24 DESIGN OF oWnd
else
@ ( cAlias )->Top, ( cAlias )->Left CHECKBOX oCheck ;
VAR lStatus PROMPT AllTrim( ( cAlias )->Caption ) ;
DESIGN SIZE ( cAlias )->Width, ( cAlias )->Height PIXEL OF oWnd ;
COLOR ( cAlias )->ClrFore, ( cAlias )->ClrBack ;
FONT BuildFont( cAlias )
endif
oCheck:Set3DLook()
oCheck:bRClicked = { || ThisInspect( oCheck ) }
return oCheck
//----------------------------------------------------------------------------//
static function LbxAdd( oWnd, lNew, cAlias )
local oLbx
local cItem := "One"
if lNew
@ 2, 2 LISTBOX oLbx VAR cItem ITEMS { "One", "Two", "Three" } ;
SIZE 100, 100 DESIGN OF oWnd
else
@ ( cAlias )->Top, ( cAlias )->Left LISTBOX oLbx VAR cItem ;
ITEMS { "One", "Two", "Three", "", "", "" } ;
SIZE ( cAlias )->Width, ( cAlias )->Height PIXEL DESIGN OF oWnd ;
COLOR ( cAlias )->ClrFore, ( cAlias )->ClrBack ;
FONT BuildFont( cAlias )
endif
oLbx:Set3DLook()
oLbx:bRClicked = { || ThisInspect( oLbx ) }
return oLbx
//----------------------------------------------------------------------------//
static function GetAdd( oWnd, lNew, cAlias )
local oGet
local cItem := Space( 15 )
if lNew
@ 2, 2 GET oGet VAR cItem SIZE 115, 24 DESIGN OF oWnd
else
@ ( cAlias )->Top, ( cAlias )->Left GET oGet VAR cItem ;
SIZE ( cAlias )->Width, ( cAlias )->Height PIXEL DESIGN OF oWnd ;
COLOR ( cAlias )->ClrFore, ( cAlias )->ClrBack ;
FONT BuildFont( cAlias )
endif
oGet:Set3DLook()
oGet:bRClicked = { || ThisInspect( oGet ) }
return oGet
//----------------------------------------------------------------------------//
static function RadioAdd( oWnd, lNew, cAlias )
local nItem := 1
local oRadio
@ 2, 2 RADIO oRadio VAR nItem PROMPT "&One", "Two", "&Three" OF oWnd
oRadio:Set3DLook()
// oRadio:bRClicked = { || ThisInspect( oRadio ) }
return oRadio
//----------------------------------------------------------------------------//
static function ShadeAdd( oWnd, lNew, cAlias )
local nItem := 1
local oRadio
// @ 2, 2 SAY oRadio VAR nItem PROMPT "&One", "Two", "&Three" OF oWnd
// oRadio:Set3DLook()
// oRadio:bRClicked = { || ThisInspect( oRadio ) }
return oRadio
//----------------------------------------------------------------------------//
static function lDlgSave( oWnd, cDlgName )
local n
local aPoint, aControls := oWnd:oControl:aControls
local cAlias
if ! MsgYesNo( "Do you wish to save this Dialog ?" )
return .t.
endif
if File( cDlgName )
if ! MsgYesno( "A file with that name already exists." + ;
"Do you want to overwrite it ?" )
return .t.
endif
endif
DbCreate( cDlgName, { { "CONTROL", "C", 15, 0 },;
{ "CAPTION", "C", 40, 0 },;
{ "ID", "N", 4, 0 },;
{ "TOP", "N", 4, 0 },;
{ "LEFT", "N", 4, 0 },;
{ "WIDTH", "N", 4, 0 },;
{ "HEIGHT", "N", 4, 0 },;
{ "STYLE", "N", 15, 0 },;
{ "CLRFORE", "N", 8, 0 },;
{ "CLRBACK", "N", 8, 0 },;
{ "FNTNAME", "C", 15, 0 },;
{ "FNTWIDTH", "N", 4, 0 },;
{ "FNTHEIGHT","N", 4, 0 },;
{ "FNTBOLD", "L", 1, 0 },;
{ "FNTITALIC","L", 1, 0 } } )
USE ( cDlgName ) NEW
ZAP
cAlias = Alias()
oWnd:CoorsUpdate()
ScreenToClient( oWnd:oWnd:oWndClient:hWnd,;
aPoint := { oWnd:nTop, oWnd:nLeft } )
APPEND BLANK
( cAlias )->Control = "TDIALOG"
( cAlias )->Caption = oWnd:cTitle
( cAlias )->Top = aPoint[ 1 ]
( cAlias )->Left = aPoint[ 2 ]
( cAlias )->Width = oWnd:nRight - oWnd:nLeft
( cAlias )->Height = oWnd:nBottom - oWnd:nTop
( cAlias )->Style = nValToN( oWnd:nStyle )
( cAlias )->ClrFore = oWnd:oControl:nClrText
( cAlias )->ClrBack = oWnd:oControl:nClrPane
if aControls != nil
for n = 1 to Len( aControls )
aControls[ n ]:CoorsUpdate()
ScreenToClient( oWnd:oControl:hWnd,;
aPoint := { aControls[ n ]:nTop, aControls[ n ]:nLeft } )
APPEND BLANK
( cAlias )->Control = aControls[ n ]:ClassName()
( cAlias )->Caption = aControls[ n ]:cCaption
( cAlias )->Top = aPoint[ 1 ]
( cAlias )->Left = aPoint[ 2 ]
( cAlias )->Width = aControls[ n ]:nRight - aControls[ n ]:nLeft - 1
( cAlias )->Height = aControls[ n ]:nBottom - aControls[ n ]:nTop - 1
( cAlias )->Style = nValToN( aControls[ n ]:nStyle )
( cAlias )->ClrFore = nValToN( aControls[ n ]:nClrText )
( cAlias )->ClrBack = nValToN( aControls[ n ]:nClrPane )
( cAlias )->FntName = cValToChar( aControls[ n ]:oFont:cFaceName )
( cAlias )->FntWidth = nValToN( aControls[ n ]:oFont:nWidth )
( cAlias )->FntHeight = nValToN( aControls[ n ]:oFont:nHeight )
( cAlias )->FntBold = lValToL( aControls[ n ]:oFont:lBold )
( cAlias )->FntItalic = lValToL( aControls[ n ]:oFont:lItalic )
next
endif
USE
return .t. // Close the Window
//----------------------------------------------------------------------------//
static function nValToN( uVal ) ; return If( ValType( uVal ) != "N", 0, uVal )
static function lValToL( uVal ) ; return If( ValType( uVal ) != "L", .f., uVal )
//----------------------------------------------------------------------------//
static function BuildFont( cAlias )
local oFont
if ! Empty( ( cAlias )->FntName )
oFont = TFont():New( AllTrim( ( cAlias )->FntName ),;
( cAlias )->FntWidth,;
( cAlias )->FntHeight,;
.f., ( cAlias )->FntBold,,,,;
( cAlias )->FntItalic )
endif
return oFont
//----------------------------------------------------------------------------//