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; } }
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 process_project($window, $id, $ctrl) { global $wb; switch ($id) { case IDC_ISTABPAGE: $val = wb_get_value($ctrl); wb_set_enabled(wb_get_control($wb->winproject, IDC_TABNUMBER), $val); wb_set_enabled(wb_get_control($wb->winproject, IDC_TABNUMBERSPINNER), $val); break; case IDC_CTRLVAR: $hastext = wb_get_text($ctrl) !== ''; wb_set_enabled(wb_get_control($wb->winproject, IDC_STARTCTRLVAL), $hastext); break; case IDC_LOCALIZE: wb_set_enabled(wb_get_control($wb->winproject, IDC_LOCPREFIX), wb_get_value($ctrl)); break; case IDOK: // Set various settings foreach ($wb->project_array as $var) { $var = strtolower($var); $ctrl = wb_get_control($wb->winproject, constant("IDC_" . strtoupper($var))); if (wb_get_class($ctrl) != RadioButton && wb_get_class($ctrl) != CheckBox) { $wb->form[$wb->currentform]->{$var} = wb_get_text($ctrl); } else { $wb->form[$wb->currentform]->{$var} = wb_get_value($ctrl); } } // Fall-through // Fall-through case IDCANCEL: set_default_accel(); wb_destroy_window($window); break; } }
function process_about($window, $id, $ctrl) { global $wb; switch ($id) { case IDCLOSE: // IDCLOSE is predefined // IDCLOSE is predefined case IDCANCEL: wb_destroy_window($window); break; } }
function process_prior($window, $id) { global $mainwin, $prior_table; switch ($id) { case ID_PRIORITYLIST: update_prior_controls($window); break; case ID_NEWITEM: $name = wb_get_text(wb_get_control($window, ID_NAME)); db_edit_record($prior_table, 0, "name", array($name)); update_priors($window); update_prior_controls($window); break; case ID_SETITEM: $name = wb_get_text(wb_get_control($window, ID_NAME)); $itemlist = wb_get_control($window, ID_PRIORITYLIST); $id = db_get_id($prior_table, wb_get_selected($itemlist)); db_edit_record($prior_table, $id, "name", array($name)); update_priors($window); update_prior_controls($window); break; case ID_DELETEITEM: $itemlist = wb_get_control($window, ID_PRIORITYLIST); $selected = wb_get_selected($itemlist); $id = db_get_id($prior_table, $selected); db_delete_records($prior_table, db_get_id($prior_table, $selected)); update_priors($window); update_prior_controls($window); break; case ID_MOVEUP: $itemlist = wb_get_control($window, ID_PRIORITYLIST); $selected = wb_get_selected($itemlist); $id = db_get_id($prior_table, $selected); db_swap_records($prior_table, db_get_id($prior_table, $selected), db_get_id($prior_table, $selected - 1)); update_priors($window); update_prior_controls($window); break; case ID_MOVEDOWN: $itemlist = wb_get_control($window, ID_PRIORITYLIST); $selected = wb_get_selected($itemlist); $id = db_get_id($prior_table, $selected); db_swap_records($prior_table, db_get_id($prior_table, $selected), db_get_id($prior_table, $selected + 1)); update_priors($window); update_prior_controls($window); break; case IDCANCEL: case IDCLOSE: case IDOK: wb_destroy_window($window); break; } }
function process_cat($window, $id) { global $it_list, $mainwin, $cat_table; switch ($id) { case ID_TREE: update_cat_controls($window); break; case ID_NEWITEM: $name = wb_get_text(wb_get_control($window, ID_NAME)); $level = wb_get_selected(wb_get_control($window, ID_LEVEL)); // db_edit_record($cat_table, 0, "name\nlevel", array($name, $level)); update_tree($window); update_cat_controls($window); break; case ID_SETITEM: $name = wb_get_text(wb_get_control($window, ID_NAME)); $level = wb_get_selected(wb_get_control($window, ID_LEVEL)); $id = get_selected_tree_item_id($window); // db_edit_record($cat_table, $id, "name\nlevel", array($name, $level)); update_tree($window); update_cat_controls($window); break; case ID_DELETEITEM: $selected = get_selected_tree_item_index($window); // db_delete_records($cat_table, db_get_id($cat_table, $selected)); update_tree($window); update_cat_controls($window); break; case ID_MOVEUP: $selected = get_selected_tree_item_index($window); // db_swap_records($cat_table, db_get_id($cat_table, $selected), // db_get_id($cat_table, $selected - 1)); update_tree($window); update_cat_controls($window); break; case ID_MOVEDOWN: $selected = get_selected_tree_item_index($window); // db_swap_records($cat_table, db_get_id($cat_table, $selected), // db_get_id($cat_table, $selected + 1)); update_tree($window); update_cat_controls($window); break; case IDCANCEL: case IDCLOSE: case IDOK: wb_destroy_window($window); update_tree($mainwin); break; } }
function process_item($window, $id) { global $mainwin; switch ($id) { case IDOK: if (update_item($window)) { wb_destroy_window($window); update_items($mainwin); } break; case IDCANCEL: case IDCLOSE: wb_destroy_window($window); break; } }
function process_contact_category_search($window, $id, $ctrl) { global $wb; switch ($id) { case IDC_SEARCH_SUBMIT: $wb->current_page = 1; $wb->keyword = wb_get_text(wb_get_control($window, IDC_KEYWORD)); reset_contact_category_view(); wb_destroy_window($window); break; case IDCLOSE: // IDCLOSE is predefined // IDCLOSE is predefined case IDCANCEL: wb_destroy_window($window); break; } }
function process_agreement_edit($window, $id, $ctrl) { global $wb; switch ($id) { case IDC_UPDATE: $wb->current_action = 'update'; wb_set_enabled(wb_get_control($window, IDC_SAVE), true); wb_set_enabled(wb_get_control($window, IDC_UPDATE), false); break; case IDC_SAVE: inser_update_agreement($window); wb_destroy_window($window); break; case IDCANCEL: wb_destroy_window($window); break; } }
function process_classes($window, $id, $ctrl, $lparam1 = 0, $lparam2 = 0) { global $wb, $mainwin, $classes_table; switch ($id) { case IDCLOSE: $nclasses = count($wb->classes); for ($i = 0; $i < $nclasses; $i++) { $const = "IDC_" . strtoupper($wb->classes[$i][1]); $c = wb_get_control($wb->classdlg, constant($const)); } wb_destroy_window($window); wb_set_selected($wb->mainmenu, ID_TOOLBOX, false); $wb->classdlg = null; break; default: process_main($window, $id, $ctrl, $lparam1, $lparam2); break; } }
function process_main($window, $id) { // Try to load the multimedia dll $winmmlib = wb_load_library("winmm"); $mciSendString = wb_get_function_address("mciSendString", $winmmlib); static $file_filter = array(array("MP3 file", "*.mp3")); switch ($id) { case ID_OPEN: $filename = wb_sys_dlg_open($window, "Get It", $file_filter); if ($filename) { wb_call_function($mciSendString, array("open \"" . $filename . "\" type mpegvideo alias " . $filename, NULL, 0, 0)); } wb_call_function($mciSendString, array("play \"" . $filename . "\" from 0 notify", NULL, 0, 0)); break; case IDCLOSE: // IDCLOSE is predefined wb_destroy_window($window); break; } }
function process_setting($window, $id, $ctrl) { global $wb; switch ($id) { case IDOK: $wb->setting["Settings"]["db_host"] = wb_get_text(wb_get_control($window, IDC_DB_HOST)); $wb->setting["Settings"]["db_username"] = wb_get_text(wb_get_control($window, IDC_DB_USERNAME)); $wb->setting["Settings"]["db_password"] = wb_get_text(wb_get_control($window, IDC_DB_PASSWORD)); $wb->setting["Settings"]["db_dbname"] = wb_get_text(wb_get_control($window, IDC_DB_NAME)); $current_lang = wb_get_text(wb_get_control($window, IDC_LANGUAGE)); include PATH_CONFIG . "common.php"; $lang_value = array_search($current_lang, $LangOption); // switch ($current_lang) // { // case 'english': // $lang_value='en'; // break; // case 'chinese': // $lang_value='zh-cn'; // break; // // } $wb->setting["Settings"]["lang_set"] = $lang_value; // include('include/wb_generic.inc.php'); // $contents = generate_ini($wb->setting, "; Store Setting INI file\r\n"); $contents = generates_ini($wb->setting, "; Store Setting INI file\r\n"); file_put_contents(PATH_INI . SEETING_DAT, $contents); wb_destroy_window($window); break; case IDCLOSE: // IDCLOSE is predefined // IDCLOSE is predefined case IDCANCEL: wb_destroy_window($window); break; } }
function process_review_edit($window, $id, $ctrl) { global $wb; switch ($id) { // case IDC_REVIEW_CAL_SELECT: // wb_set_visible (wb_get_control($window, IDC_REVIEW_CALENDAR), true); // break; // case IDC_REVIEW_CALENDAR: // $date = strftime("%Y-%m-%d %H:%M%:%S", wb_get_value($ctrl)); // wb_set_text(wb_get_control($window, IDC_REVIEW_REVIEWDATE), $date); //// wb_set_visible (wb_get_control($window, IDC_REVIEW_CALENDAR), false); // break; case IDC_UPDATE: $wb->current_action = 'update'; wb_set_enabled(wb_get_control($window, IDC_SAVE), true); wb_set_enabled(wb_get_control($window, IDC_UPDATE), false); break; case IDC_SAVE: if (!wb_get_text(wb_get_control($window, IDC_REVIEW_COMPANY))) { empty_message_box($window, $wb->vars["Lang"]["lang_please_fillup"] . $wb->vars["Lang"]["lang_company"]); wb_set_focus(wb_get_control($window, IDC_REVIEW_COMPANY)); } else { inser_update_review($window); wb_destroy_window($window); } break; case IDCANCEL: wb_destroy_window($window); break; } }
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; } }
function process_refundment_edit($window, $id, $ctrl) { global $wb; switch ($id) { case IDC_UPDATE: $wb->current_action = 'update'; wb_set_enabled(wb_get_control($window, IDC_SAVE), true); wb_set_enabled(wb_get_control($window, IDC_UPDATE), false); break; case IDC_SAVE: if (!wb_get_text(wb_get_control($window, IDC_REFUNDMENT_COMPANY))) { empty_message_box($window, $wb->vars["Lang"]["lang_please_fillup"] . $wb->vars["Lang"]["lang_company"]); wb_set_focus(wb_get_control($window, IDC_REFUNDMENT_COMPANY)); } else { inser_update_refundment($window); wb_destroy_window($window); } break; case IDCANCEL: wb_destroy_window($window); break; } }
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; } }
function process_form($window, $id, $ctrl, $lparam1 = 0, $lparam2 = 0) { global $wb; static $controls = array(); static $isMoving = false; static $xcuroff = 0; static $ycuroff = 0; static $ctrl_lastpos = null; switch ($id) { case IDDEFAULT: if ($lparam1 & WBC_RESIZE) { // Form was resized $size = wb_get_size($wb->formwin); $wb->form[$wb->currentform]->width = $size[0]; $wb->form[$wb->currentform]->height = $size[1]; update_control_data(); } elseif ($lparam1 & WBC_REDRAW) { // Redraw screen // Draw the form background and grid $buffer = $lparam2; $dim = wb_get_size($window, true); $winwidth = $dim[0]; $winheight = $dim[1]; draw_background($buffer, $winwidth, $winheight); // Draw all controls from the current form for ($i = 0; $i < $wb->form[$wb->currentform]->numcontrols; $i++) { $ct = $wb->form[$wb->currentform]->ct[$i]; if ($ct) { draw_control($buffer, $ct); } } // Draw a "ghost" if ($ctrl_lastpos && $wb->ghost) { draw_ghost($buffer, $ctrl_lastpos); } // Is there a control selected? if ($wb->form[$wb->currentform]->nselcontrol >= 0) { $ct = $wb->form[$wb->currentform]->ct[$wb->form[$wb->currentform]->nselcontrol]; if (!$isMoving) { draw_handles($buffer, "", $ct->left, $ct->top, $ct->width, $ct->height); } } else { break; } } elseif ($lparam1 & WBC_MOUSEUP) { // A button was released $ctrl_lastpos = null; $isMoving = false; $wb->mouseop = false; $xcuroff = 0; $ycuroff = 0; wb_refresh($window, true); SetMyCursor(IDC_ARROW); $wb->mousecpos = NOWHERE; } elseif ($lparam1 & WBC_LBUTTON) { // Left button is held down $wb->mouseop = true; $xleft = $lparam2 & 0xffff; $ytop = ($lparam2 & 4294901760.0) >> 16; // Left mouse button was pressed if ($lparam1 & WBC_MOUSEDOWN) { // Can't change the current control while resizing or moving a control if ($wb->mousecpos == NOWHERE || $wb->mousecpos == INCONTROL) { // If mouse cursor is clicked inside a control, select a new one. // Search in reverse order because we need the topmost control $wb->form[$wb->currentform]->nselcontrol = -1; // Start with no control selected $form = $wb->form[$wb->currentform]; // Auxiliary variable // This loop finds and selects a new control as current for ($i = $form->numcontrols - 1; $i >= 0; $i--) { $cttest = $form->ct[$i]; if ($xleft >= $cttest->left && $xleft <= $cttest->left + $cttest->width && $ytop >= $cttest->top && $ytop <= $cttest->top + $cttest->height) { $ctrl_lastpos = $form->ct[$i]; $wb->form[$wb->currentform]->nselcontrol = $i; break; } } // No control selected update_control_data(); } } // $ct (an auxiliary variable) is set to the currently selected control if ($wb->form[$wb->currentform]->nselcontrol >= 0) { $ct = $wb->form[$wb->currentform]->ct[$wb->form[$wb->currentform]->nselcontrol]; } // **** Below: resizes aren't considering cursor offset if ($wb->mousecpos == INCONTROL) { // Moving control $x = $lparam2 & 0xffff; $y = ($lparam2 & 4294901760.0) >> 16; if (!$isMoving) { $isMoving = true; $xcuroff = $x - $ct->left; $ycuroff = $y - $ct->top; } SetMyCursor(IDC_CROSS); // Is grid active? $wb->form[$wb->currentform]->ct[$wb->form[$wb->currentform]->nselcontrol]->left = $wb->grid ? (int) (max(4, $x - $xcuroff) / 5) * 5 : $x - $xcuroff; $wb->form[$wb->currentform]->ct[$wb->form[$wb->currentform]->nselcontrol]->top = $wb->grid ? (int) (max(4, $y - $ycuroff) / 5) * 5 : $y - $ycuroff; update_control_data(); wb_refresh($window, true); } elseif ($wb->mousecpos == INNHANDLE) { // Resizing control (North) $y = ($lparam2 & 4294901760.0) >> 16; // Is grid active? $y1 = $wb->grid ? (int) (max(4, $y - 0) / 5) * 5 : $y; SetMyCursor(IDC_SIZENS); $bottom = $ct->top + $ct->height; $newtop = $y1 + HANDLE_YOFFSET_5; $newheight = $bottom - $newtop; if ($newheight > 0) { $wb->form[$wb->currentform]->ct[$wb->form[$wb->currentform]->nselcontrol]->top = $newtop; $wb->form[$wb->currentform]->ct[$wb->form[$wb->currentform]->nselcontrol]->height = $newheight; } update_control_data(); wb_refresh($window, true); } elseif ($wb->mousecpos == INEHANDLE) { // Resizing control (East) $x = $lparam2 & 0xffff; // Is grid active? $x1 = $wb->grid ? (int) (max(4, $x - 0) / 5) * 5 : $x; SetMyCursor(IDC_SIZEWE); $wb->form[$wb->currentform]->ct[$wb->form[$wb->currentform]->nselcontrol]->width = max(1, $x1 - $ct->left); update_control_data(); wb_refresh($window, true); } elseif ($wb->mousecpos == INWHANDLE) { // Resizing control (West) $x = $lparam2 & 0xffff; // Is grid active? $x1 = $wb->grid ? (int) (max(4, $x - 0) / 5) * 5 : $x; SetMyCursor(IDC_SIZEWE); $right = $ct->left + $ct->width; $newleft = $x1 + HANDLE_XOFFSET_5; $newwidth = $right - $newleft; if ($newwidth > 0) { $wb->form[$wb->currentform]->ct[$wb->form[$wb->currentform]->nselcontrol]->left = $newleft; $wb->form[$wb->currentform]->ct[$wb->form[$wb->currentform]->nselcontrol]->width = $newwidth; } update_control_data(); wb_refresh($window, true); } elseif ($wb->mousecpos == INSHANDLE) { // Resizing control (South) $y = ($lparam2 & 4294901760.0) >> 16; // Is grid active? $y1 = $wb->grid ? (int) (max(4, $y - 0) / 5) * 5 : $y; SetMyCursor(IDC_SIZENS); $wb->form[$wb->currentform]->ct[$wb->form[$wb->currentform]->nselcontrol]->height = max(1, $y1 - $ct->top); update_control_data(); wb_refresh($window, true); } elseif ($wb->mousecpos == INNEHANDLE) { // Resizing control (Northeast) $x = $lparam2 & 0xffff; $y = ($lparam2 & 4294901760.0) >> 16; // Is grid active? $x1 = $wb->grid ? (int) (max(4, $x - 0) / 5) * 5 : $x; $y1 = $wb->grid ? (int) (max(4, $y - 0) / 5) * 5 : $y; SetMyCursor(IDC_SIZENESW); $wb->form[$wb->currentform]->ct[$wb->form[$wb->currentform]->nselcontrol]->width = max(1, $x1 - $ct->left); $bottom = $ct->top + $ct->height; $newtop = $y1 + HANDLE_YOFFSET_5; $newheight = $bottom - $newtop; if ($newheight > 0) { $wb->form[$wb->currentform]->ct[$wb->form[$wb->currentform]->nselcontrol]->top = $newtop; $wb->form[$wb->currentform]->ct[$wb->form[$wb->currentform]->nselcontrol]->height = $newheight; } update_control_data(); wb_refresh($window, true); } elseif ($wb->mousecpos == INSEHANDLE) { // Resizing control (Southeast) $x = $lparam2 & 0xffff; $y = ($lparam2 & 4294901760.0) >> 16; // Is grid active? $x1 = $wb->grid ? (int) (max(4, $x - 0) / 5) * 5 : $x; $y1 = $wb->grid ? (int) (max(4, $y - 0) / 5) * 5 : $y; SetMyCursor(IDC_SIZENWSE); $wb->form[$wb->currentform]->ct[$wb->form[$wb->currentform]->nselcontrol]->width = max(1, $x1 - $ct->left); $wb->form[$wb->currentform]->ct[$wb->form[$wb->currentform]->nselcontrol]->height = max(1, $y1 - $ct->top); update_control_data(); wb_refresh($window, true); } elseif ($wb->mousecpos == INNWHANDLE) { // Resizing control (Northwest) $x = $lparam2 & 0xffff; $y = ($lparam2 & 4294901760.0) >> 16; // Is grid active? $x1 = $wb->grid ? (int) (max(4, $x - 0) / 5) * 5 : $x; $y1 = $wb->grid ? (int) (max(4, $y - 0) / 5) * 5 : $y; SetMyCursor(IDC_SIZENWSE); $right = $ct->left + $ct->width; $newleft = $x1 + HANDLE_XOFFSET_5; $newwidth = $right - $newleft; if ($newwidth > 0) { $wb->form[$wb->currentform]->ct[$wb->form[$wb->currentform]->nselcontrol]->left = $newleft; $wb->form[$wb->currentform]->ct[$wb->form[$wb->currentform]->nselcontrol]->width = $newwidth; } $bottom = $ct->top + $ct->height; $newtop = $y1 + HANDLE_YOFFSET_5; $newheight = $bottom - $newtop; if ($newheight > 0) { $wb->form[$wb->currentform]->ct[$wb->form[$wb->currentform]->nselcontrol]->top = $newtop; $wb->form[$wb->currentform]->ct[$wb->form[$wb->currentform]->nselcontrol]->height = $newheight; } update_control_data(); wb_refresh($window, true); } elseif ($wb->mousecpos == INSWHANDLE) { // Resizing control (Southwest) $x = $lparam2 & 0xffff; $y = ($lparam2 & 4294901760.0) >> 16; // Is grid active? $x1 = $wb->grid ? (int) (max(4, $x - 0) / 5) * 5 : $x; $y1 = $wb->grid ? (int) (max(4, $y - 0) / 5) * 5 : $y; SetMyCursor(IDC_SIZENESW); $right = $ct->left + $ct->width; $newleft = $x1 + HANDLE_XOFFSET_5; $newwidth = $right - $newleft; if ($newwidth > 0) { $wb->form[$wb->currentform]->ct[$wb->form[$wb->currentform]->nselcontrol]->left = $newleft; $wb->form[$wb->currentform]->ct[$wb->form[$wb->currentform]->nselcontrol]->width = $newwidth; } $wb->form[$wb->currentform]->ct[$wb->form[$wb->currentform]->nselcontrol]->height = max(1, $y1 - $ct->top); update_control_data(); wb_refresh($window, true); } } elseif (!($lparam1 & (WBC_LBUTTON | WBC_RBUTTON))) { // No button pressed $xleft = $lparam2 & 0xffff; $ytop = ($lparam2 & 4294901760.0) >> 16; $form = $wb->form[$wb->currentform]; // Auxiliary variable if ($form->nselcontrol < 0) { $wb->mousecpos = NOWHERE; break; } $ct = $wb->form[$wb->currentform]->ct[$form->nselcontrol]; // Aux variable //-------------- Mouse position tests // Is mouse cursor inside the control area? if ($xleft >= $ct->left && $xleft <= $ct->left + $ct->width && $ytop >= $ct->top && $ytop <= $ct->top + $ct->height) { SetMyCursor(IDC_HAND); $wb->mousecpos = INCONTROL; break; // Test for North handle } else { if ($xleft >= $ct->left + ($ct->width - HANDLE_WIDTH) / 2 && $xleft <= $ct->left + ($ct->width + HANDLE_WIDTH) / 2 && $ytop >= $ct->top - HANDLE_YOFFSET && $ytop <= $ct->top - HANDLE_YOFFSET + HANDLE_HEIGHT) { SetMyCursor(IDC_SIZENS); $wb->mousecpos = INNHANDLE; break; // Test for East handle } else { if ($xleft >= $ct->left + $ct->width + HANDLE_XOFFSET - HANDLE_WIDTH && $xleft <= $ct->left + $ct->width + HANDLE_XOFFSET && $ytop >= $ct->top + ($ct->height - HANDLE_HEIGHT) / 2 && $ytop <= $ct->top + ($ct->height + HANDLE_HEIGHT) / 2) { SetMyCursor(IDC_SIZEWE); $wb->mousecpos = INEHANDLE; break; // Test for West handle } else { if ($xleft >= $ct->left - HANDLE_XOFFSET && $xleft <= $ct->left - HANDLE_XOFFSET + HANDLE_WIDTH && $ytop >= $ct->top + ($ct->height - HANDLE_HEIGHT) / 2 && $ytop <= $ct->top + ($ct->height + HANDLE_HEIGHT) / 2) { SetMyCursor(IDC_SIZEWE); $wb->mousecpos = INWHANDLE; break; // Test for South handle } else { if ($xleft >= $ct->left + ($ct->width - HANDLE_WIDTH) / 2 && $xleft <= $ct->left + ($ct->width + HANDLE_WIDTH) / 2 && $ytop >= $ct->top + $ct->height + HANDLE_YOFFSET - HANDLE_HEIGHT && $ytop <= $ct->top + $ct->height + HANDLE_YOFFSET) { SetMyCursor(IDC_SIZENS); $wb->mousecpos = INSHANDLE; break; // Test for Northeast handle } else { if ($xleft >= $ct->left + $ct->width + HANDLE_XOFFSET - HANDLE_WIDTH && $xleft <= $ct->left + $ct->width + HANDLE_XOFFSET && $ytop >= $ct->top - HANDLE_YOFFSET && $ytop <= $ct->top - HANDLE_YOFFSET + HANDLE_HEIGHT) { SetMyCursor(IDC_SIZENESW); $wb->mousecpos = INNEHANDLE; break; // Test for Shoutheast handle } else { if ($xleft >= $ct->left + $ct->width + HANDLE_XOFFSET - HANDLE_WIDTH && $xleft <= $ct->left + $ct->width + HANDLE_XOFFSET && $ytop >= $ct->top + $ct->height + HANDLE_YOFFSET - HANDLE_HEIGHT && $ytop <= $ct->top + $ct->height + HANDLE_YOFFSET) { SetMyCursor(IDC_SIZENWSE); $wb->mousecpos = INSEHANDLE; break; // Test for Northwest handle } else { if ($xleft >= $ct->left - HANDLE_XOFFSET && $xleft <= $ct->left - HANDLE_XOFFSET + HANDLE_WIDTH && $ytop >= $ct->top - HANDLE_YOFFSET && $ytop <= $ct->top - HANDLE_YOFFSET + HANDLE_HEIGHT) { SetMyCursor(IDC_SIZENWSE); $wb->mousecpos = INNWHANDLE; break; // Test for Shouthwest handle } else { if ($xleft >= $ct->left - HANDLE_XOFFSET && $xleft <= $ct->left - HANDLE_XOFFSET + HANDLE_WIDTH && $ytop >= $ct->top + $ct->height + HANDLE_YOFFSET - HANDLE_HEIGHT && $ytop <= $ct->top + $ct->height + HANDLE_YOFFSET) { SetMyCursor(IDC_SIZENESW); $wb->mousecpos = INSWHANDLE; break; } else { $wb->mousecpos = NOWHERE; } } } } } } } } } } break; case IDCLOSE: end_drawing_functions(); wb_destroy_window($window); break; } }
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; } }