|
of_paintinitialwindow
|
|
Full name
|
pfc_w_message.of_paintinitialwindow
|
Access
|
protected
|
Override of
|
integer
|
Return value
|
integer
|
Prototype
|
protected function integer of_paintinitialwindow()
|
Name
|
Datatype
|
li_longestlen
|
Integer
|
li_msgline
|
Integer
|
li_msglinecount
|
Integer
|
li_msglinelength
|
Integer
|
li_startpoint
|
Integer
|
li_tabcharlen
|
Integer
|
li_textlen
|
Integer
|
li_titlelen
|
Integer
|
li_widthmidpoint
|
Integer
|
li_x
|
Integer
|
li_y
|
Integer
|
ll_counttabs
|
Long
|
ll_pos
|
Long
|
ls_textline
|
String
|
lw_parent
|
Window
|
SEPARATOR
|
Integer
|
TAB
|
String
|
protected function integer of_paintinitialwindow ();//////////////////////////////////////////////////////////////////////////////
//
// Function: of_PaintInitialWindow
//
// Access: protected
//
// Arguments: (none)
//
// Returns: integer
// 1 if it succeeds and -1 if it fails.
//
// Description: Test for the validity of the SQLspy service.
//
//////////////////////////////////////////////////////////////////////////////
//
// Revision History
//
// Version
// 5.0 Initial version
// 5.0.02 Corrected code to determine longest text line.
// 5.0.02 Handle multiple font sizes.
// 5.0.02 Prevent the upper/left window coordinates from opening outside
// the screen.
//
//////////////////////////////////////////////////////////////////////////////
//
// Copyright © 1996-1997 Sybase, Inc. and its subsidiaries. All rights reserved.
// Any distribution of the PowerBuilder Foundation Classes (PFC)
// source code by other than Sybase, Inc. and its subsidiaries is prohibited.
//
//////////////////////////////////////////////////////////////////////////////
Integer li_titlelen=0
Integer li_textlen=0
Integer li_longestlen=0
Integer li_startpoint=1
constant Integer SEPARATOR =50
Integer li_msglinelength
Integer li_widthmidpoint
Integer li_msglinecount
Integer li_msgline
Integer li_tabcharlen
Integer li_x, li_y
Long ll_counttabs, ll_pos
String ls_textline
Window lw_parent
Constant String TAB='~t'
// Handle multiple font sizes.
of_UpdateFontSize()
// Get the Message Title Length (li_titlelen).
If Not IsNull(this.Title) Then
li_titlelen = Len(this.Title)
End If
// Get the number of lines on the Message Text
li_msglinecount = mle_message.LineCount()
// Get the longest Message Text Line Length (li_textlen).
li_tabcharlen = Len(TAB)
For li_msgline = 1 to li_msglinecount
// Set the starting position on the next line,
// loop until the cursor is confirmed on the next line.
mle_message.SelectText(li_startpoint, 0)
Do While mle_message.selectedline() < li_msgline
li_startpoint++
mle_message.SelectText(li_startpoint, 0)
LOOP
// Get the text on the Current Line.
ls_textline = mle_message.TextLine()
// Set the starting point to the end of the current line or start of next line..
li_startpoint += Len(ls_textline) + 1
// Determine the number of occurrences of the Tab Character.
ll_counttabs = 0
ll_Pos = Pos(ls_textline, TAB)
Do While ll_Pos > 0
ll_counttabs ++
ll_Pos = Pos(ls_textline, TAB, (ll_Pos + li_tabcharlen))
Loop
// Keep only the longest line length.
li_msglinelength = mle_message.LineLength()+ (ll_counttabs * ii_tabchars)
If li_msglinelength > li_textlen Then
li_textlen = li_msglinelength
End If
Next
// Keep the longest of the Title or Message length.
If li_titlelen > li_textlen Then
li_longestlen = li_titlelen
Else
li_longestlen = li_textlen
End If
// If at least one of the RightSide buttons are visible,
// prevent the window from width getting too small.
If (cb_print.Visible Or cb_userinput.Visible) Then
If li_longestlen < 25 Then
li_longestlen = 25
End If
End If
// Depending on the number of BottomSide buttons visible,
// prevent the window width from getting too small.
If cb_1.Visible And cb_2.Visible=False And cb_3.Visible=False Then
If li_longestlen < 10 Then
li_longestlen = 10
End If
ElseIf cb_1.Visible And cb_2.Visible And cb_3.Visible=False Then
If li_longestlen < 20 Then
li_longestlen = 20
End If
Else
If li_longestlen < 30 Then
li_longestlen = 30
End If
End If
// Set the appropriate attributes for the Message MLE.
If li_msglinecount > ii_maxlines Then
mle_message.VScrollbar = True
li_longestlen += 4
End If
// According to the text inside the Message Text,
// resize the Message control. (Check for predefined min/max)
If li_msglinecount < 2 Then
// Prevent BottomSide control from moving up too much.
li_msglinecount = 2
End If
If li_longestlen > ii_maxlinelen Then
// Prevent the width from going over the set max.
li_longestlen = ii_maxlinelen
End If
If li_msglinecount > ii_maxlines Then
// Prevent the Height from going over the set max.
li_msglinecount = ii_maxlines
End If
mle_message.Resize(li_longestlen * ii_charwidth + 50, &
li_msglinecount * ii_lineheight)
// Move the Right Hand buttons just to the right of the
// Message.
cb_print.X = mle_message.X + mle_message.Width + SEPARATOR
cb_userinput.X = mle_message.X + mle_message.Width + SEPARATOR
// Set the width of the window according to the size of
// the Message and the RightSide buttons.
If (cb_print.Visible=False And cb_userinput.Visible=False) Then
This.Width = mle_message.X + mle_message.Width + SEPARATOR + 30
Else
This.Width = mle_message.X + mle_message.Width + cb_print.Width + (SEPARATOR *2) + 30
End If
// Move the BottomSide Buttons right under the Message.
cb_1.Y = mle_message.Y + mle_message.Height + SEPARATOR
cb_2.Y = mle_message.Y + mle_message.Height + SEPARATOR
cb_3.Y = mle_message.Y + mle_message.Height + SEPARATOR
// Center the BottomSide Buttton(s). (if visible, offset some
// for the print and userinput buttons.)
If (cb_print.Visible Or cb_userinput.Visible) Then
li_widthmidpoint = (This.Width - cb_print.Width ) / 2
Else
li_widthmidpoint = This.Width / 2
End If
If cb_1.Visible And cb_2.Visible=False And cb_3.Visible=False Then
cb_1.x = li_widthmidpoint - (cb_1.Width / 2)
ElseIf cb_1.Visible And cb_2.Visible And cb_3.Visible=False Then
cb_1.x = li_widthmidpoint - (cb_1.Width +20)
cb_2.x = li_widthmidpoint +20
Else
cb_1.x = li_widthmidpoint - ((cb_1.Width +20) + (cb_1.width/2))
cb_2.x = li_widthmidpoint - (cb_2.width/2)
cb_3.x = li_widthmidpoint + (cb_3.width/2 +20)
End If
// Move, Resize, Hide the UserInput controls.
gb_userinput.Move (mle_message.X, &
mle_message.Y + mle_message.Height + cb_1.Height + SEPARATOR)
gb_userinput.Width = mle_message.Width
gb_userinput.Visible = False
st_userinput.Move (mle_message.X, &
gb_userinput.Y + gb_userinput.Height + SEPARATOR)
st_userinput.Visible = False
mle_userinput.Move(mle_message.X, &
st_userinput.Y + st_userinput.Height + 5)
mle_userinput.Width = mle_message.Width
mle_userinput.Visible = False
// Adjust the Height of the window to hide the User Input space.
This.Height = cb_1.Y + cb_1.Height + 100 + SEPARATOR
// Center the window on the Parent window.
lw_parent = ParentWindow()
If IsValid (lw_parent) Then
li_x = lw_parent.x + lw_parent.width/2 - This.width/2 - 100
If li_x < 0 Then li_x = 0
li_y = lw_parent.y + lw_parent.height/2 - This.height/2 - 100
If li_y < 0 Then li_y = 0
This.Move(li_x, li_y)
End If
Return 1
end function
Name
|
Owner
|
window.move |
window
|
window.parentwindow |
window
|
windowobject.move |
windowobject
|
windowobject.resize |
windowobject
|
multilineedit.linecount |
multilineedit
|
multilineedit.linelength |
multilineedit
|
multilineedit.selectedline |
multilineedit
|
multilineedit.selecttext |
multilineedit
|
multilineedit.textline |
multilineedit
|
systemfunctions.isnull |
systemfunctions
|
systemfunctions.isvalid |
systemfunctions
|
systemfunctions.len |
systemfunctions
|
systemfunctions.pos |
systemfunctions
|
systemfunctions.pos |
systemfunctions
|
pfc_w_message.of_updatefontsize |
pfc_w_message
|