Bearsampp 2025.8.29
Loading...
Searching...
No Matches
WinBinder Class Reference

Public Member Functions

 __construct ()
 createAppWindow ($caption, $width, $height, $style=null, $params=null)
 createButton ($parent, $caption, $xPos, $yPos, $width=null, $height=null, $style=null, $params=null)
 createControl ($parent, $ctlClass, $caption, $xPos, $yPos, $width, $height, $style=null, $params=null)
 createEditBox ($parent, $value, $xPos, $yPos, $width=null, $height=null, $style=null, $params=null)
 createFont ($fontName, $size=null, $color=null, $style=null)
 createHyperLink ($parent, $caption, $xPos, $yPos, $width=null, $height=null, $style=null, $params=null)
 createInputText ($parent, $value, $xPos, $yPos, $width=null, $height=null, $maxLength=null, $style=null, $params=null)
 createLabel ($parent, $caption, $xPos, $yPos, $width=null, $height=null, $style=null, $params=null)
 createNakedWindow ($caption, $width, $height, $style=null, $params=null)
 createProgressBar ($parent, $max, $xPos, $yPos, $width=null, $height=null, $style=null, $params=null)
 createRadioButton ($parent, $caption, $checked, $xPos, $yPos, $width=null, $height=null, $startGroup=false)
 createTimer ($wbobject, $wait=1000)
 createWindow ($parent, $wclass, $caption, $xPos, $yPos, $width, $height, $style=null, $params=null)
 destroyTimer ($wbobject, $timerobject)
 destroyWindow ($window)
 drawImage ($wbobject, $path, $xPos=0, $yPos=0, $width=0, $height=0)
 drawLine ($wbobject, $xStartPos, $yStartPos, $xEndPos, $yEndPos, $color, $height=1)
 drawRect ($parent, $xPos, $yPos, $width, $height, $color=15790320, $filled=true)
 drawText ($parent, $caption, $xPos, $yPos, $width=null, $height=null, $font=null)
 exec ($cmd, $params=null, $silent=false)
 findFile ($filename)
 getFocus ()
 getSystemInfo ($info)
 getText ($wbobject)
 getValue ($wbobject)
 incrProgressBar ($progressBar)
 isEnabled ($wbobject)
 mainLoop ()
 messageBox ($message, $type, $title=null)
 messageBoxError ($message, $title=null)
 messageBoxInfo ($message, $title=null)
 messageBoxOk ($message, $title=null)
 messageBoxOkCancel ($message, $title=null)
 messageBoxQuestion ($message, $title=null)
 messageBoxWarning ($message, $title=null)
 messageBoxYesNo ($message, $title=null)
 messageBoxYesNoCancel ($message, $title=null)
 refresh ($wbobject)
 reset ()
 resetProgressBar ($progressBar)
 setArea ($wbobject, $width, $height)
 setCursor ($wbobject, $type=self::CURSOR_ARROW)
 setDisabled ($wbobject)
 setEnabled ($wbobject, $enabled=true)
 setFocus ($wbobject)
 setHandler ($wbobject, $classCallback, $methodCallback, $launchTimer=null)
 setImage ($wbobject, $path)
 setMaxLength ($wbobject, $length)
 setProgressBarMax ($progressBar, $max)
 setProgressBarValue ($progressBar, $value)
 setRange ($wbobject, $min, $max)
 setStyle ($wbobject, $style)
 setText ($wbobject, $content)
 setValue ($wbobject, $content)
 sysDlgOpen ($parent, $title, $filter=null, $path=null)
 sysDlgPath ($parent, $title, $path=null)
 wait ($wbobject=null)

Data Fields

 $callback
 $gauge
const BOX_ERROR = WBC_STOP
const BOX_INFO = WBC_INFO
const BOX_OK = WBC_OK
const BOX_OKCANCEL = WBC_OKCANCEL
const BOX_QUESTION = WBC_QUESTION
const BOX_WARNING = WBC_WARNING
const BOX_YESNO = WBC_YESNO
const BOX_YESNOCANCEL = WBC_YESNOCANCEL
const CTRL_ID = 0
const CTRL_OBJ = 1
const CURSOR_ARROW = 'arrow'
const CURSOR_CROSS = 'cross'
const CURSOR_FINGER = 'finger'
const CURSOR_FORBIDDEN = 'forbidden'
const CURSOR_HELP = 'help'
const CURSOR_IBEAM = 'ibeam'
const CURSOR_NONE = null
const CURSOR_SIZEALL = 'sizeall'
const CURSOR_SIZENESW = 'sizenesw'
const CURSOR_SIZENS = 'sizens'
const CURSOR_SIZENWSE = 'sizenwse'
const CURSOR_SIZEWE = 'sizewe'
const CURSOR_UPARROW = 'uparrow'
const CURSOR_WAIT = 'wait'
const CURSOR_WAITARROW = 'waitarrow'
const INCR_PROGRESS_BAR = '++'
const NEW_LINE = '@nl@'
const SYSINFO_SCREENAREA = 'screenarea'
const SYSINFO_WORKAREA = 'workarea'

Private Member Functions

 callWinBinder ($function, $params=array(), $removeErrorHandler=false)
 processMessages ()
 windowIsValid ($window)

Static Private Member Functions

static writeLog ($log)

Private Attributes

 $countCtrls
 $defaultTitle

Detailed Description

Class WinBinder

This class provides an interface to the WinBinder library, allowing for the creation and management of Windows GUI elements in PHP. It includes methods for creating windows, controls, handling events, and executing system commands.

Definition at line 18 of file class.winbinder.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( )

WinBinder constructor.

Initializes the WinBinder class, sets the default window title, and resets control counters.

Definition at line 68 of file class.winbinder.php.

69 {
70 global $bearsamppCore;
71 Util::logInitClass($this);
72
73 $this->defaultTitle = APP_TITLE . ' ' . $bearsamppCore->getAppVersion();
74 $this->reset();
75 }
global $bearsamppCore
static logInitClass($classInstance)
const APP_TITLE
Definition root.php:13

References $bearsamppCore, APP_TITLE, Util\logInitClass(), and reset().

Member Function Documentation

◆ callWinBinder()

callWinBinder ( $function,
$params = array(),
$removeErrorHandler = false )
private

Calls a WinBinder function with error handling.

Parameters
string$functionThe name of the WinBinder function to call.
array$paramsThe parameters to pass to the function.
bool$removeErrorHandlerWhether to suppress errors during the call.
Returns
mixed The result of the function call.

Definition at line 142 of file class.winbinder.php.

142 : mixed
143 {
144 $result = false;
145 if (function_exists($function)) {
146 if ($removeErrorHandler) {
147 // Suppress all errors for this call
148 $oldErrorLevel = error_reporting(0);
149 $result = @call_user_func_array($function, $params);
150 error_reporting($oldErrorLevel);
151 } else {
152 $result = call_user_func_array($function, $params);
153 }
154 }
155
156 return $result;
157 }
$result

References $result.

Referenced by createControl(), createFont(), createTimer(), createWindow(), destroyTimer(), destroyWindow(), drawImage(), drawLine(), drawRect(), drawText(), exec(), findFile(), getFocus(), getSystemInfo(), getText(), getValue(), isEnabled(), mainLoop(), messageBox(), processMessages(), refresh(), setArea(), setCursor(), setEnabled(), setFocus(), setHandler(), setImage(), setMaxLength(), setProgressBarValue(), setRange(), setStyle(), setText(), setValue(), sysDlgOpen(), sysDlgPath(), wait(), and windowIsValid().

◆ createAppWindow()

createAppWindow ( $caption,
$width,
$height,
$style = null,
$params = null )

Creates a new application window.

Parameters
string$captionThe window caption.
int$widthThe width of the window.
int$heightThe height of the window.
mixed$styleThe window style.
mixed$paramsAdditional parameters for the window.
Returns
mixed The created window object.

Definition at line 97 of file class.winbinder.php.

97 : mixed
98 {
99 return $this->createWindow(null, AppWindow, $caption, WBC_CENTER, WBC_CENTER, $width, $height, $style, $params);
100 }
createWindow($parent, $wclass, $caption, $xPos, $yPos, $width, $height, $style=null, $params=null)

References createWindow().

◆ createButton()

createButton ( $parent,
$caption,
$xPos,
$yPos,
$width = null,
$height = null,
$style = null,
$params = null )

Creates a button control.

Parameters
mixed$parentThe parent window or control.
string$captionThe caption for the button.
int$xPosThe x-coordinate of the button.
int$yPosThe y-coordinate of the button.
int | null$widthThe width of the button.
int | null$heightThe height of the button.
mixed$styleThe style for the button.
mixed$paramsAdditional parameters for the button.
Returns
array An array containing the control ID and object.

Definition at line 868 of file class.winbinder.php.

869 {
870 $width = $width == null ? 80 : $width;
871 $height = $height == null ? 25 : $height;
872
873 return $this->createControl($parent, PushButton, $caption, $xPos, $yPos, $width, $height, $style, $params);
874 }
createControl($parent, $ctlClass, $caption, $xPos, $yPos, $width, $height, $style=null, $params=null)

References createControl().

◆ createControl()

createControl ( $parent,
$ctlClass,
$caption,
$xPos,
$yPos,
$width,
$height,
$style = null,
$params = null )

Creates a new control.

Parameters
mixed$parentThe parent window or control.
string$ctlClassThe control class.
string$captionThe control caption.
int$xPosThe x-coordinate of the control.
int$yPosThe y-coordinate of the control.
int$widthThe width of the control.
int$heightThe height of the control.
mixed$styleThe control style.
mixed$paramsAdditional parameters for the control.
Returns
array An array containing the control ID and object.

Definition at line 707 of file class.winbinder.php.

708 {
709 $this->countCtrls++;
710
711 return array(
712 self::CTRL_ID => $this->countCtrls,
713 self::CTRL_OBJ => $this->callWinBinder('wb_create_control', array(
714 $parent,
715 $ctlClass,
716 $caption,
717 $xPos,
718 $yPos,
719 $width,
720 $height,
721 $this->countCtrls,
722 $style,
723 $params
724 )),
725 );
726 }
callWinBinder($function, $params=array(), $removeErrorHandler=false)

References callWinBinder().

Referenced by createButton(), createEditBox(), createHyperLink(), createInputText(), createLabel(), createProgressBar(), and createRadioButton().

◆ createEditBox()

createEditBox ( $parent,
$value,
$xPos,
$yPos,
$width = null,
$height = null,
$style = null,
$params = null )

Creates an edit box control.

Parameters
mixed$parentThe parent window or control.
string$valueThe initial value for the edit box.
int$xPosThe x-coordinate of the edit box.
int$yPosThe y-coordinate of the edit box.
int | null$widthThe width of the edit box.
int | null$heightThe height of the edit box.
mixed$styleThe style for the edit box.
mixed$paramsAdditional parameters for the edit box.
Returns
array An array containing the control ID and object.

Definition at line 783 of file class.winbinder.php.

784 {
785 $value = str_replace(self::NEW_LINE, PHP_EOL, $value);
786 $width = $width == null ? 540 : $width;
787 $height = $height == null ? 340 : $height;
788 $editBox = $this->createControl($parent, RTFEditBox, (string)$value, $xPos, $yPos, $width, $height, $style, $params);
789
790 return $editBox;
791 }

References createControl().

◆ createFont()

createFont ( $fontName,
$size = null,
$color = null,
$style = null )

Creates a font for use in WinBinder controls.

Parameters
string$fontNameThe name of the font.
int | null$sizeThe size of the font.
int | null$colorThe color of the font.
mixed$styleThe style of the font.
Returns
mixed The created font object.

Definition at line 469 of file class.winbinder.php.

470 {
471 return $this->callWinBinder('wb_create_font', array($fontName, $size, $color, $style));
472 }

References callWinBinder().

◆ createHyperLink()

createHyperLink ( $parent,
$caption,
$xPos,
$yPos,
$width = null,
$height = null,
$style = null,
$params = null )

Creates a hyperlink control.

Parameters
mixed$parentThe parent window or control.
string$captionThe caption for the hyperlink.
int$xPosThe x-coordinate of the hyperlink.
int$yPosThe y-coordinate of the hyperlink.
int | null$widthThe width of the hyperlink.
int | null$heightThe height of the hyperlink.
mixed$styleThe style for the hyperlink.
mixed$paramsAdditional parameters for the hyperlink.
Returns
array An array containing the control ID and object.

Definition at line 807 of file class.winbinder.php.

808 {
809 $caption = str_replace(self::NEW_LINE, PHP_EOL, $caption);
810 $width = $width == null ? 120 : $width;
811 $height = $height == null ? 15 : $height;
812 $hyperLink = $this->createControl($parent, HyperLink, (string)$caption, $xPos, $yPos, $width, $height, $style, $params);
813 $this->setCursor($hyperLink[self::CTRL_OBJ], self::CURSOR_FINGER);
814
815 return $hyperLink;
816 }
setCursor($wbobject, $type=self::CURSOR_ARROW)

References createControl(), and setCursor().

◆ createInputText()

createInputText ( $parent,
$value,
$xPos,
$yPos,
$width = null,
$height = null,
$maxLength = null,
$style = null,
$params = null )

Creates an input text control.

Parameters
mixed$parentThe parent window or control.
string$valueThe initial value for the input text.
int$xPosThe x-coordinate of the input text.
int$yPosThe y-coordinate of the input text.
int | null$widthThe width of the input text.
int | null$heightThe height of the input text.
int | null$maxLengthThe maximum length of the input text.
mixed$styleThe style for the input text.
mixed$paramsAdditional parameters for the input text.
Returns
array An array containing the control ID and object.

Definition at line 743 of file class.winbinder.php.

744 {
745 $value = str_replace(self::NEW_LINE, PHP_EOL, $value);
746 $width = $width == null ? 120 : $width;
747 $height = $height == null ? 25 : $height;
748 $inputText = $this->createControl($parent, EditBox, (string)$value, $xPos, $yPos, $width, $height, $style, $params);
749 if (is_numeric($maxLength) && $maxLength > 0) {
750 $this->setMaxLength($inputText[self::CTRL_OBJ], $maxLength);
751 }
752
753 return $inputText;
754 }
setMaxLength($wbobject, $length)

References createControl(), and setMaxLength().

◆ createLabel()

createLabel ( $parent,
$caption,
$xPos,
$yPos,
$width = null,
$height = null,
$style = null,
$params = null )

Creates a label control.

Parameters
mixed$parentThe parent window or control.
string$captionThe caption for the label.
int$xPosThe x-coordinate of the label.
int$yPosThe y-coordinate of the label.
int | null$widthThe width of the label.
int | null$heightThe height of the label.
mixed$styleThe style for the label.
mixed$paramsAdditional parameters for the label.
Returns
array An array containing the control ID and object.

Definition at line 683 of file class.winbinder.php.

684 {
685 $caption = str_replace(self::NEW_LINE, PHP_EOL, $caption);
686 $width = $width == null ? 120 : $width;
687 $height = $height == null ? 25 : $height;
688
689 return $this->createControl($parent, Label, $caption, $xPos, $yPos, $width, $height, $style, $params);
690 }

References createControl().

◆ createNakedWindow()

createNakedWindow ( $caption,
$width,
$height,
$style = null,
$params = null )

Creates a new naked window.

Parameters
string$captionThe window caption.
int$widthThe width of the window.
int$heightThe height of the window.
mixed$styleThe window style.
mixed$paramsAdditional parameters for the window.
Returns
mixed The created window object.

Definition at line 195 of file class.winbinder.php.

195 : mixed
196 {
197 $window = $this->createWindow(null, NakedWindow, $caption, WBC_CENTER, WBC_CENTER, $width, $height, $style, $params);
198 $this->setArea($window, $width, $height);
199
200 return $window;
201 }
setArea($wbobject, $width, $height)

References createWindow(), and setArea().

◆ createProgressBar()

createProgressBar ( $parent,
$max,
$xPos,
$yPos,
$width = null,
$height = null,
$style = null,
$params = null )

Creates a progress bar control.

Parameters
mixed$parentThe parent window or control.
int$maxThe maximum value for the progress bar.
int$xPosThe x-coordinate of the progress bar.
int$yPosThe y-coordinate of the progress bar.
int | null$widthThe width of the progress bar.
int | null$heightThe height of the progress bar.
mixed$styleThe style for the progress bar.
mixed$paramsAdditional parameters for the progress bar.
Returns
array An array containing the control ID and object.

Definition at line 890 of file class.winbinder.php.

891 {
892 global $bearsamppLang;
893
894 $width = $width == null ? 200 : $width;
895 $height = $height == null ? 15 : $height;
896 $progressBar = $this->createControl($parent, Gauge, $bearsamppLang->getValue(Lang::LOADING), $xPos, $yPos, $width, $height, $style, $params);
897
898 $this->setRange($progressBar[self::CTRL_OBJ], 0, $max);
899 $this->gauge[$progressBar[self::CTRL_OBJ]] = 0;
900
901 return $progressBar;
902 }
global $bearsamppLang
const LOADING
setRange($wbobject, $min, $max)

References $bearsamppLang, createControl(), Lang\LOADING, and setRange().

◆ createRadioButton()

createRadioButton ( $parent,
$caption,
$checked,
$xPos,
$yPos,
$width = null,
$height = null,
$startGroup = false )

Creates a radio button control.

Parameters
mixed$parentThe parent window or control.
string$captionThe caption for the radio button.
bool$checkedWhether the radio button is checked.
int$xPosThe x-coordinate of the radio button.
int$yPosThe y-coordinate of the radio button.
int | null$widthThe width of the radio button.
int | null$heightThe height of the radio button.
bool$startGroupWhether this radio button starts a new group.
Returns
array An array containing the control ID and object.

Definition at line 845 of file class.winbinder.php.

846 {
847 $caption = str_replace(self::NEW_LINE, PHP_EOL, $caption);
848 $width = $width == null ? 120 : $width;
849 $height = $height == null ? 25 : $height;
850
851 return $this->createControl($parent, RadioButton, (string)$caption, $xPos, $yPos, $width, $height, $startGroup ? WBC_GROUP : null, $checked ? 1 : 0);
852 }

References createControl().

◆ createTimer()

createTimer ( $wbobject,
$wait = 1000 )

Creates a timer for a WinBinder object.

Parameters
mixed$wbobjectThe WinBinder object to create the timer for.
int$waitThe wait time in milliseconds.
Returns
array An array containing the timer ID and object.

Definition at line 543 of file class.winbinder.php.

544 {
545 $this->countCtrls++;
546
547 return array(
548 self::CTRL_ID => $this->countCtrls,
549 self::CTRL_OBJ => $this->callWinBinder('wb_create_timer', array($wbobject, $this->countCtrls, $wait))
550 );
551 }

References callWinBinder().

Referenced by setHandler().

◆ createWindow()

createWindow ( $parent,
$wclass,
$caption,
$xPos,
$yPos,
$width,
$height,
$style = null,
$params = null )

Creates a new window.

Parameters
mixed$parentThe parent window or null for a top-level window.
string$wclassThe window class.
string$captionThe window caption.
int$xPosThe x-coordinate of the window.
int$yPosThe y-coordinate of the window.
int$widthThe width of the window.
int$heightThe height of the window.
mixed$styleThe window style.
mixed$paramsAdditional parameters for the window.
Returns
mixed The created window object.

Definition at line 117 of file class.winbinder.php.

117 : mixed
118 {
119 global $bearsamppCore;
120
121 // Fix for PHP 8.2: Convert null to 0 for parent parameter
122 $parent = $parent === null ? 0 : $parent;
123
124 $caption = empty($caption) ? $this->defaultTitle : $this->defaultTitle . ' - ' . $caption;
125 $window = $this->callWinBinder('wb_create_window', array($parent, $wclass, $caption, $xPos, $yPos, $width, $height, $style, $params));
126
127 // Set tiny window icon
128 $this->setImage($window, $bearsamppCore->getIconsPath() . '/app.ico');
129
130 return $window;
131 }
setImage($wbobject, $path)

References $bearsamppCore, callWinBinder(), and setImage().

Referenced by createAppWindow(), and createNakedWindow().

◆ destroyTimer()

destroyTimer ( $wbobject,
$timerobject )

Destroys a timer for a WinBinder object.

Parameters
mixed$wbobjectThe WinBinder object to destroy the timer for.
mixed$timerobjectThe timer object to destroy.
Returns
mixed The result of the destroy operation.

Definition at line 494 of file class.winbinder.php.

495 {
496 return $this->callWinBinder('wb_destroy_timer', array($wbobject, $timerobject));
497 }

References callWinBinder().

◆ destroyWindow()

destroyWindow ( $window)

Destroys a window with proper cleanup and handling.

Parameters
mixed$windowThe window object to destroy.
Returns
boolean True if window was successfully destroyed

Definition at line 223 of file class.winbinder.php.

223 : bool
224 {
225 // Check if window exists and is valid
226 if (!$window || !$this->windowIsValid($window)) {
227 return true; // Already closed or invalid window
228 }
229
230 // Get window title before destruction for fallback
231 $windowTitle = $this->getText($window);
232 $currentPid = Win32Ps::getCurrentPid();
233
234 // Attempt standard destruction
235 $this->callWinBinder('wb_destroy_window', array($window));
236
237 // Verify closure with retries
238 $maxAttempts = 3;
239 $attempt = 0;
240 $destroyed = false;
241
242 while ($attempt < $maxAttempts && !$destroyed) {
243 $this->processMessages();
244 usleep(100000); // 100ms delay
245 $destroyed = !$this->windowIsValid($window);
246 $attempt++;
247 }
248
249 // Fallback to process termination if window still exists
250 if (!$destroyed) {
251 // 1. Try to close using window title
252 $this->exec('taskkill', '/FI "WINDOWTITLE eq ' . $windowTitle . '" /F', true);
253
254 // 2. Try to kill process directly using Winbinder's PID method
255 $currentPid = Win32Ps::getCurrentPid();
256 if (!empty($currentPid)) {
257 $this->exec('taskkill', '/PID ' . $currentPid . ' /T /F', true);
258 $this->writeLog('Force-killed PID: ' . $currentPid . ' for window: ' . $window);
259 }
260
261 // 3. Final sanity check
262 if ($this->windowIsValid($window)) {
263 $this->callWinBinder('wb_destroy_window', array($window), true); // Force native call
264 }
265
266 // 4. Reset internal state to prevent memory leaks
267 $this->reset();
268 }
269
270 // Final verification
271 return !$this->windowIsValid($window);
272 }
static getCurrentPid()
static writeLog($log)
windowIsValid($window)
getText($wbobject)
exec($cmd, $params=null, $silent=false)

References callWinBinder(), exec(), Win32Ps\getCurrentPid(), getText(), processMessages(), reset(), windowIsValid(), and writeLog().

◆ drawImage()

drawImage ( $wbobject,
$path,
$xPos = 0,
$yPos = 0,
$width = 0,
$height = 0 )

Draws an image on a WinBinder object.

Parameters
mixed$wbobjectThe WinBinder object to draw on.
string$pathThe path to the image file.
int$xPosThe x-coordinate of the image.
int$yPosThe y-coordinate of the image.
int$widthThe width of the image.
int$heightThe height of the image.
Returns
mixed The result of the draw operation.

Definition at line 394 of file class.winbinder.php.

394 : mixed
395 {
396 $image = $this->callWinBinder('wb_load_image', array($path));
397
398 return $this->callWinBinder('wb_draw_image', array($wbobject, $image, $xPos, $yPos, $width, $height));
399 }

References callWinBinder().

◆ drawLine()

drawLine ( $wbobject,
$xStartPos,
$yStartPos,
$xEndPos,
$yEndPos,
$color,
$height = 1 )

Draws a line on a WinBinder object.

Parameters
mixed$wbobjectThe WinBinder object to draw on.
int$xStartPosThe starting x-coordinate of the line.
int$yStartPosThe starting y-coordinate of the line.
int$xEndPosThe ending x-coordinate of the line.
int$yEndPosThe ending y-coordinate of the line.
int$colorThe color of the line.
int$heightThe height of the line.
Returns
mixed The result of the draw operation.

Definition at line 454 of file class.winbinder.php.

455 {
456 return $this->callWinBinder('wb_draw_line', array($wbobject, $xStartPos, $yStartPos, $xEndPos, $yEndPos, $color, $height));
457 }

References callWinBinder().

◆ drawRect()

drawRect ( $parent,
$xPos,
$yPos,
$width,
$height,
$color = 15790320,
$filled = true )

Draws a rectangle on a WinBinder object.

Parameters
mixed$parentThe parent WinBinder object.
int$xPosThe x-coordinate of the rectangle.
int$yPosThe y-coordinate of the rectangle.
int$widthThe width of the rectangle.
int$heightThe height of the rectangle.
int$colorThe color of the rectangle.
bool$filledWhether the rectangle should be filled.
Returns
mixed The result of the draw operation.

Definition at line 436 of file class.winbinder.php.

437 {
438 return $this->callWinBinder('wb_draw_rect', array($parent, $xPos, $yPos, $width, $height, $color, $filled));
439 }

References callWinBinder().

◆ drawText()

drawText ( $parent,
$caption,
$xPos,
$yPos,
$width = null,
$height = null,
$font = null )

Draws text on a WinBinder object.

Parameters
mixed$parentThe parent WinBinder object.
string$captionThe text to draw.
int$xPosThe x-coordinate of the text.
int$yPosThe y-coordinate of the text.
int | null$widthThe width of the text area.
int | null$heightThe height of the text area.
mixed$fontThe font to use for the text.
Returns
mixed The result of the draw operation.

Definition at line 414 of file class.winbinder.php.

415 {
416 $caption = str_replace(self::NEW_LINE, PHP_EOL, $caption);
417 $width = $width == null ? 120 : $width;
418 $height = $height == null ? 25 : $height;
419
420 return $this->callWinBinder('wb_draw_text', array($parent, $caption, $xPos, $yPos, $width, $height, $font));
421 }

References callWinBinder().

◆ exec()

exec ( $cmd,
$params = null,
$silent = false )

Executes a system command.

Parameters
string$cmdThe command to execute.
string | null$paramsThe parameters to pass to the command.
bool$silentWhether to execute the command silently.
Returns
mixed The result of the command execution.

Definition at line 322 of file class.winbinder.php.

322 : mixed
323 {
324 global $bearsamppCore;
325
326 if ($silent) {
327 $silent = '"' . $bearsamppCore->getScript(Core::SCRIPT_EXEC_SILENT) . '" "' . $cmd . '"';
328 $cmd = 'wscript.exe';
329 $params = !empty($params) ? $silent . ' "' . $params . '"' : $silent;
330 }
331
332 $this->writeLog('exec: ' . $cmd . ' ' . $params);
333
334 return $this->callWinBinder('wb_exec', array($cmd, $params));
335 }
const SCRIPT_EXEC_SILENT

References $bearsamppCore, callWinBinder(), Core\SCRIPT_EXEC_SILENT, and writeLog().

Referenced by destroyWindow().

◆ findFile()

findFile ( $filename)

Finds a file using WinBinder.

Parameters
string$filenameThe name of the file to find.
Returns
mixed The result of the find operation.

Definition at line 506 of file class.winbinder.php.

507 {
508 $result = $this->callWinBinder('wb_find_file', array($filename));
509 $this->writeLog('findFile ' . $filename . ': ' . $result);
510
511 return $result != $filename ? $result : false;
512 }

References $result, callWinBinder(), and writeLog().

◆ getFocus()

getFocus ( )

Retrieves the focus from a WinBinder object.

Returns
mixed The WinBinder object that has the focus.

Definition at line 573 of file class.winbinder.php.

574 {
575 return $this->callWinBinder('wb_get_focus');
576 }

References callWinBinder().

◆ getSystemInfo()

getSystemInfo ( $info)

Retrieves system information.

Parameters
string$infoThe type of system information to retrieve.
Returns
mixed The retrieved system information.

Definition at line 377 of file class.winbinder.php.

377 : mixed
378 {
379 return $this->callWinBinder('wb_get_system_info', array($info));
380 }

References callWinBinder().

◆ getText()

getText ( $wbobject)

Retrieves the text from a WinBinder object.

Parameters
mixed$wbobjectThe WinBinder object to get the text from.
Returns
mixed The retrieved text.

Definition at line 281 of file class.winbinder.php.

281 : mixed
282 {
283 return $this->callWinBinder('wb_get_text', array($wbobject));
284 }

References callWinBinder().

Referenced by destroyWindow().

◆ getValue()

getValue ( $wbobject)

Retrieves the value from a WinBinder object.

Parameters
mixed$wbobjectThe WinBinder object to get the value from.
Returns
mixed The retrieved value.

Definition at line 911 of file class.winbinder.php.

912 {
913 return $this->callWinBinder('wb_get_value', array($wbobject));
914 }

References callWinBinder().

◆ incrProgressBar()

incrProgressBar ( $progressBar)

Increments the value of a progress bar.

Parameters
array$progressBarThe progress bar control.

Definition at line 935 of file class.winbinder.php.

936 {
937 $this->setProgressBarValue($progressBar, self::INCR_PROGRESS_BAR);
938 }
setProgressBarValue($progressBar, $value)

References setProgressBarValue().

◆ isEnabled()

isEnabled ( $wbobject)

Checks if a WinBinder object is enabled.

Parameters
mixed$wbobjectThe WinBinder object to check.
Returns
mixed True if the object is enabled, false otherwise.

Definition at line 597 of file class.winbinder.php.

598 {
599 return $this->callWinBinder('wb_get_enabled', array($wbobject));
600 }

References callWinBinder().

◆ mainLoop()

mainLoop ( )

Starts the main event loop.

Returns
mixed The result of the main loop.

Definition at line 353 of file class.winbinder.php.

353 : mixed
354 {
355 return $this->callWinBinder('wb_main_loop');
356 }

References callWinBinder().

◆ messageBox()

messageBox ( $message,
$type,
$title = null )

Displays a message box.

Parameters
string$messageThe message to display.
int$typeThe type of message box.
string | null$titleThe title of the message box.
Returns
mixed The result of the message box operation.

Definition at line 1018 of file class.winbinder.php.

1019 {
1020 global $bearsamppCore;
1021
1022 $message = str_replace(self::NEW_LINE, PHP_EOL, $message);
1023 $messageBox = $this->callWinBinder('wb_message_box', array(
1024 0, // Use 0 instead of null for the window handle parameter
1025 strlen($message) < 64 ? str_pad($message, 64) : $message, // Pad message to display entire title
1026 $title == null ? $this->defaultTitle : $this->defaultTitle . ' - ' . $title,
1027 $type
1028 ));
1029
1030 return $messageBox;
1031 }

References $bearsamppCore, and callWinBinder().

Referenced by messageBoxError(), messageBoxInfo(), messageBoxOk(), messageBoxOkCancel(), messageBoxQuestion(), messageBoxWarning(), messageBoxYesNo(), and messageBoxYesNoCancel().

◆ messageBoxError()

messageBoxError ( $message,
$title = null )

Displays an error message box.

Parameters
string$messageThe message to display.
string | null$titleThe title of the message box. If null, the default title will be used.
Returns
mixed The result of the message box operation.

Definition at line 1080 of file class.winbinder.php.

1081 {
1082 return $this->messageBox($message, self::BOX_ERROR, $title);
1083 }
messageBox($message, $type, $title=null)

References messageBox().

◆ messageBoxInfo()

messageBoxInfo ( $message,
$title = null )

Displays an informational message box.

Parameters
string$messageThe message to display.
string | null$titleThe title of the message box.
Returns
mixed The result of the message box operation.

Definition at line 1004 of file class.winbinder.php.

1005 {
1006 return $this->messageBox($message, self::BOX_INFO, $title);
1007 }

References messageBox().

◆ messageBoxOk()

messageBoxOk ( $message,
$title = null )

Displays an OK message box.

Parameters
string$messageThe message to display.
string | null$titleThe title of the message box.
Returns
mixed The result of the message box operation.

Definition at line 1041 of file class.winbinder.php.

1042 {
1043 return $this->messageBox($message, self::BOX_OK, $title);
1044 }

References messageBox().

◆ messageBoxOkCancel()

messageBoxOkCancel ( $message,
$title = null )

Displays an OK/Cancel message box.

Parameters
string$messageThe message to display.
string | null$titleThe title of the message box.
Returns
mixed The result of the message box operation.

Definition at line 1054 of file class.winbinder.php.

1055 {
1056 return $this->messageBox($message, self::BOX_OKCANCEL, $title);
1057 }

References messageBox().

◆ messageBoxQuestion()

messageBoxQuestion ( $message,
$title = null )

Displays a question message box.

Parameters
string$messageThe message to display.
string | null$titleThe title of the message box. If null, the default title will be used.
Returns
mixed The result of the message box operation.

Definition at line 1067 of file class.winbinder.php.

1068 {
1069 return $this->messageBox($message, self::BOX_QUESTION, $title);
1070 }

References messageBox().

◆ messageBoxWarning()

messageBoxWarning ( $message,
$title = null )

Displays a warning message box.

Parameters
string$messageThe message to display.
string | null$titleThe title of the message box. If null, the default title will be used.
Returns
mixed The result of the message box operation.

Definition at line 1093 of file class.winbinder.php.

1094 {
1095 return $this->messageBox($message, self::BOX_WARNING, $title);
1096 }

References messageBox().

◆ messageBoxYesNo()

messageBoxYesNo ( $message,
$title = null )

Displays a Yes/No message box.

Parameters
string$messageThe message to display.
string | null$titleThe title of the message box. If null, the default title will be used.
Returns
mixed The result of the message box operation.

Definition at line 1106 of file class.winbinder.php.

1107 {
1108 return $this->messageBox($message, self::BOX_YESNO, $title);
1109 }

References messageBox().

◆ messageBoxYesNoCancel()

messageBoxYesNoCancel ( $message,
$title = null )

Displays a Yes/No/Cancel message box.

Parameters
string$messageThe message to display.
string | null$titleThe title of the message box. If null, the default title will be used.
Returns
mixed The result of the message box operation.

Definition at line 1119 of file class.winbinder.php.

1120 {
1121 return $this->messageBox($message, self::BOX_YESNOCANCEL, $title);
1122 }

References messageBox().

◆ processMessages()

processMessages ( )
private

Process any pending window messages.

Returns
void

Definition at line 308 of file class.winbinder.php.

308 : void
309 {
310 $this->callWinBinder('wb_wait', array(null, 1), true);
311 }

References callWinBinder().

Referenced by destroyWindow().

◆ refresh()

refresh ( $wbobject)

Refreshes a WinBinder object.

Parameters
mixed$wbobjectThe WinBinder object to refresh.
Returns
mixed The result of the refresh operation.

Definition at line 365 of file class.winbinder.php.

365 : mixed
366 {
367 return $this->callWinBinder('wb_refresh', array($wbobject, true));
368 }

References callWinBinder().

◆ reset()

reset ( )

Resets the control counter and callback array.

Definition at line 80 of file class.winbinder.php.

80 : void
81 {
82 $this->countCtrls = 1000;
83 $this->callback = array();
84 }

Referenced by __construct(), and destroyWindow().

◆ resetProgressBar()

resetProgressBar ( $progressBar)

Resets the value of a progress bar to zero.

Parameters
array$progressBarThe progress bar control.

Definition at line 980 of file class.winbinder.php.

981 {
982 $this->setProgressBarValue($progressBar, 0);
983 }

References setProgressBarValue().

◆ setArea()

setArea ( $wbobject,
$width,
$height )

Sets the area of a WinBinder object.

Parameters
mixed$wbobjectThe WinBinder object to set the area for.
int$widthThe width of the area.
int$heightThe height of the area.
Returns
mixed The result of the set area operation.

Definition at line 212 of file class.winbinder.php.

212 : mixed
213 {
214 return $this->callWinBinder('wb_set_area', array($wbobject, WBC_TITLE, 0, 0, $width, $height));
215 }

References callWinBinder().

Referenced by createNakedWindow().

◆ setCursor()

setCursor ( $wbobject,
$type = self::CURSOR_ARROW )

Sets the cursor type for a WinBinder object.

Parameters
mixed$wbobjectThe WinBinder object to set the cursor for.
string$typeThe cursor type to set.
Returns
mixed The result of the set cursor operation.

Definition at line 826 of file class.winbinder.php.

827 {
828 return $this->callWinBinder('wb_set_cursor', array($wbobject, $type));
829 }

References callWinBinder().

Referenced by createHyperLink().

◆ setDisabled()

setDisabled ( $wbobject)

Disables a WinBinder object.

Parameters
mixed$wbobjectThe WinBinder object to disable.
Returns
mixed The result of the disable operation.

Definition at line 609 of file class.winbinder.php.

610 {
611 return $this->setEnabled($wbobject, false);
612 }
setEnabled($wbobject, $enabled=true)

References setEnabled().

◆ setEnabled()

setEnabled ( $wbobject,
$enabled = true )

Sets the enabled state for a WinBinder object.

Parameters
mixed$wbobjectThe WinBinder object to set the enabled state for.
bool$enabledTrue to enable the object, false to disable it.
Returns
mixed The result of the set enabled state operation.

Definition at line 622 of file class.winbinder.php.

623 {
624 return $this->callWinBinder('wb_set_enabled', array($wbobject, $enabled));
625 }

References callWinBinder().

Referenced by setDisabled().

◆ setFocus()

setFocus ( $wbobject)

Sets the focus to a WinBinder object.

Parameters
mixed$wbobjectThe WinBinder object to set the focus to.
Returns
mixed The result of the set focus operation.

Definition at line 585 of file class.winbinder.php.

586 {
587 return $this->callWinBinder('wb_set_focus', array($wbobject));
588 }

References callWinBinder().

◆ setHandler()

setHandler ( $wbobject,
$classCallback,
$methodCallback,
$launchTimer = null )

Sets an event handler for a WinBinder object.

Parameters
mixed$wbobjectThe WinBinder object to set the handler for.
mixed$classCallbackThe class callback for the handler.
mixed$methodCallbackThe method callback for the handler.
mixed$launchTimerThe timer to launch for the handler.
Returns
mixed The result of the set handler operation.

Definition at line 524 of file class.winbinder.php.

525 {
526 if ($launchTimer != null) {
527 $launchTimer = $this->createTimer($wbobject, $launchTimer);
528 }
529
530 $this->callback[$wbobject] = array($classCallback, $methodCallback, $launchTimer);
531
532 return $this->callWinBinder('wb_set_handler', array($wbobject, '__winbinderEventHandler'));
533 }
createTimer($wbobject, $wait=1000)

References callWinBinder(), and createTimer().

◆ setImage()

setImage ( $wbobject,
$path )

Sets an image for a WinBinder object.

Parameters
mixed$wbobjectThe WinBinder object to set the image for.
string$pathThe path to the image file.
Returns
mixed The result of the set image operation.

Definition at line 167 of file class.winbinder.php.

167 : mixed
168 {
169 if ($wbobject === null) {
170 error_log('Error: $wbobject is null.');
171
172 return false;
173 }
174
175 if (!file_exists($path)) {
176 error_log('Error: Image file does not exist at path: ' . $path);
177
178 return false;
179 }
180
181 return $this->callWinBinder('wb_set_image', array($wbobject, $path));
182 }

References callWinBinder().

Referenced by createWindow().

◆ setMaxLength()

setMaxLength ( $wbobject,
$length )

Sets the maximum length for a WinBinder object.

Parameters
mixed$wbobjectThe WinBinder object to set the maximum length for.
int$lengthThe maximum length to set.
Returns
mixed The result of the set maximum length operation.

Definition at line 764 of file class.winbinder.php.

765 {
766 return $this->callWinBinder('wb_send_message', array($wbobject, 0x00c5, $length, 0));
767 }

References callWinBinder().

Referenced by createInputText().

◆ setProgressBarMax()

setProgressBarMax ( $progressBar,
$max )

Sets the maximum value of a progress bar.

Parameters
array$progressBarThe progress bar control.
int$maxThe maximum value to set.

Definition at line 991 of file class.winbinder.php.

992 {
993 $this->setRange($progressBar[self::CTRL_OBJ], 0, $max);
994 }

References setRange().

◆ setProgressBarValue()

setProgressBarValue ( $progressBar,
$value )

Sets the value of a progress bar.

Parameters
array$progressBarThe progress bar control.
mixed$valueThe value to set.

Definition at line 946 of file class.winbinder.php.

947 {
948 if ($progressBar != null && isset($progressBar[self::CTRL_OBJ]) && isset($this->gauge[$progressBar[self::CTRL_OBJ]])) {
949 if (strval($value) == self::INCR_PROGRESS_BAR) {
950 $value = $this->gauge[$progressBar[self::CTRL_OBJ]] + 1;
951 }
952 if (is_numeric($value)) {
953 $this->gauge[$progressBar[self::CTRL_OBJ]] = $value;
954
955 // Check if the control is still valid before setting the value
956 // This prevents errors when the parent window has been destroyed
957 $this->callWinBinder('wb_set_value', array($progressBar[self::CTRL_OBJ], $value), true);
958 }
959 }
960 }

References callWinBinder().

Referenced by incrProgressBar(), and resetProgressBar().

◆ setRange()

setRange ( $wbobject,
$min,
$max )

Sets the range for a WinBinder object.

Parameters
mixed$wbobjectThe WinBinder object to set the range for.
int$minThe minimum value of the range.
int$maxThe maximum value of the range.
Returns
mixed The result of the set range operation.

Definition at line 925 of file class.winbinder.php.

926 {
927 return $this->callWinBinder('wb_set_range', array($wbobject, $min, $max));
928 }

References callWinBinder().

Referenced by createProgressBar(), and setProgressBarMax().

◆ setStyle()

setStyle ( $wbobject,
$style )

Sets the style for a WinBinder object.

Parameters
mixed$wbobjectThe WinBinder object to set the style for.
mixed$styleThe style to set.
Returns
mixed The result of the set style operation.

Definition at line 635 of file class.winbinder.php.

636 {
637 return $this->callWinBinder('wb_set_style', array($wbobject, $style));
638 }

References callWinBinder().

◆ setText()

setText ( $wbobject,
$content )

Sets the text for a WinBinder object.

Parameters
mixed$wbobjectThe WinBinder object to set the text for.
string$contentThe text content to set.
Returns
mixed The result of the set text operation.

Definition at line 561 of file class.winbinder.php.

562 {
563 $content = str_replace(self::NEW_LINE, PHP_EOL, $content);
564
565 return $this->callWinBinder('wb_set_text', array($wbobject, $content));
566 }

References callWinBinder().

◆ setValue()

setValue ( $wbobject,
$content )

Sets the value for a WinBinder object.

Parameters
mixed$wbobjectThe WinBinder object to set the value for.
mixed$contentThe value to set.
Returns
mixed The result of the set value operation.

Definition at line 970 of file class.winbinder.php.

971 {
972 return $this->callWinBinder('wb_set_value', array($wbobject, $content));
973 }

References callWinBinder().

◆ sysDlgOpen()

sysDlgOpen ( $parent,
$title,
$filter = null,
$path = null )

Opens a system dialog to open a file.

Parameters
mixed$parentThe parent window for the dialog.
string$titleThe title of the dialog.
string | null$filterThe file filter for the dialog.
string | null$pathThe initial path for the dialog.
Returns
mixed The selected file path.

Definition at line 664 of file class.winbinder.php.

665 {
666 return $this->callWinBinder('wb_sys_dlg_open', array($parent, $title, $filter, $path));
667 }

References callWinBinder().

◆ sysDlgPath()

sysDlgPath ( $parent,
$title,
$path = null )

Opens a system dialog to select a path.

Parameters
mixed$parentThe parent window for the dialog.
string$titleThe title of the dialog.
string | null$pathThe initial path for the dialog.
Returns
mixed The selected path.

Definition at line 649 of file class.winbinder.php.

650 {
651 return $this->callWinBinder('wb_sys_dlg_path', array($parent, $title, $path));
652 }

References callWinBinder().

◆ wait()

wait ( $wbobject = null)

Waits for an event on a WinBinder object.

Parameters
mixed$wbobjectThe WinBinder object to wait on.
Returns
mixed The result of the wait operation.

Definition at line 481 of file class.winbinder.php.

482 {
483 return $this->callWinBinder('wb_wait', array($wbobject), true);
484 }

References callWinBinder().

◆ windowIsValid()

windowIsValid ( $window)
private

Checks if a window handle is still valid.

Parameters
mixed$windowThe window object to check.
Returns
boolean True if window is valid

Definition at line 292 of file class.winbinder.php.

292 : bool
293 {
294 if (!$window) {
295 return false;
296 }
297
298 // Try to get window text - if window is invalid, this will fail
299 $text = $this->callWinBinder('wb_get_text', array($window), true);
300 return ($text !== false);
301 }

References callWinBinder().

Referenced by destroyWindow().

◆ writeLog()

writeLog ( $log)
staticprivate

Writes a log message to the WinBinder log file.

Parameters
string$logThe log message to write.

Definition at line 342 of file class.winbinder.php.

342 : void
343 {
344 global $bearsamppRoot;
345 Util::logDebug($log, $bearsamppRoot->getWinbinderLogFilePath());
346 }
global $bearsamppRoot
static logDebug($data, $file=null)

References $bearsamppRoot, and Util\logDebug().

Referenced by destroyWindow(), exec(), and findFile().

Field Documentation

◆ $callback

$callback

Definition at line 58 of file class.winbinder.php.

◆ $countCtrls

$countCtrls
private

Definition at line 61 of file class.winbinder.php.

◆ $defaultTitle

$defaultTitle
private

Definition at line 60 of file class.winbinder.php.

◆ $gauge

$gauge

Definition at line 59 of file class.winbinder.php.

◆ BOX_ERROR

const BOX_ERROR = WBC_STOP

Definition at line 33 of file class.winbinder.php.

◆ BOX_INFO

const BOX_INFO = WBC_INFO

Definition at line 29 of file class.winbinder.php.

◆ BOX_OK

const BOX_OK = WBC_OK

Definition at line 30 of file class.winbinder.php.

◆ BOX_OKCANCEL

const BOX_OKCANCEL = WBC_OKCANCEL

Definition at line 31 of file class.winbinder.php.

◆ BOX_QUESTION

const BOX_QUESTION = WBC_QUESTION

Definition at line 32 of file class.winbinder.php.

◆ BOX_WARNING

const BOX_WARNING = WBC_WARNING

Definition at line 34 of file class.winbinder.php.

◆ BOX_YESNO

const BOX_YESNO = WBC_YESNO

Definition at line 35 of file class.winbinder.php.

◆ BOX_YESNOCANCEL

const BOX_YESNOCANCEL = WBC_YESNOCANCEL

Definition at line 36 of file class.winbinder.php.

◆ CTRL_ID

◆ CTRL_OBJ

◆ CURSOR_ARROW

const CURSOR_ARROW = 'arrow'

Definition at line 39 of file class.winbinder.php.

◆ CURSOR_CROSS

const CURSOR_CROSS = 'cross'

Definition at line 40 of file class.winbinder.php.

◆ CURSOR_FINGER

const CURSOR_FINGER = 'finger'

Definition at line 41 of file class.winbinder.php.

◆ CURSOR_FORBIDDEN

const CURSOR_FORBIDDEN = 'forbidden'

Definition at line 42 of file class.winbinder.php.

◆ CURSOR_HELP

const CURSOR_HELP = 'help'

Definition at line 43 of file class.winbinder.php.

◆ CURSOR_IBEAM

const CURSOR_IBEAM = 'ibeam'

Definition at line 44 of file class.winbinder.php.

◆ CURSOR_NONE

const CURSOR_NONE = null

Definition at line 45 of file class.winbinder.php.

◆ CURSOR_SIZEALL

const CURSOR_SIZEALL = 'sizeall'

Definition at line 46 of file class.winbinder.php.

◆ CURSOR_SIZENESW

const CURSOR_SIZENESW = 'sizenesw'

Definition at line 47 of file class.winbinder.php.

◆ CURSOR_SIZENS

const CURSOR_SIZENS = 'sizens'

Definition at line 48 of file class.winbinder.php.

◆ CURSOR_SIZENWSE

const CURSOR_SIZENWSE = 'sizenwse'

Definition at line 49 of file class.winbinder.php.

◆ CURSOR_SIZEWE

const CURSOR_SIZEWE = 'sizewe'

Definition at line 50 of file class.winbinder.php.

◆ CURSOR_UPARROW

const CURSOR_UPARROW = 'uparrow'

Definition at line 51 of file class.winbinder.php.

◆ CURSOR_WAIT

const CURSOR_WAIT = 'wait'

Definition at line 52 of file class.winbinder.php.

◆ CURSOR_WAITARROW

const CURSOR_WAITARROW = 'waitarrow'

Definition at line 53 of file class.winbinder.php.

◆ INCR_PROGRESS_BAR

const INCR_PROGRESS_BAR = '++'

Definition at line 25 of file class.winbinder.php.

◆ NEW_LINE

const NEW_LINE = '@nl@'

Definition at line 26 of file class.winbinder.php.

◆ SYSINFO_SCREENAREA

const SYSINFO_SCREENAREA = 'screenarea'

Definition at line 56 of file class.winbinder.php.

◆ SYSINFO_WORKAREA

const SYSINFO_WORKAREA = 'workarea'

Definition at line 57 of file class.winbinder.php.

Referenced by ActionLoading\__construct(), and Splash\init().


The documentation for this class was generated from the following file: