Application and practice of software engineering in Shandong University -- WeaselUI

2021SC@SDUSC
This report continues with the previous one to continue to study and analyze the WeaselUI.h file.

#pragma once

#include <WeaselCommon.h>

namespace weasel
{

	enum ClientCapabilities
	{
		INLINE_PREEDIT_CAPABLE = 1,
	};

	class UIImpl;

	//
	// Input method interface class
	//
	class UI
	{
	public:
		UI() : pimpl_(0)
		{
		}

		virtual ~UI()
		{
			if (pimpl_)
				Destroy();
		}

		// Create input method interface
		bool Create(HWND parent);

		// Destroy interface
		void Destroy();
		
		// Interface explicit implicit
		void Show();
		void Hide();
		void ShowWithTimeout(DWORD millisec);
		bool IsCountingDown() const;
		bool IsShown() const;
		
		// Redraw interface
		void Refresh();

		// Set the input focus position (the cursor moves the candidate window at any time) but do not redraw
		void UpdateInputPosition(RECT const& rc);

		// Update interface display content
		void Update(Context const& ctx, Status const& status);

		Context& ctx() { return ctx_; } 
		Status& status() { return status_; } 
		UIStyle& style() { return style_; }

	private:
		UIImpl* pimpl_;

		Context ctx_;
		Status status_;
		UIStyle style_;
	};

}

WeaselUI.h refers to < weaselcommon. H > as the header file, and the endpoint defines the input method interface class.

MPL (Mozilla Public License) is a software license designed by the Mozilla team of Netscape for its open source software project in early 1998. The most important reason for the emergence of MPL license is that Netscape believes that GPL license does not well balance the needs of developers for source code and the benefits they obtain from using source code.
Compared with the famous GPL licenses and BSD licenses, MPL has the same rights and obligations as them (because they are open source software licenses recognized by OSI). However, MPL has the following significant differences:
Although MPL requires that the modification of the source code released under the MPL license should also be re licensed in the form of MPL license, so as to ensure that other people can share the source code under the terms of MPL. However, in the MPL license, the definition of "publish" is "files published in source code", which means that MPL allows an enterprise to add an interface to its existing source code base. Except that the source code of the interface program is licensed in the form of MPL license, the source code in the source code base can be licensed without MPL license. These leave a gap for learning from other people's source code for their own commercial software development.
Paragraph 7 of Article 3 of the MPL license allows the licensee to mix the source code obtained through the MPL license with its own other types of code to obtain its own software program.
As for the attitude towards software patents, MPL license does not explicitly oppose software patents like GPL license, but clearly requires that the source code provider cannot provide the source code that has been protected by patents (unless he is the patentee and licenses these source codes to the public free of charge), Nor can they apply for patents related to these source codes after they are licensed in the form of open source license.
Definition of source code. In the MPL (version 1.1) license, the definition of source code is: "source code refers to the most preferred form for modifying works. It includes: all source programs of all modules, plus the definition of relevant interfaces, plus the 'original' (originally 'Script') that controls the installation and compilation of executable works Or either the source code that is significantly different from the original source code or the program code available from the public domain selected by the source code contributor. "
Article 3 of the MPL license has a special provision on the description of source code modification, which requires all redistributors to have a special document to describe the time and method of source code program modification.

UI classes mainly define some common methods and private variables.

private:
		UIImpl* pimpl_;

		Context ctx_;
		Status status_;
		UIStyle style_;

About interface design, there are methods to create input method interface

// Create input method interface
bool Create(HWND parent);

Destroy interface method

// Destroy interface
void Destroy();
Method for determining whether the interface is displayed or hidden The Hide() method represents the hidden interface, the ShowWithTimeout (DWORD millisec) method represents the timeout of the display interface, the iscoundingdown() method represents the process of counting down to 0 or the specified time, and the isshow() method represents the interface display method.
void Show();
		void Hide();
		void ShowWithTimeout(DWORD millisec);
		bool IsCountingDown() const;
		bool IsShown() const;

Redrawing interface method

// Redraw interface
void Refresh();
Method of placing input focus without redrawing Set the input focus position, and the cursor moves the candidate window at any time, but does not redraw
void UpdateInputPosition(RECT const& rc);

Method of updating interface display content

void Update(Context const& ctx, Status const& status);
Context& ctx() { return ctx_; } 
Status& status() { return status_; } 
UIStyle& style() { return style_; }

Tags: C++

Posted on Sun, 31 Oct 2021 19:06:16 -0400 by dkoolgeek