Beispiel #1
1
function process_main($window, $id, $ctrl, $lparam1 = 0, $lparam2 = 0)
{
    global $wb, $statusbar;
    switch ($id) {
        case IDC_TREEVIEW:
            $selnode = wb_get_selected($wb->tree_view);
            if ($wb->left_control) {
                wb_set_visible($wb->left_control, false);
            }
            switch (wb_get_value($wb->tree_view)) {
                case 2002:
                    include_once PATH_FORM . 'Contact.form.php';
                    $wb->current_ctl = new ContactForm();
                    $wb->left_control = $wb->current_ctl->renderForm();
                    break;
                case 2003:
                    $wb->left_control = wb_create_control($wb->mainwin, CheckBox, "Checkbox 1", 170, 105, 91, 14, 0);
                    break;
                case 2004:
                    $wb->left_control = wb_create_control($wb->mainwin, RTFEditBox, "Rich text", 170, 120, 205, 55, 0);
                    break;
            }
            wb_set_text($wb->statusbar, "Selected item: " . wb_get_text($wb->tree_view, $selnode) . " / Value: " . wb_get_value($wb->tree_view) . " / Parent: " . wb_get_parent($wb->tree_view, $selnode) . " / Level: " . wb_get_level($wb->tree_view, $selnode) . " / State: " . (wb_get_state($wb->tree_view, $selnode) ? "expanded" : "collapsed"));
            break;
        case IDCLOSE:
            // IDCLOSE is predefined
            if (wb_message_box($wb->mainwin, $wb->vars["Lang"]["lang_sure_logout"], $wb->vars["Lang"]["system_name"], WBC_QUESTION | WBC_YESNO)) {
                wb_destroy_window($window);
            }
            break;
        case IDC_CATEGORY_LIST_VIEW:
            $sel = wb_get_selected($ctrl);
            $sel = $sel ? implode(", ", $sel) : "none";
            wb_message_box($wb->mainwin, $sel);
            break;
        default:
            include_once PATH_FORM . 'contact.handle.php';
            process_ContactForm($window, $id, $ctrl, $lparam1, $lparam2);
            break;
    }
}
    define('IDC_SLIDER1002', 1002);
}
if (!defined('IDC_SCROLLBAR1003')) {
    define('IDC_SCROLLBAR1003', 1003);
}
if (!defined('IDC_GAUGE1004')) {
    define('IDC_GAUGE1004', 1004);
}
// Create window
$winmain = wb_create_window(null, ModalDialog, '(Empty Form)', WBC_CENTER, WBC_CENTER, 389, 315, 0x0, 0);
// Insert controls
$tab = $control = wb_create_control($winmain, TabControl, 'Tab1,Tab2,Tab3', 5, 20, 155, 240, IDC_TABCONTROL1001, 0x0, 0, 0);
$control = wb_create_control($tab, EditBox, 'EditBox2', 20, 13, 90, 20, IDC_EDITBOX1002, 0x0, 0, 0);
$control = wb_create_control($tab, EditBox, 'EditBox3', 20, 38, 90, 20, IDC_EDITBOX1003, 0x0, 0, 0);
$control = wb_create_control($tab, Label, 'Label4', 20, 73, 90, 15, IDC_LABEL1001, 0x0, 0, 0);
$control = wb_create_control($tab, Label, 'Label5', 20, 93, 90, 15, IDC_LABEL1001, 0x0, 0, 0);
$control = wb_create_control($tab, RadioButton, 'RadioButton6', 20, 123, 120, 15, IDC_RADIOBUTTON1001, 0x0, 0, 0);
$control = wb_create_control($winmain, CheckBox, 'CheckBox7', 185, 20, 120, 15, IDC_CHECKBOX1001, 0x0, 0, 0);
$ctrl = $control = wb_create_control($winmain, ComboBox, 'ComboBox8', 185, 40, 120, 60, IDC_COMBOBOX1003, 0x40, 0, 0);
wb_set_text($ctrl, explode(',', 'ComboBox8'));
$control = wb_create_control($winmain, EditBox, 'EditBox9', 185, 70, 90, 20, IDC_EDITBOX1004, 0x0, 0, 0);
$control = wb_create_control($winmain, ListView, 'ListView10,List12', 185, 100, 185, 75, IDC_LISTVIEW1001, 0x0, 0, 0);
$control = wb_create_control($winmain, ImageButton, 'resources\\ctrl_listbox3.bmp', 185, 190, 24, 24, IDC_IMAGEBUTTON1001, 0x0, 3, 0);
$control = wb_create_control($tab, EditBox, 'EditBox12', 25, 163, 90, 20, IDC_EDITBOX1001, 0x0, 0, 0);
$ctrl = $control = wb_create_control($winmain, Slider, 'Slider13', 260, 185, 100, 20, IDC_SLIDER1002, 0x0, 50, 0);
wb_set_value($ctrl, 50);
$ctrl = $control = wb_create_control($winmain, ScrollBar, 'ScrollBar14', 225, 185, 18, 82, IDC_SCROLLBAR1003, 0x0, 50, 0);
wb_set_value($ctrl, 50);
$ctrl = $control = wb_create_control($winmain, Gauge, 'Gauge15', 260, 215, 100, 20, IDC_GAUGE1004, 0x0, 50, 0);
wb_set_value($ctrl, 50);
// End controls
function create_project_dlg($parent)
{
    global $wb;
    include "fe_project.form.php";
    // 	Read various settings
    foreach ($wb->project_array as $var) {
        $var = strtolower($var);
        $ctrl = wb_get_control($wb->winproject, constant("IDC_" . strtoupper($var)));
        if (preg_match("/[\\d\\.\\,]+/", $wb->form[$wb->currentform]->{$var})) {
            wb_set_value($ctrl, $wb->form[$wb->currentform]->{$var});
        } else {
            if (wb_get_class($ctrl) != RadioButton && wb_get_class($ctrl) != CheckBox) {
                wb_set_text($ctrl, $wb->form[$wb->currentform]->{$var});
            }
        }
    }
    // Disable / enable controls according to context
    wb_set_enabled(wb_get_control($wb->winproject, IDC_LOCPREFIX), wb_get_value(wb_get_control($wb->winproject, IDC_LOCALIZE)));
    $val = wb_get_value(wb_get_control($wb->winproject, IDC_ISTABPAGE));
    wb_set_enabled(wb_get_control($wb->winproject, IDC_TABNUMBER), $val);
    wb_set_enabled(wb_get_control($wb->winproject, IDC_TABNUMBERSPINNER), $val);
    $hastext = wb_get_text(wb_get_control($wb->winproject, IDC_CTRLVAR)) !== '';
    wb_set_enabled(wb_get_control($wb->winproject, IDC_STARTCTRLVAL), $hastext);
    wb_set_handler($wb->winproject, "process_project");
    wb_set_visible($wb->winproject, true);
    set_default_accel($wb->winproject, false);
}
function process_options($window, $id, $ctrl)
{
    global $wb;
    switch ($id) {
        case IDC_WIREFRAME:
        case IDC_GRID:
            wb_set_value(wb_get_control($wb->mainwin, $id), wb_get_value($ctrl));
            break;
        case IDC_BROWSE:
            $current = wb_get_text(wb_get_control($window, IDC_FILEPATH));
            $path = wb_sys_dlg_path($window, 'Select default path for project files:', $current);
            if ($path) {
                wb_set_text(wb_get_control($window, IDC_FILEPATH), $path);
            }
            break;
        case IDOK:
            // 	Set various settings
            foreach ($wb->options_array as $var) {
                $var = strtolower($var);
                $ctrl = wb_get_control($wb->winoptions, constant("IDC_" . strtoupper($var)));
                if (wb_get_class($ctrl) == CheckBox) {
                    $wb->{$var} = wb_get_value($ctrl);
                } else {
                    $wb->{$var} = wb_get_text($ctrl);
                }
            }
            // Fall-through
        // Fall-through
        case IDCANCEL:
            set_default_accel();
            wb_destroy_window($window);
            break;
    }
}
function dummy_callback($window, $id)
{
    switch ($id) {
        case ID_RESETHANDLER:
            wb_set_text(wb_get_control($window, IDC_EDIT6002), "Resetting window handler...");
            wb_set_handler($window, "process_main");
            break;
    }
}
function update_item_controls($window)
{
    global $id_edit, $curr_cat;
    $table = "item";
    $data = db_get_data($table, $id_edit, null, "", FETCH_ASSOC);
    $data = $data[0];
    wb_set_text(wb_get_control($window, ID_NAME), $data["name"]);
    wb_set_text(wb_get_control($window, ID_DESCRIPTION), $data["description"]);
    // Select the appropriate values from the combo boxes
    wb_set_selected(wb_get_control($window, ID_CATLIST), (int) array_search($curr_cat === null ? $data["cat"] : $curr_cat, db_get_data("cat", null, "id")));
    wb_set_selected(wb_get_control($window, ID_PRIORLIST), (int) array_search($data["priority"], db_get_data("priority", null, "id")));
    wb_set_selected(wb_get_control($window, ID_SEVERLIST), (int) array_search($data["severity"], db_get_data("severity", null, "id")));
}
function get_refundment_by_id($parent, $id)
{
    global $wb;
    $ctrl_map = refundment_ctrl_mapping();
    $table_name = $wb->setting["Settings"]["refundment_table"];
    $where_is = " WHERE id='{$id}' ";
    $sql = " SELECT * FROM {$table_name} {$where_is} ";
    $wb->db->query($sql);
    while ($wb->db->next_record()) {
        while (list($ctrl_name, $field_name) = each($ctrl_map)) {
            wb_set_text(wb_get_control($parent, $ctrl_name), $wb->db->f($field_name));
        }
    }
}
function process_test_lists($window, $id, $ctrl = 0, $lparam = 0)
{
    //	$ctrl = wb_get_control($window, $id);
    switch ($id) {
        case IDC_LISTLINE:
            $n = wb_get_value($ctrl);
            $text = wb_get_text(wb_get_control($window, IDC_LISTVIEW2027), $n);
            if (is_array($text)) {
                $elem = $text[1];
                $text = implode(" ", $text);
            }
            wb_set_text(wb_get_control($window, IDC_EDIT2064), "{$n} [{$text}]\r\n{$elem}");
            return true;
        case IDC_LISTVIEW2027:
        case IDC_LISTVIEW2067:
            if ($lparam == WBC_DBLCLICK) {
                wb_set_text(wb_get_control($window, IDC_EDIT2064), "Double-clicked.");
            } else {
                $val = wb_get_value($ctrl);
                if ($val && is_array($val)) {
                    $val = implode(", ", $val);
                }
                $sel = wb_get_selected($ctrl);
                if ($sel && is_array($sel)) {
                    $sel = implode(", ", $sel);
                }
                $text = wb_get_text($ctrl);
                if (@is_array($text[0])) {
                    $all = $text;
                    $text = "";
                    foreach ($all as $arr) {
                        $text .= "(" . implode(", ", $arr) . ") ";
                    }
                } elseif (is_array($text)) {
                    $text = implode(", ", $text);
                }
                wb_set_text(wb_get_control($window, IDC_EDIT2064), "Selected rows: {$sel}\nValues: [{$val}]\nText: {$text}");
            }
            return true;
        case IDC_LISTBOX2018:
        case IDC_COMBOBOX2010:
            $val = wb_get_value($ctrl);
            $text = wb_get_text($ctrl);
            wb_set_text(wb_get_control($window, IDC_EDIT2064), "[{$text}] [val: {$val}]");
            return true;
    }
    return false;
}
/**
 *
 * yc_about.form.inc.php
 *
 * @package    core
 * @author     John.meng <*****@*****.**>
 * @author     цот╤РШ
 * @author     QQ:3440895
 * @version    CVS: $Id: yc_setting.form.inc.php,v 1.4 2006/12/25 12:37:27 arzen Exp $
 */
function display_setting_dlg()
{
    global $wb;
    include PATH_FORM . "yc_setting.form.php";
    wb_set_text(wb_get_control($winmain, IDC_DB_HOST), $wb->setting["Settings"]["db_host"]);
    wb_set_text(wb_get_control($winmain, IDC_DB_USERNAME), $wb->setting["Settings"]["db_username"]);
    wb_set_text(wb_get_control($winmain, IDC_DB_PASSWORD), $wb->setting["Settings"]["db_password"]);
    wb_set_text(wb_get_control($winmain, IDC_DB_NAME), $wb->setting["Settings"]["db_dbname"]);
    include PATH_CONFIG . "common.php";
    $items = array_values($LangOption);
    wb_set_text(wb_get_control($winmain, IDC_LANGUAGE), $items);
    wb_set_text(wb_get_control($winmain, IDC_LANGUAGE), $LangOption[$wb->setting["Settings"]["lang_set"]]);
    //	wb_set_selected(wb_get_control($winmain, IDC_LANGUAGE),$LangOption[$wb->setting["Settings"]["lang_set"]]);
    wb_set_visible($winmain, true);
    wb_set_handler($winmain, "process_setting");
}
function get_review_by_id($parent, $id)
{
    global $wb, $ReviewwayOption;
    $ctrl_map = review_ctrl_mapping();
    $table_name = $wb->setting["Settings"]["review_table"];
    $where_is = " WHERE id='{$id}' ";
    $sql = " SELECT * FROM {$table_name} {$where_is} ";
    $wb->db->query($sql);
    while ($wb->db->next_record()) {
        while (list($ctrl_name, $field_name) = each($ctrl_map)) {
            if ($field_name == 'category') {
                include PATH_CONFIG . "common.php";
                wb_set_text(wb_get_control($parent, $ctrl_name), $ReviewwayOption[$wb->db->f($field_name)]);
            } else {
                wb_set_text(wb_get_control($parent, $ctrl_name), $wb->db->f($field_name));
            }
        }
    }
}
function reset_form($class, $parent, $title, $width, $height, $style = 0, $value = 0)
{
    global $wb;
    $wb->currentform = 0;
    $wb->proj_filename = null;
    if (!isset($wb->form[$wb->currentform])) {
        $wb->form[$wb->currentform] = new stdclass();
    }
    // Reset form data with fixed attributes
    $wb->form[$wb->currentform]->ct = array();
    $wb->form[$wb->currentform]->numcontrols = 0;
    $wb->form[$wb->currentform]->ncurrindex = 0;
    $wb->form[$wb->currentform]->nselcontrol = -1;
    $wb->form[$wb->currentform]->treenode = 0;
    foreach ($wb->project_array as $var) {
        $wb->form[$wb->currentform]->{$var} = constant("DEFAULT_" . strtoupper($var));
    }
    // Variable attributes
    $wb->form[$wb->currentform]->width = $width;
    $wb->form[$wb->currentform]->height = $height;
    $wb->form[$wb->currentform]->caption = $title;
    $wb->form[$wb->currentform]->cclass = $class;
    $wb->form[$wb->currentform]->style = (int) $style;
    $wb->form[$wb->currentform]->value = (int) $value;
    // Resize, reposition and show form
    $pos = wb_get_position($parent);
    wb_set_position($wb->formwin, $pos[0] + 180, $pos[1] + 76);
    wb_set_size($wb->formwin, $width, $height);
    wb_set_text($wb->formwin, $title);
    wb_set_visible($wb->formwin, true);
    // Create a treeview item for this form
    wb_delete_items($wb->tree, $wb->form[$wb->currentform]->treenode);
    $root = $wb->rootnode;
    $node = wb_create_items($wb->tree, array(array($title, $wb->currentform, $root, 8, 9, 2)));
    $wb->form[$wb->currentform]->treenode = $node;
    // numforms is always set to 1
    $wb->numforms = 1;
    // Expand the root and select the new node
    wb_set_state($wb->tree, $root, 1);
    wb_set_selected($wb->tree, $node);
}
function import_csv($window)
{
    global $statusbar;
    $filename = wb_sys_dlg_open($window, "Import CSV", "CSV files (*.csv, *.txt)*.csv;*.txtAll files (*.*)*.*" . "");
    if ($filename) {
        $csv = file($filename);
    } else {
        return false;
    }
    $n = 0;
    foreach ($csv as $line) {
        $line = trim($line);
        if ($line) {
            $entry = csv_explode(stripcslashes($line));
            if (edit_record("item", 0, "name\ndescription\ncat\npriority\nseverity", $entry)) {
                $n++;
            }
        }
    }
    wb_set_text($statusbar, basename($filename) . " imported successfully ({$n} items added).");
    return true;
}
function wb_create_control($parent, $class, $caption = "", $xpos = 0, $ypos = 0, $width = 0, $height = 0, $id = null, $style = 0, $lparam = null, $ntab = 0)
{
    switch ($class) {
        case Accel:
            return wbtemp_set_accel_table($parent, $caption);
        case ToolBar:
            return wbtemp_create_toolbar($parent, $caption, $width, $height, $lparam);
        case Menu:
            return wbtemp_create_menu($parent, $caption);
        case HyperLink:
            return wbtemp_create_control($parent, $class, $caption, $xpos, $ypos, $width, $height, $id, $style, is_null($lparam) ? NOCOLOR : $lparam, $ntab);
        case ComboBox:
        case ListBox:
        case ListView:
            $ctrl = wbtemp_create_control($parent, $class, $caption, $xpos, $ypos, $width, $height, $id, $style, $lparam, $ntab);
            if (is_array($caption)) {
                wb_set_text($ctrl, $caption[0]);
            }
            return $ctrl;
        case TreeView:
            $ctrl = wbtemp_create_control($parent, $class, $caption, $xpos, $ypos, $width, $height, $id, $style, $lparam, $ntab);
            if (is_array($caption)) {
                wb_set_text($ctrl, $caption[0]);
            }
            return $ctrl;
        case Gauge:
        case Slider:
        case ScrollBar:
            $ctrl = wbtemp_create_control($parent, $class, $caption, $xpos, $ypos, $width, $height, $id, $style, $lparam, $ntab);
            if ($lparam) {
                wb_set_value($ctrl, $lparam);
            }
            return $ctrl;
        default:
            return wbtemp_create_control($parent, $class, $caption, $xpos, $ypos, $width, $height, $id, $style, $lparam, $ntab);
    }
}
function process_main($window, $id, $ctrl)
{
    global $statusbar, $fmod, $mainwin;
    switch ($id) {
        case ID_INFOTIMER:
            $status = "´ÅÅÌ: " . $fmod->fmod_GetOutputName() . " ";
            $status .= "¸èÇú³¤¶È: " . $fmod->fmod_GetLenght(true) . " ·ÖÖÓ ";
            $status .= "ÒѲ¥·Å: " . $fmod->fmod_Msec2Time($fmod->fmod_GetTime(true)) . " sec ";
            if ($song_name = $fmod->fmodStreamUrl) {
                $status .= "Ãû³Æ: {$song_name} ";
            }
            wb_set_text($statusbar, $status);
            //		play position
            if ($fmod->fmod_GetLenght(false)) {
                wb_set_value(wb_get_control($mainwin, ID_PLAY_POS), round($fmod->fmod_GetTime(false) / $fmod->fmod_GetLenght(false), 2) * 100);
            }
            if ($fmod->fmod_GetTime(false) == $fmod->fmod_GetLenght(false)) {
                $fmod->fmod_StreamOpen($fmod->fmodStreamUrl);
                $fmod->fmod_StreamPlay();
            }
            break;
        case ID_OPEN:
            $filename = wb_sys_dlg_open();
            if ($filename) {
                if ($fmod->fmod_StreamOpen($filename)) {
                    $fmod->fmod_StreamPlay();
                    // returns true, then play
                } else {
                    wb_message_box($window, "Error opening Audiostream!\n" . $fmod->lasterror, APPNAME, WBC_INFO);
                }
            }
            break;
        case ID_CLOSE:
            $fmod->fmod_StreamStop();
            break;
        case ID_PLAY:
            $fmod->fmod_StreamPlay();
            break;
        case ID_STOP:
            $fmod->fmod_StreamStop();
            break;
        case ID_PAUSE:
            if ($fmod->fmodStreamState == 1) {
                switch ($fmod->fmodIsPaused) {
                    case 0:
                        $fmod->fmod_SoundPause(true);
                        wb_set_text($ctrl, "¼ÌÐø..");
                        break;
                    case 1:
                        $fmod->fmod_SoundPause(false);
                        wb_set_text($ctrl, "ÔÝÍ£");
                        break;
                }
            }
            break;
        case ID_MUTE:
            if ($fmod->fmodStreamState == 1) {
                switch ($fmod->fmodIsMuted) {
                    case 0:
                        $fmod->fmod_SoundMute(true);
                        wb_set_text($ctrl, "·ÅÒô");
                        break;
                    case 1:
                        $fmod->fmod_SoundMute(false);
                        wb_set_text($ctrl, "¾²Òô");
                        break;
                }
            }
            break;
        case ID_SURROUND:
            switch ($fmod->fmodSurroundEnabled) {
                case 0:
                    $fmod->fmod_SetSurround(true);
                    wb_set_text($ctrl, "Ñ­»·");
                    break;
                case 1:
                    $fmod->fmod_SetSurround(false);
                    wb_set_text($ctrl, "²»Ñ­»·");
                    break;
            }
            break;
        case ID_VOLUMEN:
            $fmod->fmod_SetVolumen(wb_get_value($ctrl));
            wb_set_text($statusbar, "ÒôÁ¿: " . $fmod->fmod_GetVolumen());
            break;
        case ID_BALANCE:
            $fmod->fmod_SetPanning(wb_get_value($ctrl));
            break;
        case ID_BALCENTER:
            $fmod->fmod_SetPanning(127);
            wb_set_value(wb_get_control($window, ID_BALANCE), 127);
            break;
        case IDCLOSE:
            $fmod->fmod_SoundClose();
            wb_release_library($fmod->fmodlib);
            wb_destroy_window($window);
            break;
    }
}
$tab = wb_create_control($winmain, TabControl, 'Tab1,Tab2,Tab3', 10, 215, 195, 85, IDC_TABCONTROL1020, 0x0, 0, 0);
wb_create_control($winmain, PushButton, 'PushButton1', 10, 15, 100, 25, IDC_PUSHBUTTON1001, 0x0, 0, 0);
$ctrl = $ctrl = wb_create_control($winmain, ImageButton, 'ImageButton2', 120, 15, 90, 60, IDC_IMAGEBUTTON1002, 0x0, 0, 0);
$img = wb_load_image('resources\\symb_imagebutton.bmp');
wb_set_image($ctrl, $img, NOCOLOR, 0, 0);
wb_destroy_image($img);
wb_create_control($winmain, InvisibleArea, 'InvisibleArea3', 220, 15, 70, 60, IDC_INVISIBLEAREA1003, 0x0, 0, 0);
wb_create_control($winmain, CheckBox, 'CheckBox4', 300, 20, 120, 15, IDC_CHECKBOX1004, 0x0, 0, 0);
wb_create_control($winmain, RadioButton, 'RadioButton5', 300, 40, 120, 15, IDC_RADIOBUTTON1005, 0x0, 0, 0);
wb_create_control($winmain, HyperLink, 'HyperLink6', 405, 25, 165, 15, IDC_HYPERLINK1006, 0x880, 12582912, 0);
wb_create_control($winmain, Label, 'Label7', 10, 50, 100, 15, 0, 0x0, 0, 0);
wb_create_control($winmain, EditBox, 'EditBox8', 220, 225, 200, 20, IDC_EDITBOX1008, 0x0, 0, 0);
wb_create_control($winmain, RTFEditBox, 'RTFEditBox9', 300, 65, 120, 140, IDC_RTFEDITBOX1009, 0x0, 0, 0);
wb_create_control($winmain, Frame, 'Frame10', 10, 75, 280, 130, 0, 0x0, 0, 0);
$ctrl = wb_create_control($winmain, ListBox, 'ListBox11', 25, 95, 120, 95, IDC_LISTBOX1011, 0x0, 0, 0);
wb_set_text($ctrl, explode(',', 'ListBox11'));
$ctrl = wb_create_control($winmain, ComboBox, 'ComboBox12', 155, 95, 120, 95, IDC_COMBOBOX1013, 0x0, 0, 0);
wb_set_text($ctrl, explode(',', 'ComboBox12'));
wb_create_control($winmain, Spinner, 'Spinner13', 440, 410, 20, 20, IDC_SPINNER1014, 0x0, 0, 0);
$ctrl = wb_create_control($winmain, ScrollBar, 'ScrollBar14', 435, 305, 140, 20, IDC_SCROLLBAR1015, 0x0, 0, 0);
wb_set_value($ctrl, 0);
$ctrl = wb_create_control($winmain, Slider, 'Slider15', 430, 380, 145, 20, IDC_SLIDER1016, 0x0, 50, 0);
wb_set_value($ctrl, 50);
$ctrl = wb_create_control($winmain, Gauge, 'Gauge16', 435, 345, 140, 20, IDC_GAUGE1017, 0x0, 50, 0);
wb_set_value($ctrl, 50);
wb_create_control($winmain, Calendar, 'Calendar17', 220, 263, 200, 167, IDC_CALENDAR1018, 0x8, 0, 0);
wb_create_control($winmain, HTMLControl, 'HTMLControl18', 435, 215, 140, 80, IDC_HTMLCONTROL1019, 0x8, 0, 0);
wb_create_control($winmain, TreeView, 'TreeView20', 425, 55, 150, 150, IDC_TREEVIEW1021, 0x0, 0, 0);
$ctrl = wb_create_control($winmain, ListView, 'Field 1,Field 2,Field3', 10, 310, 195, 120, IDC_LISTVIEW1022, 0x0, 0, 0);
wb_set_text($ctrl, 'Field 1,Field 2,Field3');
// End controls
function update_prior_controls($window)
{
    global $mainwin, $prior_table;
    $itemlist = wb_get_control($window, ID_PRIORITYLIST);
    $id = db_get_id($prior_table, wb_get_selected($itemlist));
    wb_set_text(wb_get_control($window, ID_NAME), db_get_data($prior_table, $id, "name"));
    $sel = wb_get_selected($itemlist);
    wb_set_enabled(wb_get_control($window, ID_SETITEM), $sel != -1);
    wb_set_enabled(wb_get_control($window, ID_DELETEITEM), $sel != -1);
}
 function renderForm()
 {
     global $wb;
     if (empty($wb->current_page)) {
         $wb->current_page = 1;
         $wb->total_page = 1;
         $wb->current_category_page = 1;
         $wb->total_category_page = 1;
     }
     $this->left_control = wb_create_control($wb->mainwin, TabControl, "{$wb->vars["Lang"]["lang_contact"]},{$wb->vars["Lang"]["lang_contact"]}{$wb->vars["Lang"]["lang_category"]}", 160, 2, $wb->winwidth - 160, $wb->winheight - 40, IDC_TABCONTROL, 0x0, 0 | WBC_RESIZE, 0);
     $dim = wb_get_size($this->left_control, true);
     $this->data_list = wb_create_control($this->left_control, ListView, "", 0, 10, $dim[0] - 10, $dim[1] - 300, IDC_DATA_LIST, WBC_VISIBLE | WBC_ENABLED | WBC_SORT | WBC_LINES | WBC_CHECKBOXES, 0, 0);
     $this->category_list = wb_create_control($this->left_control, ListView, "", 0, 10, $dim[0] - 10, $dim[1] - 300, IDC_CATEGORY_LIST_VIEW, WBC_VISIBLE | WBC_ENABLED | WBC_SORT | WBC_LINES | WBC_CHECKBOXES, 0, 1);
     // Create ListView header
     wb_set_text($this->data_list, array(array("File", 100), array(null, 80), array("Name", 140), array("Update", 200)));
     // Create Category ListView header
     wb_set_text($this->category_list, array(array($wb->vars["Lang"]["lang_id"], 100), array($wb->vars["Lang"]["lang_category"] . $wb->vars["Lang"]["lang_name"], 220), array($wb->vars["Lang"]["lang_state"], 140)));
     $this->reset_listview();
     $this->reset_category_listview();
     // render form
     $this->renderCategoryForm($this->left_control);
     wb_set_handler($this->left_control, "process_main");
     return $this->left_control;
 }
 /**
  * _update_status
  * no desc
  * @example examples/status.php Example
  * @param string $str
  * @return void
  */
 function _update_status($str)
 {
     if ($this->wb_status_active) {
         wb_set_text($this->wb_status_field, $str);
     }
 }
Beispiel #19
0
function process_main($window, $id)
{
    global $label, $statusbar, $top_bar, $foot_bar, $news_str, $wb;
    static $pos, $top_pos, $foot_pos;
    $disks_str = "";
    $news_str = $wb->newscontent;
    //	if ((date("i")%3)==0)
    //	{
    //		$news_str="滚动新闻:".getNews ();
    //
    ////		$disks = explode(" ", wb_get_system_info("diskdrives"));
    ////		for ($index = 0; $index < sizeof($disks); $index++)
    ////		{
    ////			$disks_str .= getTotalDiskSpace ($disks[$index]);
    ////		}
    //
    //	}
    //	$news_str=$news_str?$news_str:"滚动新闻:".getNews ();
    switch ($id) {
        case ID_NEWS_TIMER:
            $wb->newscontent = getNews();
            break;
        case ID_APP_TIMER:
            // Show the current time in hours, minutes and seconds
            wb_set_text($label, getTimeShotFormat(date("h:i:s A")));
            // Truncate text
            $text = $news_str;
            //			$text = formatLocalDate (date("Y-m-d H:i:s")).$news_str;//.$news_str;//date(LONG_FMT);
            $len = strlen($text);
            wb_set_text($statusbar, mb_substr($text . $text, $pos, $len, "gb2312"));
            //substr($text . $text, $pos, $len) mb_substr($text . $text, $pos, $len,"gb2312")
            $pos = $pos < $len ? $pos + 2 : 0;
            $top_text = "....>........";
            if (ereg("11:4([0-9])", date("H:i"))) {
                $top_text = "吃中午饭时间";
            }
            if (ereg("12:([0-9]{2})", date("H:i"))) {
                $top_text = "中午休息时间";
            }
            if (ereg("17:([2-3][0-9])", date("H:i"))) {
                $top_text = "记得写每日工作报告";
            }
            $top_len = strlen($top_text);
            wb_set_text($top_bar, mb_substr($top_text . $top_text, $top_pos, $top_len, "gb2312"));
            //substr($text . $text, $pos, $len) mb_substr($text . $text, $pos, $len,"gb2312")
            $top_pos = $top_pos > 0 ? $top_pos - 1 : $top_len;
            //			$foot_len = strlen($disks_str);
            //			wb_set_text($foot_bar, mb_substr($disks_str . $disks_str, $foot_pos, $foot_len,"gb2312"));//substr($text . $text, $pos, $len) mb_substr($text . $text, $pos, $len,"gb2312")
            //			$foot_pos = $foot_pos < $foot_len  ? $foot_pos +1 : 0;
            break;
        case IDCLOSE:
            wb_destroy_window($window);
            break;
    }
}
function process_test_values($window, $id, $ctrl = 0, $lparam1 = 0, $lparam2 = 0)
{
    global $statusbar;
    if ($lparam1 == WBC_GETFOCUS) {
        wb_set_text($statusbar, "Focus to control {$id}");
        return false;
    }
    switch ($id) {
        case IDC_EDIT4069:
        case IDC_EDIT4071:
            if ($lparam1 == WBC_KEYDOWN) {
                wb_set_text($statusbar, "Char {$lparam2}: " . chr($lparam2));
            }
            break;
        case IDC_EDIT4057:
            if ($lparam1 == WBC_KEYDOWN) {
                wb_set_text($statusbar, "Char {$lparam2}: " . chr($lparam2));
                //				wb_set_text(wb_get_control($window, IDC_STATIC4048), $lparam2 . "\n" . chr($lparam2));
                break;
            }
            $text = wb_get_text(wb_get_control($window, IDC_EDIT4057));
            wb_set_text(wb_get_control($window, IDC_EDIT4058), $text);
            wb_set_text(wb_get_control($window, IDC_EDIT4059), $text);
            wb_set_text(wb_get_control($window, IDC_EDIT4065), implode(" ", array_fill(0, 20, $text)));
            break;
        case IDC_LISTBOX4053:
            if ($lparam1 & WBC_DBLCLICK) {
                wb_set_text(wb_get_control($window, IDC_STATIC4048), "Double-click");
            } else {
                wb_set_text(wb_get_control($window, IDC_STATIC4048), "Single click");
            }
            break;
        case IDC_HSCROLL4056:
        case IDC_SLIDER4011:
            $value = wb_get_value(wb_get_control($window, $id));
            wb_set_value(wb_get_control($window, IDC_PROGRESSBAR4007), $value);
            wb_set_text(wb_get_control($window, IDC_STATIC4019), $value);
            wb_set_value(wb_get_control($window, IDC_HSCROLL4026), $value);
            wb_set_value(wb_get_control($window, IDC_VSCROLL4051), $value);
            wb_set_value(wb_get_control($window, IDC_UPDOWN4028), $value);
            $value = wb_get_value(wb_get_control($window, $id));
            wb_set_text(wb_get_control($window, IDC_STATIC4048), "Control #{$id}: value [{$value}]\n");
            wb_set_value(wb_get_control($window, IDC_EDIT4052), $value);
            break;
        case IDC_RADIOBUTTON4014:
        case IDC_RADIOBUTTON4015:
        case IDC_RADIOBUTTON4016:
            $value = $id - IDC_RADIOBUTTON4014;
            wb_set_value(wb_get_control($window, IDC_LISTBOX4053), $value);
            wb_set_value(wb_get_control($window, IDC_COMBOBOX4054), $value);
            wb_set_value(wb_get_control($window, IDC_LISTBOX4055), $value);
            break;
        case IDC_CHECKBOX4034:
            wb_set_selected(wb_get_control($window, IDC_CHECKBOX4049), wb_get_selected($ctrl));
            $value = wb_get_value(wb_get_control($window, $id));
            wb_set_text(wb_get_control($window, IDC_STATIC4048), "Control #{$id}: value [{$value}]\n");
            break;
        case IDC_UPDOWN4028:
        case IDC_CHECKBOX4049:
            $value = wb_get_value(wb_get_control($window, $id));
            wb_set_text(wb_get_control($window, IDC_STATIC4048), "Control #{$id}: value [{$value}]\n");
            break;
    }
}
function process_refundment($window, $id, $ctrl, $lparam1 = 0, $lparam2 = 0)
{
    global $wb;
    switch ($id) {
        case IDC_NAV_FIRST:
            $wb->current_page = 1;
            reset_refundment_view();
            break;
        case IDC_NAV_PRE:
            $wb->current_page -= 1;
            $wb->current_page = $wb->current_page < 1 ? 1 : $wb->current_page;
            reset_refundment_view();
            break;
        case IDC_NAV_NEXT:
            $wb->current_page += 1;
            $wb->current_page = $wb->current_page > $wb->total_page ? $wb->total_page : $wb->current_page;
            reset_refundment_view();
            break;
        case IDC_NAV_LAST:
            $wb->current_page = $wb->total_page;
            reset_refundment_view();
            break;
        case IDC_REFUNDMENT_LIST:
            if ($lparam1 == WBC_DBLCLICK) {
                $current_rows = wb_get_text($ctrl);
                $current_id = $current_rows[0][0];
                $wb->current_ids = $current_id;
                $wb->current_form_state = false;
                $wb->current_action = 'update';
                if ($wb->current_ids) {
                    include_once PATH_FORM . "yc_refundment_edit.form.inc.php";
                    create_refundment_edit_dlg();
                }
            }
            // Show current selection and checked items
            $sel = wb_get_selected($ctrl);
            $sel = $sel ? implode(", ", $sel) : "none";
            $contents = wb_get_text($ctrl);
            $text = "";
            if ($contents) {
                foreach ($contents as $row) {
                    $text .= $row ? "[" . implode(", ", $row) . "]  " : "";
                }
            }
            $checked = wb_get_value($ctrl);
            $temp_str = "";
            if ($checked) {
                foreach ($checked as $value) {
                    $row_data = wb_get_text($ctrl, $value, 0);
                    $temp_str .= $row_data . ",";
                }
                $del_ids = rtrim($temp_str, ',');
                $wb->del_ids = $del_ids;
            }
            $checked = $checked ? implode(", ", $checked) : "none";
            wb_set_text($wb->statusbar, "Selected lines: " . $sel . " / checked: " . $checked . " / deleted: " . $del_ids . " / contents: " . $text);
            break;
        case IDC_REFUNDMENT_CATEGORY_LIST:
            if ($lparam1 == WBC_DBLCLICK) {
                $current_rows = wb_get_text($ctrl);
                $current_id = $current_rows[0][0];
                $wb->current_ids = $current_id;
                $wb->current_form_state = false;
                $wb->current_action = 'update';
                if ($wb->current_ids) {
                    include_once PATH_FORM . "yc_refundment_category_edit.form.inc.php";
                    create_refundment_category_edit_dlg();
                }
            }
            // Show current selection and checked items
            $sel = wb_get_selected($ctrl);
            $sel = $sel ? implode(", ", $sel) : "none";
            $contents = wb_get_text($ctrl);
            $text = "";
            if ($contents) {
                foreach ($contents as $row) {
                    $text .= $row ? "[" . implode(", ", $row) . "]  " : "";
                }
            }
            $checked = wb_get_value($ctrl);
            $temp_str = "";
            if ($checked) {
                foreach ($checked as $value) {
                    $row_data = wb_get_text($ctrl, $value, 0);
                    $temp_str .= $row_data . ",";
                }
                $del_ids = rtrim($temp_str, ',');
                $wb->del_ids = $del_ids;
            }
            $checked = $checked ? implode(", ", $checked) : "none";
            wb_set_text($wb->statusbar, "Selected lines: " . $sel . " / checked: " . $checked . " / deleted: " . $del_ids . " / contents: " . $text);
            break;
    }
}
function save_settings()
{
    global $wb;
    wb_set_text($wb->statusbar, "Saving configuration...");
    // Get values
    save_window_geom($wb->mainwin, "main", true);
    // Get various settings
    foreach ($wb->options_array as $var) {
        $var = strtolower($var);
        if ($wb->{$var} === '') {
            $wb->settings["Settings"][$var] = '';
        } elseif (preg_match("/[\\d\\.\\,]+/", $wb->{$var})) {
            $wb->settings["Settings"][$var] = (int) $wb->{$var};
        } else {
            $wb->settings["Settings"][$var] = $wb->{$var};
        }
    }
    // Save options to INI file
    $contents = generate_ini($wb->settings, "; Make Release INI file\r\n");
    if ($contents) {
        file_put_contents(SYS_INIFILE, $contents);
        wb_set_text($wb->statusbar, "Configuration saved.");
    } else {
        wb_message_box($wb->mainwin, "Problem saving file " . SYS_INIFILE);
    }
}
function update_cat_controls($window)
{
    global $mainwin, $cat_table, $it_list;
    // Below: get id of selected treeview element. See comment in update_items()
    $it_list = wb_get_control($window, ID_TREE);
    $sel_text = wb_get_text($it_list);
    $cat_data = db_get_data("cat", null, "name");
    $sel_index = (int) array_search($sel_text, $cat_data);
    $cat_data = db_get_data("cat", null, "id");
    $id_cat = $cat_data[$sel_index];
    $id = db_get_id($cat_table, $sel_index);
    $data = db_get_data($cat_table, $id, null, "", FETCH_ASSOC);
    $data = $data[0];
    wb_set_text(wb_get_control($window, ID_NAME), $data["name"]);
    wb_set_value(wb_get_control($window, ID_LEVEL), $data["level"]);
    wb_set_enabled(wb_get_control($window, ID_SETITEM), $sel_text != "");
    wb_set_enabled(wb_get_control($window, ID_DELETEITEM), $sel_text != "");
}
Beispiel #24
0
function process_main($window, $id, $ctrl, $lparam1 = 0, $lparam2 = 0)
{
    global $wb;
    switch ($id) {
        case ID_CREATE:
            $wb->current_ids = null;
            $wb->current_action = "insert";
            switch ($wb->current_module) {
                case "contact":
                    include_once PATH_FORM . "yc_contact_edit.form.inc.php";
                    create_contact_edit_dlg();
                    break;
                case "contact_category":
                case "company":
                case "product":
                case "product_category":
                case "opportunity":
                case "order":
                case "order_category":
                case "agreement":
                case "agreement_category":
                case "complaints":
                case "complaints_category":
                case "refundment":
                case "refundment_category":
                case "review":
                    $module_name = $wb->current_module;
                    $function_name = "create_{$module_name}_edit_dlg";
                    include_once PATH_FORM . "yc_{$module_name}_edit.form.inc.php";
                    $function_name();
                    break;
            }
            wb_set_text($wb->statusbar, "Create module: " . $wb->current_module);
            break;
        case IDC_TOOLBAR_SEARCH:
            switch ($wb->current_module) {
                case "contact":
                    create_contact_search_dlg($window);
                    break;
                case "contact_category":
                    create_category_contact_search_dlg($window);
                    break;
                case "company":
                case "product":
                case "product_category":
                case "opportunity":
                case "order":
                case "order_category":
                case "agreement":
                case "agreement_category":
                case "complaints":
                case "complaints_category":
                case "refundment":
                case "refundment_category":
                case "review":
                    $module_name = $wb->current_module;
                    $function_name = "create_{$module_name}_search_dlg";
                    include_once PATH_FORM . "yc_{$module_name}_search.form.inc.php";
                    $function_name();
                    break;
            }
            wb_set_text($wb->statusbar, "Search module: " . $wb->current_module);
            break;
        case ID_DELETE:
            switch ($wb->current_module) {
                case "contact":
                    del_selected_contact();
                    break;
                case "contact_category":
                case "company":
                case "product":
                case "product_category":
                case "opportunity":
                case "order":
                case "order_category":
                case "agreement":
                case "agreement_category":
                case "complaints":
                case "complaints_category":
                case "refundment":
                case "refundment_category":
                case "review":
                    $module_name = $wb->current_module;
                    $function_name = "del_selected_{$module_name}";
                    $function_name();
                    break;
            }
            wb_set_text($wb->statusbar, "Deleted module: " . $wb->current_module);
            break;
        case IDC_LEFT_TREE:
            $selnode = wb_get_selected($wb->tree_view);
            if ($wb->right_control) {
                wb_set_visible($wb->right_control, false);
            }
            switch (wb_get_value($wb->tree_view)) {
                case 2001:
                case 2002:
                    $wb->current_module = "contact";
                    $wb->keyword = null;
                    $wb->current_page = 1;
                    $wb->del_ids = null;
                    displayContactForm();
                    break;
                case 2003:
                    $wb->current_module = "company";
                    $wb->keyword = null;
                    $wb->current_page = 1;
                    $wb->del_ids = null;
                    include_once PATH_FORM . "yc_company.form.inc.php";
                    displayCompanyMainTabForm();
                    break;
                case 2004:
                    $wb->current_module = "product";
                    $wb->keyword = null;
                    $wb->current_page = 1;
                    $wb->del_ids = null;
                    include_once PATH_FORM . "yc_product.form.inc.php";
                    display_product_main_tab_form();
                    break;
                case 2005:
                case 2006:
                    $wb->current_module = "opportunity";
                    $wb->keyword = null;
                    $wb->current_page = 1;
                    $wb->del_ids = null;
                    include_once PATH_FORM . "yc_opportunity.form.inc.php";
                    display_opportunity_main_tab_form();
                    break;
                case 2007:
                    $wb->current_module = "order";
                    $wb->keyword = null;
                    $wb->current_page = 1;
                    $wb->del_ids = null;
                    include_once PATH_FORM . "yc_order.form.inc.php";
                    display_order_main_tab_form();
                    break;
                case 2008:
                    $wb->current_module = "agreement";
                    $wb->keyword = null;
                    $wb->current_page = 1;
                    $wb->del_ids = null;
                    include_once PATH_FORM . "yc_agreement.form.inc.php";
                    display_agreement_main_tab_form();
                    break;
                case 2009:
                case 2010:
                    $wb->current_module = "complaints";
                    $wb->keyword = null;
                    $wb->current_page = 1;
                    $wb->del_ids = null;
                    include_once PATH_FORM . "yc_complaints.form.inc.php";
                    display_complaints_main_tab_form();
                    break;
                case 2011:
                    $wb->current_module = "refundment";
                    $wb->keyword = null;
                    $wb->current_page = 1;
                    $wb->del_ids = null;
                    include_once PATH_FORM . "yc_refundment.form.inc.php";
                    display_refundment_main_tab_form();
                    break;
                case 2012:
                    $wb->current_module = "review";
                    $wb->keyword = null;
                    $wb->current_page = 1;
                    $wb->del_ids = null;
                    include_once PATH_FORM . "yc_review.form.inc.php";
                    display_review_main_tab_form();
                    break;
            }
            wb_set_text($wb->statusbar, "Selected item: " . wb_get_text($wb->tree_view, $selnode) . " / Value: " . wb_get_value($wb->tree_view) . " / Parent: " . wb_get_parent($wb->tree_view, $selnode) . " / Level: " . wb_get_level($wb->tree_view, $selnode) . " / State: " . (wb_get_state($wb->tree_view, $selnode) ? "expanded" : "collapsed"));
            break;
        case IDCLOSE:
            // IDCLOSE is predefined
            if (wb_message_box($wb->mainwin, $wb->vars["Lang"]["lang_sure_logout"], $wb->vars["Lang"]["system_name"], WBC_QUESTION | WBC_YESNO)) {
                wb_destroy_window($window);
            }
            break;
        case ID_ABOUT:
            include_once PATH_FORM . "yc_about.form.inc.php";
            display_about_dlg();
            break;
        case ID_SETTING:
            include_once PATH_FORM . "yc_setting.form.inc.php";
            display_setting_dlg();
            break;
        default:
            if (process_contact($window, $id, $ctrl, $lparam1, $lparam2)) {
                break;
            }
            if (wb_get_class($ctrl) == TabControl && $lparam1 & WBC_HEADERSEL) {
                switch ($id) {
                    case IDC_CONTACT_FORM:
                        if ($lparam2 == 0) {
                            $wb->current_module = "contact";
                        } else {
                            $wb->current_module = "contact_category";
                        }
                        break;
                    case IDC_PRODUCTS_TAB:
                        if ($lparam2 == 0) {
                            $wb->current_module = "product";
                        } else {
                            $wb->current_module = "product_category";
                        }
                        break;
                    case IDC_ORDER_TAB:
                        if ($lparam2 == 0) {
                            $wb->current_module = "order";
                        } else {
                            $wb->current_module = "order_category";
                        }
                        break;
                    case IDC_AGREEMENT_TAB:
                        if ($lparam2 == 0) {
                            $wb->current_module = "agreement";
                        } else {
                            $wb->current_module = "agreement_category";
                        }
                        break;
                    case IDC_COMPLAINTS_TAB:
                        if ($lparam2 == 0) {
                            $wb->current_module = "complaints";
                        } else {
                            $wb->current_module = "complaints_category";
                        }
                        break;
                    case IDC_REFUNDMENT_TAB:
                        if ($lparam2 == 0) {
                            $wb->current_module = "refundment";
                        } else {
                            $wb->current_module = "refundment_category";
                        }
                        break;
                }
                wb_set_text($wb->statusbar, "Tab #{$lparam2} of tab control #{$id} selected.");
            } else {
                wb_set_text($wb->statusbar, "Control ID: " . $id);
            }
            break;
    }
}