static regrow *make_regrow(GtkWidget *ww, GtkSignalFunc play_callback, GtkSignalFunc name_callback) { regrow *r; r = (regrow *)CALLOC(1, sizeof(regrow)); /* assume "ww" is a vbox widget in this case */ r->rw = gtk_hbox_new(false, 0); gtk_box_pack_start(GTK_BOX(ww), r->rw, false, false, 0); gtk_widget_modify_bg(r->rw, GTK_STATE_NORMAL, ss->sgx->highlight_color); gtk_widget_modify_base(r->rw, GTK_STATE_NORMAL, ss->sgx->highlight_color); gtk_widget_show(r->rw); r->pl = gtk_check_button_new(); gtk_box_pack_start(GTK_BOX(r->rw), r->pl, false, false, 2); SG_SIGNAL_CONNECT(r->pl, "toggled", play_callback, r); gtk_widget_show(r->pl); r->nm = gtk_button_new_with_label(""); sg_left_justify_button(r->nm); gtk_box_pack_start(GTK_BOX(r->rw), r->nm, true, true, 2); SG_SIGNAL_CONNECT(r->nm, "clicked", name_callback, r); SG_SIGNAL_CONNECT(r->nm, "enter_notify_event", regrow_mouse_enter_label, r); SG_SIGNAL_CONNECT(r->nm, "leave_notify_event", regrow_mouse_leave_label, r); set_user_data(G_OBJECT(r->nm), (gpointer)r); gtk_widget_modify_bg(r->nm, GTK_STATE_NORMAL, ss->sgx->highlight_color); gtk_widget_modify_base(r->nm, GTK_STATE_NORMAL, ss->sgx->highlight_color); gtk_widget_show(r->nm); return(r); }
/*** TimedCallback ***/ TimedCallback::TimedCallback(CallBack *t, void *d, uint32 wait_time, bool repeat) : TimedEvent(wait_time, TIMER_DELAYED, TIMER_REALTIME) { set_target(t); set_user_data(d); repeat_count = repeat ? -1 : 0; queue(); // start }
//---------------------------------------------------------------------------------------------------------------------- // PROC -- MODAL //---------------------------------------------------------------------------------------------------------------------- INT_PTR CALLBACK cDlgModal::dialog_proc (HWND hDlg, UINT uMessage, WPARAM wParam, LPARAM lParam) { cWin * pWin = user_data_to_pWin ( hDlg ); cDlgModal * pThis = static_cast<cDlgModal*>(pWin); switch ( uMessage ) { case WM_MOUSEMOVE: pThis->wm_mousemove(); break; case WM_LBUTTONDOWN: case WM_RBUTTONDOWN: pThis->cWin::wm_buttondown(); break; case WM_INITDIALOG: { set_user_data ( hDlg, lParam ); cWin * pWin = lParam_to_pWin ( hDlg, lParam ); pThis = static_cast<cDlgModal*>(pWin); HICON hIcon = (HICON)LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE ( IDI_mojo ), IMAGE_ICON, 16, 16, 0); SendMessage ( pThis->hwnd, WM_SETICON, ICON_BIG, (LPARAM) hIcon ) ; } return (INT_PTR)TRUE; case WM_SIZE: if ( pThis ) pThis->cWin::wm_size ( LOWORD(lParam), HIWORD(lParam) ); break; case WM_MOVE: if ( pThis ) pThis->cWin::wm_move ( LOWORD(lParam), HIWORD(lParam) ); break; case WM_COMMAND: { switch ( LOWORD ( wParam ) ) // iID { case ID_OK: case ID_CANCEL: case IDOK: case IDCANCEL: EndDialog(hDlg, LOWORD(wParam)); return (INT_PTR)TRUE; } } break; } return (INT_PTR)FALSE; }
//---------------------------------------------------------------------------------------------------------------------- // DEFAULT DIALOG PROC //---------------------------------------------------------------------------------------------------------------------- INT_PTR CALLBACK cDlg::dialog_proc ( HWND hDlg, UINT uMessage, WPARAM wParam, LPARAM lParam ) { cWin * pWin = user_data_to_pWin ( hDlg ); cDlg * pThis = static_cast<cDlg*>(pWin); switch ( uMessage ) { case WM_MOUSEMOVE: pThis->wm_mousemove(); break; case WM_LBUTTONDOWN: case WM_RBUTTONDOWN: pThis->cWin::wm_buttondown(); break; case WM_SIZE: if ( pThis ) pThis->cWin::wm_size ( LOWORD(lParam), HIWORD(lParam) ); break; case WM_INITDIALOG: { set_user_data ( hDlg, lParam ); cWin * pWin = lParam_to_pWin ( hDlg, lParam ); pThis = static_cast<cDlg*>(pWin); HICON hIcon = (HICON)LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE ( IDI_mojo ), IMAGE_ICON, 16, 16, 0); SendMessage ( pThis->hwnd, WM_SETICON, ICON_BIG, (LPARAM) hIcon ) ; } return (INT_PTR)TRUE; case WM_COMMAND: { int iID = LOWORD(wParam); int iEvent = HIWORD(wParam); iEvent; if ( iID == ID_OK || iID == ID_CANCEL || iID == ID_CANCEL || iID == ID_ACCEPT ) { DestroyWindow ( hDlg ); pThis->hwnd = 0; ///////////// DO THIS HERE IN BASE CLASS, NOT IN DERIVED CLASSES return (INT_PTR)TRUE; } } break; } return (INT_PTR)FALSE; }
int test_open(talk_handle_t *hdl, const char* device, const int channel, media_info_t *info) { //return -1; int ret; pthread_t thid; int *fd = (int *)calloc(1, sizeof(int)*8); printf("@@@@@ test_open hdl: %p device: %s channel: %d encode_type: %d@@@@@\n", hdl, device, channel, info->attr.encode_type); *(fd + 3) = open_file(FILE_PATH); if (*(fd + 3) < 0) { printf("fail to open file errno:%d\n", *(fd + 3)); return -1; } *(fd + 1) = (int *)hdl; *(fd + 2) = (int *)0x1; // thread runing flag *(fd + 4) = 0; /* frame_no */ set_user_data(hdl, (void *)fd); talk_handle_ref(hdl); ret = pthread_create(&thid, NULL, &send_thread, (void *)fd); if (ret) { talk_handle_unref(hdl); printf("fail to create pthread errno:%d\n", ret); return -1; } else {//@不能在这里给线程的参数赋值,因为线程有时直接就启动了,这时不没有来得及赋值 *(fd + 0) = (int *)thid; printf("succeed to create thread id:%p arg:%p\n", thid, fd); } return 0; }
//---------------------------------------------------------------------------------------------------------------------- // DEFAULT PROC //---------------------------------------------------------------------------------------------------------------------- INT_PTR CALLBACK cDlgToons::dialog_proc (HWND hwnd, UINT uMessage, WPARAM wParam, LPARAM lParam) { cWin * pWin = user_data_to_pWin ( hwnd ); cDlgToons * pThis = static_cast<cDlgToons*>(pWin); switch ( uMessage ) { case WM_PAINT: pThis->wm_paint(); break; case uWM_TOON_LIST_CHANGED: { #if 0 cToonList tl ( g_Config.ToonList ); pThis->ListView.populate ( &tl ); #endif } break; case WM_INITDIALOG: { set_user_data ( hwnd, lParam ); cWin * pWin = lParam_to_pWin ( hwnd, lParam ); pThis = static_cast<cDlgToons*>(pWin); pThis->hwnd = hwnd; pThis->wm_init (); } break; #if 0 case WM_NOTIFY: if ( pThis ) { NMHDR * pN = (NMHDR*)lParam; if ( pN->code == NM_RCLICK ) { DWORD dwHandle = pThis->ListView.hot_item(); if ( (DWORD)-1 != dwHandle ) { #if 0 cMach m; if ( mojo::get_mach ( &m, dwHandle ) ) { cStrW s; s.f ( L"You right-clicked a computer.\n\nHandle = %d.\nName = %s\n", dwHandle, m.sName.cstr() ); message_box ( s.cstr() ); // do_pc_context_menu ( hwnd, pM ); } #endif } } } break; #endif default: break; } return cDlgModal::dialog_proc ( hwnd, uMessage, wParam, lParam ); }
//---------------------------------------------------------------------------------------------------------------------- // DEFAULT PROC //---------------------------------------------------------------------------------------------------------------------- INT_PTR CALLBACK cDlgFigPredefinedHotkeys::dialog_proc (HWND hwnd, UINT uMessage, WPARAM wParam, LPARAM lParam) { cWin * pWin = user_data_to_pWin ( hwnd ); cDlgFigPredefinedHotkeys * pThis = static_cast<cDlgFigPredefinedHotkeys*>(pWin); switch ( uMessage ) { case WM_INITDIALOG: { set_user_data ( hwnd, lParam ); cWin * pWin = lParam_to_pWin ( hwnd, lParam ); pThis = static_cast<cDlgFigPredefinedHotkeys*>(pWin); pThis->hwnd = hwnd; pThis->wm_init(); } break; case WM_CTLCOLORSTATIC: { wchar_t awName [2000]; GetClassName ( (HWND)lParam, awName, sizeof(awName)/sizeof(wchar_t ) ); if ( 0 == wcscmp ( L"Edit", awName ) ) { LONG_PTR Style = GetWindowLongPtr ( (HWND)lParam, GWL_STYLE ); if ( 0 == ( WS_DISABLED & Style ) ) return (INT_PTR) GetStockObject ( WHITE_BRUSH ); } } break; case WM_COMMAND: switch ( LOWORD ( wParam ) ) { case ID_TOGGLE_MOJO_BUTTON: case ID_TOGGLE_WINDOW_BROADCAST_BUTTON: case ID_TOGGLE_COMPUTER_BROADCAST_BUTTON: case ID_TOGGLE_MOUSEOVER_BUTTON: case ID_TOGGLE_HOTKEYS_BUTTON: case ID_BRING_MOUSEOVER_CURSOR_HOME_BUTTON: case ID_HIDE_SHOW_MOJO_BUTTON: pThis->on_button ( LOWORD(wParam) ); break; case ID_CANCEL: case IDCANCEL: break; case ID_OK: case IDOK: pThis->VarsFig.dlg_to_vars(); g_FigMgr.set_fig ( pThis->VarsFig.pFigOriginal->dwSerialNumber, (cFigWoW*)pThis->VarsFig.pFigCopy ); g_FigMgr.save_to_file(); pThis->pFigOriginal->set_engine(); break; } break; case WM_NOTIFY: { switch( wParam ) { case ID_LINK: switch ( ((LPNMHDR)lParam)->code ) { case NM_CLICK: case NM_RETURN: { wchar_t * pURL = PNMLINK(lParam)->item.szUrl; ShellExecute ( NULL, L"open", pURL, NULL, NULL, SW_SHOW ); } break; } break; } } break; default: break; } return cDlgModal::dialog_proc ( hwnd, uMessage, wParam, lParam ); }
//---------------------------------------------------------------------------------------------------------------------- // DEFAULT PROC //---------------------------------------------------------------------------------------------------------------------- INT_PTR CALLBACK cDlgSetTrigger::dialog_proc (HWND hwnd, UINT uMessage, WPARAM wParam, LPARAM lParam) { cWin * pWin = user_data_to_pWin ( hwnd ); cDlgSetTrigger * pThis = static_cast<cDlgSetTrigger*>(pWin); switch ( uMessage ) { case WM_SIZE: if ( pThis ) { pThis->cWin::wm_size ( LOWORD(lParam), HIWORD(lParam) ); InvalidateRect ( hwnd, NULL, FALSE ); UpdateWindow ( hwnd ); return ( INT_PTR ) TRUE; } break; case WM_CTLCOLORSTATIC: if ( lParam == (long) GetDlgItem ( hwnd, ID_HEAD ) ) { HDC hdc = (HDC)wParam; SetTextColor ( hdc, RGB ( 90, 104, 170 ) ); SetBkMode(hdc, TRANSPARENT ); SetDCBrushColor ( hdc, GetSysColor ( COLOR_BTNFACE ) ); return (LONG) GetStockObject ( DC_BRUSH ); } break; case mojo::uWM_KEY_EVENT_OCCURRED: pThis->wm_key_event((WORD)wParam); // wExVK ); break; case WM_INITDIALOG: { set_user_data ( hwnd, lParam ); cWin * pWin = lParam_to_pWin ( hwnd, lParam ); pThis = static_cast<cDlgSetTrigger*>(pWin); pThis->hwnd = hwnd; pThis->wm_init (); } break; case WM_COMMAND: { if ( CBN_SETFOCUS == HIWORD ( wParam ) ) { HWND hwndCombo = (HWND) lParam; cDlgSetTrigger::cComboWin * pCombo = pThis->get_combo_from_combo_hwnd ( hwndCombo ); hwndCombo, pCombo; } if ( CBN_SELCHANGE == HIWORD ( wParam ) ) { pThis->on_combo_changed ( ( HWND ) lParam ); break; } int iID = LOWORD ( wParam ); switch ( iID ) { case ID_CLEAR: pThis->on_clear (); break; case IDCANCEL: mojo::unregister_for_key_events ( hwnd ); break; case IDOK: { cStrW s; pThis->vars_to_string ( &s ); if ( 0 == s.len() ) pThis->Trigger.clear(); else if ( ! pThis->init_trigger ( s.cstr() ) ) return ( INT_PTR ) TRUE; else { mojo::unregister_for_key_events ( hwnd ); *((mojo::cTrigger*)pThis->pUserData ) = pThis->Trigger; //------------------------------------ // TEMP FOR TESTING //------------------------------------ #if 0 cStrW s, t; pThis->Trigger.print ( &t ); s.f ( L"For testing purposes, Mojo has stored your trigger " L"in an internal format and then converted it from that " L"format into something humans can read. Here's the result " L"of that process:\n\n" L" %s\n\n" L"If that's not what you entered, please let Freddie know.\n\n" L"It doesn't matter if Mojo changes the order as long as the " L"last key stays at the end. The last key is special since it's " L"the real trigger. The other keys are preconditions.\n\n" L"Thanks a lot.", t.cstr() ); MessageBox ( hwnd, s.cstr(), g_awAppTitle, MB_OK ); #endif } } break; case ID_NUMLOCK_ON: case ID_NUMLOCK_OFF: case ID_CAPSLOCK_ON: case ID_CAPSLOCK_OFF: case ID_SCROLLLOCK_ON: case ID_SCROLLLOCK_OFF: pThis->set_state ( iID ); break; } } break; case WM_NOTIFY: { switch( wParam ) { case ID_LINK: switch ( ((LPNMHDR)lParam)->code ) { case NM_CLICK: case NM_RETURN: { wchar_t * pURL = PNMLINK(lParam)->item.szUrl; ShellExecute ( NULL, L"open", pURL, NULL, NULL, SW_SHOW ); } break; } break; } } break; default: break; } return cDlgModal::dialog_proc ( hwnd, uMessage, wParam, lParam ); }
//---------------------------------------------------------------------------------------------------------------------- // DEFAULT PROC //---------------------------------------------------------------------------------------------------------------------- INT_PTR CALLBACK cDlgView::dialog_proc (HWND hwnd, UINT uMessage, WPARAM wParam, LPARAM lParam) { cWin * pWin = user_data_to_pWin ( hwnd ); cDlgView * pThis = static_cast<cDlgView*>(pWin); switch ( uMessage ) { case WM_COMMAND: switch ( LOWORD ( wParam ) ) { case ID_TOGGLE_VIEW: pThis->toggle_view (); break; } #if 0 case WM_ERASEBKGND: return TRUE; #endif case WM_PAINT: pThis->wm_paint(); break; #if 0 case uWM_TOON_LIST_CHANGED: { #if 0 // cToonList tl ( g_Config.ToonList ); pThis->pListView->populate ( &g_Config ); #endif } break; #endif case WM_INITDIALOG: { set_user_data ( hwnd, lParam ); cWin * pWin = lParam_to_pWin ( hwnd, lParam ); pThis = static_cast<cDlgView*>(pWin); pThis->hwnd = hwnd; pThis->wm_init (); } break; case WM_NOTIFY: if ( pThis ) { NMHDR * pN = (NMHDR*)lParam; if ( pN->code == NM_RCLICK ) { DWORD dwHandle = pThis->pListView->hot_item(); if ( (DWORD)-1 != dwHandle ) { cConfigItem * p = pThis->pListView->pList->get_item_clone ( dwHandle ); if ( p ) { int iCommand = p->do_context_menu ( hwnd ); switch ( iCommand ) { case ID_LAUNCH: message_box ( L"Sorry, Mojo can't launch programs yet." ); break; case ID_PROPERTIES: { cDlgPropWoW d; d.make_dlg ( p ); } break; default: break; } delete p; } } } } break; default: break; } return cDlg::dialog_proc ( hwnd, uMessage, wParam, lParam ); }
//---------------------------------------------------------------------------------------------------------------------- // DEFAULT PROC //---------------------------------------------------------------------------------------------------------------------- INT_PTR CALLBACK cDlgModeStrip::dialog_proc (HWND hwnd, UINT uMessage, WPARAM wParam, LPARAM lParam) { cWin * pWin = user_data_to_pWin ( hwnd ); cDlgModeStrip * pThis = static_cast<cDlgModeStrip*>(pWin); switch ( uMessage ) { case WM_COMMAND: { if ( BN_CLICKED == HIWORD ( wParam ) ) { switch ( LOWORD ( wParam ) ) { case ID_TOGGLE_MOUSEOVER: PostMessage ( g_hwnd, WM_COMMAND, ID_TOGGLE_MOUSEOVER, ID_TOGGLE_MOUSEOVER ); break; case ID_TOGGLE_HOTKEYS: pThis->cWin::balloon ( GetDlgItem ( hwnd, ID_TOGGLE_HOTKEYS ), L"Sorry.", L"Hotkeys aren't implemented yet." ); break; case ID_TOGGLE_WINDOW_BROADCAST: PostMessage ( g_hwnd, WM_COMMAND, ID_TOGGLE_WINDOW_BROADCAST, ID_TOGGLE_WINDOW_BROADCAST ); break; case ID_TOGGLE_COMPUTER_BROADCAST: pThis->cWin::balloon ( GetDlgItem ( hwnd, ID_TOGGLE_COMPUTER_BROADCAST ), L"Sorry.", L"Computer broadcast isn't implemented yet." ); break; case ID_VIEW_MONITOR: PostMessage ( g_hwnd, WM_COMMAND, ID_VIEW_MONITOR, 0 ); break; case ID_VIEW_WOWS: PostMessage ( g_hwnd, WM_COMMAND, ID_VIEW_WOWS, 0 ); break; } } } break; case WM_DRAWITEM: if ( pThis ) pThis->wm_drawitem ( (int) wParam, (DRAWITEMSTRUCT*) lParam ); break; case WM_INITDIALOG: { set_user_data ( hwnd, lParam ); cWin * pWin = lParam_to_pWin ( hwnd, lParam ); pThis = static_cast<cDlgModeStrip*>(pWin); pThis->hwnd = hwnd; pThis->wm_init (); } break; default: break; } return cDlgModal::dialog_proc ( hwnd, uMessage, wParam, lParam ); }