2024.8.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()

ActionChangeBrowser::__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 38 of file class.action.changeBrowser.php.

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

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 Vbs\getInstalledBrowsers().

Member Function Documentation

◆ processWindow()

ActionChangeBrowser::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 87 of file class.action.changeBrowser.php.

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

ActionChangeBrowser::$wbBtnBrowse
private

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

◆ $wbBtnCancel

ActionChangeBrowser::$wbBtnCancel
private

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

◆ $wbBtnSave

ActionChangeBrowser::$wbBtnSave
private

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

◆ $wbInputBrowse

ActionChangeBrowser::$wbInputBrowse
private

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

◆ $wbLabelExp

ActionChangeBrowser::$wbLabelExp
private

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

◆ $wbProgressBar

ActionChangeBrowser::$wbProgressBar
private

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

◆ $wbRadioButton

ActionChangeBrowser::$wbRadioButton
private

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

◆ $wbRadioButtonOther

ActionChangeBrowser::$wbRadioButtonOther
private

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

◆ $wbWindow

ActionChangeBrowser::$wbWindow
private

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

◆ GAUGE_SAVE

const ActionChangeBrowser::GAUGE_SAVE = 2

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


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