⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mgwidget.cpp

📁 monqueror一个很具有参考价值的源玛
💻 CPP
📖 第 1 页 / 共 2 页
字号:
				WS_CHILD | WS_BORDER | ES_PASSWORD,				MG::g_nChildWndID++,				0, 0, 1, 1,				m_hWndParent, (DWORD)this);//	SetWindowAdditionalData (m_hWnd, (DWORD)this);}//------------------------ Static -------------------------------MGWidgetStatic::MGWidgetStatic(HWND hWndParent, RenderFormElement * renderer) : MGWidget(hWndParent, renderer){	initWindow();}MGWidgetStatic::~MGWidgetStatic(){}void MGWidgetStatic::clicked(){	m_renderer->slotClicked();}void MGWidgetStatic::initWindow(){	m_hWnd = ::CreateWindow ("static",				"",				WS_CHILD | SS_NOTIFY,				MG::g_nChildWndID++,				0, 0, 1, 1,				m_hWndParent, (DWORD)this);//	You can set additional data by passing it in CreateWindow.//	SetWindowAdditionalData (m_hWnd, (DWORD)this);}//-----------------------------------------------------------------------------------------------------------------ParentMGWidgetParent::MGWidgetParent(HWND hWndParent, RenderFormElement * renderer) : MGWidget(hWndParent, renderer){	initWindow();}MGWidgetParent::~MGWidgetParent(){	delete m_Edit;}void MGWidgetParent::clicked(){	m_renderer->slotClicked();}MGSize MGWidgetParent::sizeHint() const{	// TODO	return MGSize( 270, 25 );}int MGWidgetParent::ParentProc( HWND hWnd, int message, WPARAM wParam, LPARAM lParam ){	MGWidgetParent * obj = (MGWidgetParent*) GetWindowAdditionalData (hWnd);	assert( obj != 0 );	switch (message) {	case MSG_COMMAND:	{		int id = LOWORD(wParam);		if ( id ==  obj->m_ButtonID ) {			obj->m_renderer->slotClicked();		}		break;	}	case MSG_DESTROY:		DestroyAllControls (hWnd);		break;    	}	return DefaultControlProc (hWnd, message, wParam, lParam);}bool MGWidgetParent::createParentWnd( int x, int y, int w, int h, bool visible, HWND hParent ){	// must have a parent window	assert (hParent != 0);	static HCURSOR hCur = GetSystemCursor( 0 );	/* FIXME: Register this window class only once. */	static WNDCLASS wndClass1 = {0, 0, 0, 0,		hCur, COLOR_lightwhite, ParentProc, 0}; 	// unregistered 	if (wndClass1.spClassName == 0) 	{		wndClass1.spClassName = "yanclass";		if (!RegisterWindowClass (&wndClass1)) {			wndClass1.spClassName = 0;			return false;		}	}	m_hWnd = CreateWindowEx (wndClass1.spClassName, "yanwindow", 					WS_HSCROLL | WS_VSCROLL,					0, MG::g_nChildWndID++, x, y, w, h, 					hParent, (DWORD)this); 	/* FIXME: Do you really need the scroll bars? */	ShowScrollBar( m_hWnd, SB_HORZ, false );	ShowScrollBar( m_hWnd, SB_VERT, false );	return true;}void MGWidgetParent::initWindow(){	createParentWnd (0, 0, 260, 25, true, m_hWndParent);	m_Edit = new MGWidgetEdit (m_hWnd, m_renderer);	m_hEdit = m_Edit->getHwnd();	assert (m_Edit != 0 );	m_Edit->resize (150, 25);	m_Edit->moveWindow (0, 0);	m_hButton = ::CreateWindow ( "button",			"Browse...",			WS_CHILD,			(m_ButtonID = MG::g_nChildWndID++), 			155, 0, 50, 25,			m_hWnd, 0);}void MGWidgetParent::show(){	ShowWindow( getHwnd(), SW_SHOW );	ShowWindow( m_hEdit, SW_SHOW );	ShowWindow( m_hButton, SW_SHOW );}void MGWidgetParent::hide(){	ShowWindow( getHwnd(), SW_HIDE );	ShowWindow( m_hEdit, SW_HIDE );	ShowWindow( m_hButton, SW_HIDE );}//---------------------------- ComboBox ------------------------------MGWidgetComboBox::MGWidgetComboBox(HWND hWndParent, RenderFormElement * renderer) 			: MGWidget(hWndParent, renderer){	initWindow();}MGWidgetComboBox::~MGWidgetComboBox(){}int MGWidgetComboBox::ProcNotification (int code){	switch (code){		case MBN_SELECTED:{#if WIDGET_DEBUG			fprintf(stderr, "MBN_SELECTED\n");#endif			int index = SendMessage(m_hWnd, MBM_GETCURITEM, 0, 0);#if WIDGET_DEBUG			fprintf(stderr, ".................................index=%d\n", index);#endif			static_cast<RenderSelect *>(m_renderer) -> slotActivated(index);		}	}	return 0;}void MGWidgetComboBox::clicked(){}void MGWidgetComboBox::initWindow(){#if WIDGET_DEBUG	fprintf(stderr, "MGWidgetComboBox::initWindow\n");#endif        m_hWnd = CreateWindow ("menubutton", 				"Select", 				WS_CHILD , 				MG::g_nChildWndID++,				0, 0, 1, 1,				m_hWndParent, (DWORD) this); //	SetWindowAdditionalData( m_hWnd,(DWORD) this);}void MGWidgetComboBox::insertItem(const char* str, int index){#if WIDGET_DEBUG	fprintf(stderr, "MGWidgetComboBox::insertItem %s\n", str);#endif	    MENUBUTTONITEM mbi;	if (str == 0)		str = "";			mbi.text = str;	mbi.bmp = NULL;	mbi.data = 0;	SendMessage (m_hWnd, MBM_ADDITEM, (WPARAM)-1, (LPARAM) &mbi);	}void MGWidgetComboBox::clear(){	SendMessage (m_hWnd, MBM_RESETCTRL, 1, (LPARAM)0);	}int MGWidgetComboBox::currentItem(){	int nIndex = (WORD) SendMessage( m_hWnd, MBM_GETCURITEM, 0, 0L);	return nIndex;}void MGWidgetComboBox::setCurrentItem(int index){	SendMessage( m_hWnd, MBM_SETCURITEM, index, 0L);}//---------------------------- ListBox ------------------------------MGWidgetList::MGWidgetList(HWND hWndParent, RenderFormElement * renderer) : MGWidget(hWndParent, renderer){	initWindow();	m_size = MGSize(80, 0);}MGWidgetList::~MGWidgetList(){}int MGWidgetList::ProcNotification (int code){	switch (code) {	case MBN_SELECTED:	{#if WIDGET_DEBUG		fprintf(stderr, "MBN_SELECTED\n");#endif		int index = SendMessage (m_hWnd, MBM_GETCURITEM, 0, 0);#if WIDGET_DEBUG		fprintf(stderr, ".................................index=%d\n", index);#endif		static_cast<RenderSelect *>(m_renderer) -> slotActivated(index);	}	}	return 0;}void MGWidgetList::clicked(){}void MGWidgetList::initWindow(){#if WIDGET_DEBUG	fprintf(stderr, "MGWidgetList::initWindow\n");#endif        m_hWnd = CreateWindow ("listbox",				"List",				WS_CHILD | WS_BORDER | WS_VSCROLL | LBS_MULTIPLESEL,                                MG::g_nChildWndID++,				0, 0, 1, 1,				m_hWndParent, (DWORD) this);//	SetWindowAdditionalData( m_hWnd,(DWORD) this);}MGSize MGWidgetList::sizeHint() const{	return m_size;}void MGWidgetList::insertItem(const char* str, int index){#if WIDGET_DEBUG	fprintf(stderr, "MGWidgetList::insertItem %s\n", str);#endif	if (str == 0) str = "";	SendMessage (m_hWnd, LB_ADDSTRING, 0, (LPARAM) str);	m_size = MGSize( m_size.width(), m_size.height() + 16);}void MGWidgetList::clear(){	SendMessage (m_hWnd, LB_RESETCONTENT, 1, (LPARAM)0);	m_size = MGSize (80, 0);}bool MGWidgetList::isSelected( int index ){	WORD wSelect = (WORD)SendMessage( m_hWnd, LB_GETSEL, (WORD)index, 0L);	if (wSelect)		return true;	else		return false;}void MGWidgetList::setSelected( int index, bool bSet ){	if ( bSet )		SendMessage( m_hWnd, LB_SETSEL, 1, (WORD) index );	else		SendMessage( m_hWnd, LB_SETSEL, 0, (WORD) index );}//------------------------- TextArea ----------------------------MGWidgetTextArea::MGWidgetTextArea(HWND hWndParent, RenderFormElement * renderer) : MGWidget(hWndParent, renderer){	initWindow();}MGWidgetTextArea::~MGWidgetTextArea(){}int MGWidgetTextArea::ProcNotification(int code){#if WIDGET_DEBUG	fprintf(stderr, "MGWidgetTextArea::ProcNotification\n");	#endif	switch (code) {	case EN_CHANGE:	{			//static_cast<RenderTextArea *>(m_renderer) -> slotTextChanged();		break;	}	return code;	}	return 0;}void MGWidgetTextArea::initWindow(){#if WIDGET_DEBUG	fprintf(stderr, "MGWidgetTextArea::initWindow\n");#endif	m_hWnd = ::CreateWindow ("medit",				"DDD",				WS_CHILD | WS_BORDER | WS_VSCROLL | WS_HSCROLL,				MG::g_nChildWndID++,				0, 0, 1, 1,				m_hWndParent, (DWORD) this);//	SetWindowAdditionalData( m_hWnd,(DWORD) this);}MGSize MGWidgetTextArea::sizeHint() const{	return MGSize (250, 200);}QString MGWidgetTextArea::text(){	/* FIXME: Do not assume the buffer length by yourself. */#if 0	char buf [2048];		memset (buf, '\0', 2048);	GetWindowText(m_hWnd, buf, 2048);#else	// optimize by ymwei.	char buf [2049];		GetWindowText (m_hWnd, buf, 2048);	buf [2048] = '\0';#endif		return QString (buf);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -