Bearsampp 2026.9.23
Loading...
Searching...
No Matches
ActionChangeBrowser Class Reference

Public Member Functions

 __construct ($args)
 processWindow ($window, $id, $ctrl, $param1, $param2)

Data Fields

const GAUGE_SAVE = 2

Private Attributes

 $wbBtnBrowse
 $wbBtnCancel
 $wbBtnSave
 $wbInputBrowse
 $wbLabelExp
 $wbProgressBar
 $wbRadioButton
 $wbRadioButtonOther
 $wbWindow

Detailed Description

Class ActionChangeBrowser

This class handles the action of changing the default browser in the Bearsampp application. It creates a window with options to select from installed browsers or browse for a different browser executable. The selected browser is then saved in the configuration.

Definition at line 17 of file class.action.changeBrowser.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( $args)

Constructor for ActionChangeBrowser.

Initializes the window and its components, sets up event handlers, and starts the main loop.

Parameters
array$argsArguments passed to the constructor.

Definition at line 48 of file class.action.changeBrowser.php.

49 {
50 global $bearsamppConfig, $bearsamppLang, $bearsamppWinbinder;
51
52 $bearsamppWinbinder->reset();
53 $this->wbWindow = $bearsamppWinbinder->createAppWindow($bearsamppLang->getValue(Lang::CHANGE_BROWSER_TITLE), 490, 350, WBC_NOTIFY, WBC_KEYDOWN | WBC_KEYUP);
54
55 $this->wbLabelExp = $bearsamppWinbinder->createLabel($this->wbWindow, $bearsamppLang->getValue(Lang::CHANGE_BROWSER_EXP_LABEL), 15, 15, 470, 50);
56
57 $currentBrowser = $bearsamppConfig->getBrowser();
58 $this->wbRadioButton[] = $bearsamppWinbinder->createRadioButton($this->wbWindow, $currentBrowser, true, 15, 40, 470, 20, true);
59
60 $yPos = 70;
61 $installedBrowsers = Win32Native::getInstalledBrowsers();
62 foreach ($installedBrowsers as $installedBrowser) {
63 if ($installedBrowser != $currentBrowser) {
64 $this->wbRadioButton[] = $bearsamppWinbinder->createRadioButton($this->wbWindow, $installedBrowser, false, 15, $yPos, 470, 20);
65 $yPos += 30;
66 }
67 }
68
69 $this->wbRadioButtonOther = $bearsamppWinbinder->createRadioButton($this->wbWindow, $bearsamppLang->getValue(Lang::CHANGE_BROWSER_OTHER_LABEL), false, 15, $yPos, 470, 15);
70
71 $this->wbInputBrowse = $bearsamppWinbinder->createInputText($this->wbWindow, null, 30, $yPos + 30, 190, null, 20, WBC_READONLY);
72 $this->wbBtnBrowse = $bearsamppWinbinder->createButton($this->wbWindow, $bearsamppLang->getValue(Lang::BUTTON_BROWSE), 225, $yPos + 25, 110);
73 $bearsamppWinbinder->setEnabled($this->wbBtnBrowse[WinBinder::CTRL_OBJ], false);
74
75 $this->wbProgressBar = $bearsamppWinbinder->createProgressBar($this->wbWindow, self::GAUGE_SAVE, 15, 287, 275);
76 $this->wbBtnSave = $bearsamppWinbinder->createButton($this->wbWindow, $bearsamppLang->getValue(Lang::BUTTON_SAVE), 300, 282);
77 $this->wbBtnCancel = $bearsamppWinbinder->createButton($this->wbWindow, $bearsamppLang->getValue(Lang::BUTTON_CANCEL), 387, 282);
78 $bearsamppWinbinder->setEnabled($this->wbBtnSave[WinBinder::CTRL_OBJ], empty($currentBrowser) ? false : true);
79
80 $bearsamppWinbinder->setHandler($this->wbWindow, $this, 'processWindow');
81 $bearsamppWinbinder->mainLoop();
82 $bearsamppWinbinder->reset();
83 }
global $bearsamppLang
const CHANGE_BROWSER_OTHER_LABEL
const BUTTON_BROWSE
const BUTTON_CANCEL
const CHANGE_BROWSER_TITLE
const BUTTON_SAVE
const CHANGE_BROWSER_EXP_LABEL
static getInstalledBrowsers()
global $bearsamppConfig
Definition homepage.php:46

References $bearsamppConfig, $bearsamppLang, Lang\BUTTON_BROWSE, Lang\BUTTON_CANCEL, Lang\BUTTON_SAVE, Lang\CHANGE_BROWSER_EXP_LABEL, Lang\CHANGE_BROWSER_OTHER_LABEL, Lang\CHANGE_BROWSER_TITLE, WinBinder\CTRL_OBJ, and Win32Native\getInstalledBrowsers().

Here is the call graph for this function:

Member Function Documentation

◆ processWindow()

processWindow ( $window,
$id,
$ctrl,
$param1,
$param2 )

Processes window events.

Handles the logic for various controls in the window, such as enabling/disabling buttons, opening file dialogs, and saving the selected browser.

Parameters
resource$windowThe window resource.
int$idThe ID of the control that triggered the event.
resource$ctrlThe control resource.
mixed$param1Additional parameter 1.
mixed$param2Additional parameter 2.

Definition at line 97 of file class.action.changeBrowser.php.

98 {
99 global $bearsamppConfig, $bearsamppLang, $bearsamppWinbinder;
100
101 // Get other value
102 $browserPath = $bearsamppWinbinder->getText($this->wbInputBrowse[WinBinder::CTRL_OBJ]);
103
104 // Get value
105 $selected = null;
106 if ($bearsamppWinbinder->getValue($this->wbRadioButtonOther[WinBinder::CTRL_OBJ]) == 1) {
107 $bearsamppWinbinder->setEnabled($this->wbBtnBrowse[WinBinder::CTRL_OBJ], true);
108 $selected = $bearsamppWinbinder->getText($this->wbInputBrowse[WinBinder::CTRL_OBJ]);
109 } else {
110 $bearsamppWinbinder->setEnabled($this->wbBtnBrowse[WinBinder::CTRL_OBJ], false);
111 }
112 foreach ($this->wbRadioButton as $radioButton) {
113 if ($bearsamppWinbinder->getValue($radioButton[WinBinder::CTRL_OBJ]) == 1) {
114 $selected = $bearsamppWinbinder->getText($radioButton[WinBinder::CTRL_OBJ]);
115 break;
116 }
117 }
118
119 // Enable/disable save button
120 $bearsamppWinbinder->setEnabled($this->wbBtnSave[WinBinder::CTRL_OBJ], empty($selected) ? false : true);
121
122 switch ($id) {
123 case $this->wbBtnBrowse[WinBinder::CTRL_ID]:
124 $browserPath = trim(
125 $bearsamppWinbinder->sysDlgOpen(
126 $window,
128 array(array($bearsamppLang->getValue(Lang::EXECUTABLE), '*.exe')),
129 $browserPath
130 )
131 );
132 if ($browserPath && is_file($browserPath)) {
133 $bearsamppWinbinder->setText($this->wbInputBrowse[WinBinder::CTRL_OBJ], $browserPath);
134 }
135 break;
136 case $this->wbBtnSave[WinBinder::CTRL_ID]:
137 $bearsamppWinbinder->incrProgressBar($this->wbProgressBar);
138
139 $bearsamppWinbinder->incrProgressBar($this->wbProgressBar);
140 $bearsamppConfig->replace(Config::CFG_BROWSER, $selected);
141
142 $bearsamppWinbinder->messageBoxInfo(
143 sprintf($bearsamppLang->getValue(Lang::CHANGE_BROWSER_OK), $selected),
145 );
146 $bearsamppWinbinder->destroyWindow($window);
147
148 break;
149 case IDCLOSE:
150 case $this->wbBtnCancel[WinBinder::CTRL_ID]:
151 $bearsamppWinbinder->destroyWindow($window);
152 break;
153 }
154 }
const CFG_BROWSER
const CHANGE_BROWSER_OK
const ALIAS_DEST_PATH
const EXECUTABLE

References $bearsamppConfig, $bearsamppLang, Lang\ALIAS_DEST_PATH, Config\CFG_BROWSER, Lang\CHANGE_BROWSER_OK, Lang\CHANGE_BROWSER_TITLE, WinBinder\CTRL_ID, WinBinder\CTRL_OBJ, and Lang\EXECUTABLE.

Field Documentation

◆ $wbBtnBrowse

$wbBtnBrowse
private

Definition at line 30 of file class.action.changeBrowser.php.

◆ $wbBtnCancel

$wbBtnCancel
private

Definition at line 36 of file class.action.changeBrowser.php.

◆ $wbBtnSave

$wbBtnSave
private

Definition at line 34 of file class.action.changeBrowser.php.

◆ $wbInputBrowse

$wbInputBrowse
private

Definition at line 28 of file class.action.changeBrowser.php.

◆ $wbLabelExp

$wbLabelExp
private

Definition at line 22 of file class.action.changeBrowser.php.

◆ $wbProgressBar

$wbProgressBar
private

Definition at line 32 of file class.action.changeBrowser.php.

◆ $wbRadioButton

$wbRadioButton
private

Definition at line 24 of file class.action.changeBrowser.php.

◆ $wbRadioButtonOther

$wbRadioButtonOther
private

Definition at line 26 of file class.action.changeBrowser.php.

◆ $wbWindow

$wbWindow
private

Definition at line 20 of file class.action.changeBrowser.php.

◆ GAUGE_SAVE

const GAUGE_SAVE = 2

Definition at line 39 of file class.action.changeBrowser.php.


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