Bearsampp 2025.8.29
Loading...
Searching...
No Matches
wb_resources.inc.php File Reference

Go to the source code of this file.

Functions

 _bit_test ($v, $t)
 _scale_controls ($c)
 _scale_dialog ($c)
 _trim_quotes ($str)
if(!defined("WB_KX_SCREEN")) if(!defined("WB_KY_SCREEN")) if(!defined("WS_VISIBLE")) if(!defined("WS_DISABLED")) if(!defined("WS_GROUP")) if(!defined("WS_EX_STATICEDGE")) if(!defined('BM_SETCHECK')) if(!defined( 'LVM_FIRST')) if(!defined('LVM_DELETEALLITEMS')) if(!defined( 'LVM_GETITEMCOUNT')) if(!defined('LVM_GETITEMSTATE')) if(!defined( 'LVM_GETSELECTEDCOUNT')) if(!defined('LVIS_SELECTED')) if(!defined( 'TCM_GETCURSEL')) if(!defined('CB_FINDSTRINGEXACT')) if(!defined( 'CB_SETCURSEL')) if(!defined('LB_FINDSTRINGEXACT')) if(!defined( 'LB_SETCURSEL')) if(!defined('TCM_SETCURSEL')) if(!defined( 'WM_SETTEXT')) if(!defined("BS_PUSHBUTTON")) if(!defined("BS_CHECKBOX")) if(!defined("BS_AUTOCHECKBOX")) if(!defined("BS_RADIOBUTTON")) if(!defined("BS_GROUPBOX")) if(!defined("BS_AUTORADIOBUTTON")) if(!defined("BS_ICON")) if(!defined("BS_BITMAP")) if(!defined("ES_NUMBER")) if(!defined("ES_PASSWORD")) if(!defined("ES_READONLY")) if(!defined("ES_UPPERCASE")) if(!defined("ES_LEFT")) if(!defined("ES_CENTER")) if(!defined("ES_RIGHT")) if(!defined("ES_MULTILINE")) if(!defined("SS_LEFT")) if(!defined("SS_CENTER")) if(!defined("SS_RIGHT")) if(!defined("SS_ETCHEDHORZ")) if(!defined("SS_ETCHEDVERT")) if(!defined("SS_ETCHEDFRAME")) if(!defined("SS_ICON")) if(!defined("SS_BITMAP")) if(!defined("SS_LEFTNOWORDWRAP")) if(!defined("SS_WORDELLIPSIS")) if(!defined("CBS_SORT")) if(!defined("CBS_DROPDOWNLIST")) if(!defined("LBS_SORT")) if(!defined("LVS_NOSORTHEADER")) if(!defined("LVS_GRIDLINES")) if(!defined("LVS_CHECKBOXES")) if(!defined("LVS_SINGLESEL")) if(!defined("TBS_AUTOTICKS")) parse_rc ( $rc, $winvar=' $mainwin', $parent=0, $type="AppWindow", $caption="", $x=WBC_CENTER, $y=WBC_CENTER, $width=WBC_CENTER, $height=WBC_CENTER, $style=0, $lparam=0, $respath=PATH_RES)

Function Documentation

◆ _bit_test()

_bit_test ( $v,
$t )

Definition at line 637 of file wb_resources.inc.php.

638{
639 return (($v & $t) == $t);
640}

Referenced by _scale_controls().

◆ _scale_controls()

_scale_controls ( $c)

Definition at line 373 of file wb_resources.inc.php.

374{
375 global $_tabN, $path_res;
376
377 $winclass = $c[3];
378 $winstyle = hexdec($c[4]);
379 $winexstyle = hexdec($c[9]);
380
381 if (_bit_test($winstyle, WS_VISIBLE)) {
382 $style = "WBC_VISIBLE";
383 } else {
384 $style = "WBC_INVISIBLE";
385 }
386
387 if (_bit_test($winstyle, WS_DISABLED)) {
388 $style .= " | WBC_DISABLED";
389 } else {
390 $style .= " | WBC_ENABLED";
391 }
392
393 if (_bit_test($winexstyle, WS_EX_STATICEDGE)) {
394 $style .= " | WBC_BORDER";
395 }
396
397 // Set attributes according to control class
398
399 switch (strtolower($winclass)) {
400 case '"button"':
401
402 switch ($winstyle & 0x0F) {
403 case BS_AUTORADIOBUTTON:
404 case BS_RADIOBUTTON:
405 $class = "RadioButton";
406 if (_bit_test($winstyle, WS_GROUP)) {
407 $style .= " | WBC_GROUP";
408 }
409 break;
410 case BS_AUTOCHECKBOX:
411 case BS_CHECKBOX:
412 $class = "CheckBox";
413 break;
414 case BS_GROUPBOX:
415 $class = "Frame";
416 break;
417 case BS_PUSHBUTTON:
418 default:
419 $class = "PushButton";
420 break;
421 }
422 break;
423
424 case '"static"':
425
426 switch ($winstyle & 0x1F) {
427 case SS_ICON:
428 case SS_BITMAP:
429 $style .= " | WBC_IMAGE | WBC_CENTER";
430 $class = "Frame";
431 break;
432 case SS_ETCHEDHORZ:
433 case SS_ETCHEDVERT:
434 case SS_ETCHEDFRAME:
435 $class = "Frame";
436 break;
437 case SS_CENTER:
438 if (_bit_test($winstyle, SS_WORDELLIPSIS)) {
439 $style .= " | WBC_ELLIPSIS";
440 }
441 $style .= " | WBC_CENTER";
442 $class = "Label";
443 break;
444 case SS_RIGHT:
445 if (_bit_test($winstyle, SS_WORDELLIPSIS)) {
446 $style .= " | WBC_ELLIPSIS";
447 }
448 $style .= " | WBC_RIGHT";
449 $class = "Label";
450 break;
451 case SS_LEFT:
452 default:
453 if (!_bit_test($winstyle, SS_LEFTNOWORDWRAP)) {
454 $style .= " | WBC_MULTILINE";
455 }
456 if (_bit_test($winstyle, SS_WORDELLIPSIS)) {
457 $style .= " | WBC_ELLIPSIS";
458 }
459 $class = "Label";
460 break;
461 }
462 break;
463
464 case '"edit"':
465 $class = "EditBox";
466 if (_bit_test($winstyle, ES_MULTILINE)) {
467 $style .= " | WBC_MULTILINE";
468 } else {
469 switch ($winstyle & 0x03) {
470 case ES_CENTER:
471 $style .= " | WBC_CENTER";
472 break;
473 case ES_RIGHT:
474 $style .= " | WBC_RIGHT";
475 break;
476 case ES_LEFT:
477 default:
478 break;
479 }
480 }
481 if (_bit_test($winstyle, ES_READONLY)) {
482 $style .= " | WBC_READONLY";
483 }
484 if (_bit_test($winstyle, ES_PASSWORD)) {
485 $style .= " | WBC_MASKED";
486 }
487 if (_bit_test($winstyle, ES_NUMBER)) {
488 $style .= " | WBC_NUMBER";
489 }
490 break;
491
492 case '"richedit20a"':
493 if (_bit_test($winstyle, ES_READONLY)) {
494 $style .= " | WBC_READONLY";
495 }
496 $class = "RTFEditBox";
497 switch ($winstyle & 0x03) {
498 case ES_CENTER:
499 $style .= " | WBC_CENTER";
500 break;
501 case ES_RIGHT:
502 $style .= " | WBC_RIGHT";
503 break;
504 case ES_LEFT:
505 default:
506 break;
507 }
508 break;
509
510 case '"combobox"':
511 $class = "ComboBox";
512 if (_bit_test($winstyle, CBS_SORT)) {
513 $style .= " | WBC_SORT";
514 }
515 if (_bit_test($winstyle, CBS_DROPDOWNLIST)) {
516 $style .= " | WBC_READONLY";
517 }
518 break;
519
520 case '"listbox"':
521 $class = "ListBox";
522 if (_bit_test($winstyle, LBS_SORT)) {
523 $style .= " | WBC_SORT";
524 }
525 break;
526
527 case '"scrollbar"':
528 $class = "ScrollBar";
529 break;
530
531 case '"syslistview32"':
532 $class = "ListView";
533 if (!_bit_test($winstyle, LVS_NOSORTHEADER)) {
534 $style .= " | WBC_SORT";
535 }
536 if (_bit_test($winstyle, LVS_GRIDLINES)) {
537 $style .= " | WBC_LINES";
538 }
539 if (_bit_test($winstyle, LVS_CHECKBOXES)) {
540 $style .= " | WBC_CHECKBOXES";
541 }
542 if (!_bit_test($winstyle, LVS_SINGLESEL)) {
543 $style .= " | WBC_SINGLE";
544 }
545 break;
546
547 case '"systabcontrol32"':
548 $class = "TabControl";
549 break;
550
551 case '"systreeview32"':
552 $class = "TreeView";
553 break;
554
555 case '"toolbarwindow32"':
556 $class = "ToolBar";
557 break;
558
559 case '"msctls_progress32"':
560 $class = "Gauge";
561 break;
562
563 case '"msctls_statusbar32"':
564 $class = "StatusBar";
565 break;
566
567 case '"sysmonthcal32"':
568 $class = "Calendar";
569 break;
570
571 case '"msctls_trackbar32"':
572 $class = "Slider";
573 if (_bit_test($winstyle, TBS_AUTOTICKS)) {
574 $style .= " | WBC_LINES";
575 }
576 break;
577
578 case '"msctls_updown32"':
579 $class = "Spinner";
580 if (_bit_test($winstyle, WS_GROUP)) {
581 $style .= " | WBC_GROUP";
582 }
583 break;
584 }
585
586 // Convert Windows style to WinBinder style
587
588 $str = "wb_create_control(" .
589 "%WINVAR%, " . // Parent
590 $class . ", " . // Class
591 $c[1] . ", " . // Caption
592 (int)($c[5] * WB_KX_SCREEN) . ", " . // Left
593 (int)($c[6] * WB_KY_SCREEN) . ", " . // Top
594 (int)($c[7] * WB_KX_SCREEN) . ", " . // Width
595 (int)($c[8] * WB_KY_SCREEN) . ", " . // Height
596 $c[2] . ", " . // ID
597 $style . ", " . // Style
598 "0" . // Param
599 ($_tabN ? ", " . ($_tabN - 1) . ");\n" : ");\n"); // Tab #
600
601 // Add some attributes to controls where needed
602
603 switch ($class) {
604 case "Frame":
605
606 if (strstr($style, "WBC_IMAGE")) {
607 if (($winstyle & (SS_BITMAP | SS_ICON)) && ($c[1] !== '""')) {
608 $image = $path_res . _trim_quotes($c[1]);
609 if (preg_match("/\.(bmp|ico)$/", $image)) {
610 $str = "\$_tmp_ctrl_ = " . $str . "wb_set_image(\$_tmp_ctrl_, '$image', GREEN);" . " unset(\$_tmp_ctrl_);\n";
611 }
612 }
613 }
614 break;
615
616 case "PushButton":
617
618 if (($winstyle & (BS_BITMAP | BS_ICON)) && ($c[1] !== '""')) {
619 $image = $path_res . _trim_quotes($c[1]);
620 if ($image) {
621 if (preg_match("/\.(bmp|ico)$/", $image)) {
622 $str = "\$_tmp_ctrl_ = " . $str . "wb_set_image(\$_tmp_ctrl_, '$image', GREEN);" . " unset(\$_tmp_ctrl_);\n";
623 }
624 }
625 }
626 break;
627 }
628
629 return $str;
630}
_trim_quotes($str)
_bit_test($v, $t)

References _bit_test(), and _trim_quotes().

◆ _scale_dialog()

_scale_dialog ( $c)

Definition at line 290 of file wb_resources.inc.php.

291{
292 global $_winclass, $_usergeom, $_tabN;
293
294 if ($_winclass == "TabControl") {
295 $_tabN++;
296 $code = "wb_create_item(%PARENT%, " . $c[6] . ");\n";
297 } else {
298 $_addx = 8; //width + 2xborder
299 $_addy = 4 + 42 + 17 + 4; //border + caption + border
300
301 switch (is_string($_winclass) ? strtolower($_winclass) : $_winclass) {
302 case "appwindow":
303 $_winclass = AppWindow;
304 $_addx = 8; //width + 2xborder
305 $_addy = 3 + 18 + 22 + 18 + 3; //border + caption + menu + statusbar + border
306 break;
307 case "resizablewindow":
308 $_winclass = ResizableWindow;
309 $_addx = 8; //width + 2xborder
310 $_addy = 4 + 42 + 17 + 4; //border + caption + menu + statusbar + border
311 break;
312 case "modaldialog":
313 $_winclass = ModalDialog;
314 $_addx = 8; //width + 2xborder
315 $_addy = 4 + 42 + 17 + 4; //border + caption + border
316 break;
317 case "modelessdialog":
318 $_winclass = ModelessDialog;
319 break;
320 case "tooldialog":
321 $_winclass = ToolDialog;
322 break;
323 }
324
325 if (!(($_usergeom[0] == WBC_CENTER && $_usergeom[1] == WBC_CENTER &&
326 $_usergeom[2] == WBC_CENTER && $_usergeom[3] == WBC_CENTER))) {
327 $code = "%WINVAR% = wb_create_window(" .
328 "%PARENT%, " . // parent
329 "$_winclass, " . // class
330 $c[6] . ", " . // caption
331 $_usergeom[0] . ", " . // left
332 $_usergeom[1] . ", " . // top
333 $_usergeom[2] . ", " . // width
334 $_usergeom[3] . ", " . // height
335 "%STYLE%, " . // style
336 "%LPARAM%);\n"; // lparam
337
338 } else {
339 if (is_array($_usergeom)) {
340 if (count($_usergeom) == 2) { // Width, height only
341 $_usergeom[2] = $_usergeom[0];
342 $_usergeom[3] = $_usergeom[1];
343 $_usergeom[0] = WBC_CENTER;
344 $_usergeom[1] = WBC_CENTER;
345 }
346 } elseif (is_null($_usergeom)) {
347 $_usergeom[0] = WBC_DEFAULTPOS;
348 $_usergeom[1] = WBC_DEFAULTPOS;
349 $_usergeom[2] = WBC_DEFAULTPOS;
350 $_usergeom[3] = WBC_DEFAULTPOS;
351 }
352
353 $code = "%WINVAR% = wb_create_window(" .
354 "%PARENT%, " . // parent
355 "$_winclass, " . // class
356 $c[6] . ", " . // caption
357 "WBC_CENTER, " . // left
358 "WBC_CENTER, " . // top
359// (int)($c[4] * WB_KX_SCREEN + $_addx) . ", " .
360// (int)($c[5] * WB_KY_SCREEN + $_addy) . ", " .
361 (int)($c[4] * WB_KX_SCREEN) . ", " .
362 (int)($c[5] * WB_KY_SCREEN) . ", " .
363 "%STYLE%, " . // style
364 "%LPARAM%);\n"; // lparam
365 }
366
367 $_tabN = 0;
368 }
369
370 return $code;
371}

◆ _trim_quotes()

_trim_quotes ( $str)

Definition at line 632 of file wb_resources.inc.php.

633{
634 return str_replace('"', '', $str);
635}

Referenced by _scale_controls().

◆ parse_rc()

if(!defined("WB_KX_SCREEN")) if(!defined("WB_KY_SCREEN")) if(!defined("WS_VISIBLE")) if(!defined("WS_DISABLED")) if(!defined("WS_GROUP")) if(!defined("WS_EX_STATICEDGE")) if(!defined( 'BM_SETCHECK')) if(!defined('LVM_FIRST')) if(!defined( 'LVM_DELETEALLITEMS')) if(!defined('LVM_GETITEMCOUNT')) if(!defined( 'LVM_GETITEMSTATE')) if(!defined('LVM_GETSELECTEDCOUNT')) if(!defined( 'LVIS_SELECTED')) if(!defined('TCM_GETCURSEL')) if(!defined( 'CB_FINDSTRINGEXACT')) if(!defined('CB_SETCURSEL')) if(!defined( 'LB_FINDSTRINGEXACT')) if(!defined('LB_SETCURSEL')) if(!defined( 'TCM_SETCURSEL')) if(!defined('WM_SETTEXT')) if(!defined("BS_PUSHBUTTON")) if(!defined("BS_CHECKBOX")) if(!defined("BS_AUTOCHECKBOX")) if(!defined("BS_RADIOBUTTON")) if(!defined("BS_GROUPBOX")) if(!defined("BS_AUTORADIOBUTTON")) if(!defined("BS_ICON")) if(!defined("BS_BITMAP")) if(!defined("ES_NUMBER")) if(!defined("ES_PASSWORD")) if(!defined("ES_READONLY")) if(!defined("ES_UPPERCASE")) if(!defined("ES_LEFT")) if(!defined("ES_CENTER")) if(!defined("ES_RIGHT")) if(!defined("ES_MULTILINE")) if(!defined("SS_LEFT")) if(!defined("SS_CENTER")) if(!defined("SS_RIGHT")) if(!defined("SS_ETCHEDHORZ")) if(!defined("SS_ETCHEDVERT")) if(!defined("SS_ETCHEDFRAME")) if(!defined("SS_ICON")) if(!defined("SS_BITMAP")) if(!defined("SS_LEFTNOWORDWRAP")) if(!defined("SS_WORDELLIPSIS")) if(!defined("CBS_SORT")) if(!defined("CBS_DROPDOWNLIST")) if(!defined("LBS_SORT")) if(!defined("LVS_NOSORTHEADER")) if(!defined("LVS_GRIDLINES")) if(!defined("LVS_CHECKBOXES")) if(!defined("LVS_SINGLESEL")) if(!defined("TBS_AUTOTICKS")) parse_rc ( $rc,
$winvar = '$mainwin',
$parent = 0,
$type = "AppWindow",
$caption = "",
$x = WBC_CENTER,
$y = WBC_CENTER,
$width = WBC_CENTER,
$height = WBC_CENTER,
$style = 0,
$lparam = 0,
$respath = PATH_RES )

Definition at line 210 of file wb_resources.inc.php.

223 {
224 global $_winclass, $_usergeom, $path_res;
225
226 // Read file
227
228 $_usergeom = array($x, $y, $width, $height);
229 $path_res = $respath;
230
231 // Remove comments and useless spaces
232
233 $rc = preg_replace("/^\s*;.*$/m", "", $rc);
234 $rc = preg_replace("/^\s*(.*)$/m", "\\1", $rc);
235
236 // Maintain #defines and discard the rest (fixed to work with newer versions of PHP -- thanks Hans)
237
238// $def = preg_replace("/(?!^\s*#define)(.*)$/m", "\\2", $rc);
239 $def = preg_replace('/^((?!#define).)*$/m', "\\2", $rc);
240
241 // Remove blank lines
242
243 $def = preg_replace("/\n+/m", "\n", $def);
244
245 // Change string C #defines to PHP format
246
247 $def = preg_replace("/#define\s+(\w+)\s+\"(.*)\"/", "if(!defined(\"\\1\")) define(\"\\1\", \"\\2\");", $def);
248
249 // Change character C #defines to PHP format
250
251 $def = preg_replace("/#define\s+(\w+)\s+'(.+)'/", "if(!defined(\"\\1\")) define(\"\\1\", \"\\2\");", $def);
252
253 // Change numeric C #defines to PHP format
254
255 $def = preg_replace("/#define\s+(\w+)\s+(\S+)/", "if(!defined(\"\\1\")) define(\"\\1\", \\2);", $def);
256 $def = "// Control identifiers\n\n" . preg_replace("/(\r\n|\r|\n)+/sm", "\n", $def);
257
258 // Return to original string and eliminates the #defines
259
260 $rc = preg_replace("/^\s*#define(.*)$/m", "", $rc);
261
262 // Create the window
263
264 $_winclass = $type;
265
266 $tok = "\s*((?:[\"'][\S \t]*[\"'])|(?:[\S^,'\"]+))\s*"; // Normal or quoted token
267 $rc = "// Create window\n\n" . preg_replace_callback("/^$tok\s+DIALOGEX$tok,$tok,$tok,$tok\s+CAPTION$tok\s+FONT$tok,$tok\s+STYLE$tok\s+EXSTYLE$tok/m", "_scale_dialog", $rc);
268
269 // Create the controls
270
271 $rc = preg_replace_callback("/^\s*CONTROL\s+$tok,$tok,$tok,$tok,$tok,$tok,$tok,$tok,$tok/m", "_scale_controls", $rc);
272
273 // Create BEGIN / END comments
274
275 $rc = preg_replace("/^\s*BEGIN/m", "\n// Insert controls\n", $rc);
276 $rc = preg_replace("/^\s*END/m", "\n// End controls", $rc);
277
278 // Replace variable names
279
280 $rc = str_replace("%WINVAR%", $winvar, $rc);
281 $rc = str_replace("%PARENT%", $parent ? $parent : "0", $rc);
282 $rc = str_replace("%STYLE%", $style, $rc);
283 $rc = str_replace("%LPARAM%", $lparam, $rc);
284
285 return "$def\n$rc";
286}