A summary of the thought of Scw-app body based on Directui

Source: Internet
Author: User

A summary of the thought of Scw-app body based on Directui

The idea and implementation of the SC Directui interface library based on C + + has been nearly half a month today. Some new ideas and ideas have been improved in learning and practice. Overturn again, repeat again dry, although is a piece of hard work, but, have to for it. This will improve.

Previous article: The personal conception and goal of SC design planning based on Directui


When you design SCW, you summarize the components of the program:

  1. Global: Data members, object members, and so on that are unique in the hypervisor.

  2. Desktop: Some parameters or features related to the system desktop. such as the screen size of the desktop, mouse shape and so on.

  3. window: Responsible for registering windows, creating, displaying, destroying windows, and other window-related functions.

  4. Event: Message processing under Windows systems. This includes starting the message loop, filtering, distributing, and so on.

  5. Drawing: implements drawing output to a window or printer. complete with support libraries such as GDI + or DIRECT2D. Responsible for the basic elements of the interface function implementation.

  6. components: A series of controls that make up the window interface and event handling. such as Label, Button, Edit and so on.

  7. Resources: Unified management and distribution programs in the picture, text, fonts and other resources. Including the implementation of interface themes, multi-lingual and other factors.

  8. Function: The function task that the program ultimately wants to complete.

On the basis of the above summary, complete When the SCW control class CWinApp . Two sets of programmes were planned.

  1. under consideration of cross-platform, refer to the Firemonkey iwindowservice, message iapplicationservice< Span style= "FONT-SIZE:14PX; Font-family: the song body; >, drawing ccanvas Three the code of the Body class part. The main control class Cwinapp inherit Windowservice, Iapplicationservice

  2. later because want to speed up, regardless of the non-cross-platform, want to focus on the realization the directui interface Library under Windows. Redesigned the CWinApp. To simplify the idea, the original code is all assembled to a CWinApp . Only the drawing section is detached. The base code for these three sections is also completed.

But today, when reviewing the framework, there are drawbacks to both of these designs:

  1. The feature is too concentrated. In a CWinApp class, Windows, messaging, and resource management functions are implemented. While these features are a task that an app should complete, it's focused on an app. It's not a good idea. Although the first scenario above has the ability to break down functionality into different interface classes, the inheritance is derived in a way that is aggregated onto a CWinApp . Although the idea of Firemonkey is good, but this kind of aggregation function, still inconvenient.

  2. The ability to focus too much also causes the code to be centralized. When you test and update your code. It takes a bunch of process functions to find each one, and navigate to the function code block. For the future maintenance and improvement is not a good thing.

  3. encapsulation is not flexible, especially the second scenario, although the idea is simplified, just want a APP class to solve all problems. But it also makes the APP function module bloated. Extensibility is also inconvenient and flexible. Although inheritance and rewriting can be extended, they are error-prone and require a lot of virtual processes to achieve the purpose of inheritance. The first is a second strong point, which can be implemented across platforms by overwriting the interface class (Firemonkey is implemented in this way), and extensibility is still a problem because it derives from inheriting interface classes.

summarize the above questions, add yourself in the heap code, learn C + + is constantly in- depth, the framework has a new understanding and more convenient solution. so sort out the frame from the new design Scw–app part.

class to manage these functional classes. The idea is as follows:

    1. cglobal entity , and CAPP

    2. capp ET. The virtual creation process can inherit overrides. Easy to expand.

    3. capp

scw- main structure planning is as follows:

  1. Global Class Cglobal

    Register
    the CAPP class. Other objects can access the implementation of the current CAPP through this global class , and implement related functions.

    Manage globally unique objects. such as desktop, mouse, current activation window, set point control and so on.
    The setting of the global parameter. such as font, interface theme, language and so on.

    The Global class
    Cglobal is a static object entity that is generated when the program is run.

  2. main control class CWinApp

    Dynamically generated by the program, extensible. When created, the entity pointer is registered directly into
    cglobal .

    Basically complete the basic functions related to the program.
    Responsible for managing and generating other functional classes. You can inherit the rewrite build process, which enables you to add a new feature control class or register a new feature control derived class. Greatly improved scalability.
    Responsible for registering the drawing engine. Can inherit overrides, can register different drawing engine.

  3. Desktop Class Cscreen
    Can be extended and
    generated dynamically by CAPP. Provides parameter settings and function functions related to the system desktop.

  4. Message Processing Classes Cmsgcontroller

    Can be extended and
    generated dynamically by CAPP. Provides functions such as message looping, processing, derivation, and so on. It is the core middleware of window and window control to realize interface refresh and operation response.

  5. window Control class Cwndmanager

    Can be extended and
    generated dynamically by CAPP. Provide window registration, creation, destruction and other functions.

  6. Drawing engine Classes CCanvas

    Extensible and is registered by the
    CApp . A drawing entity is generated by a specific window. Provides the basic functions of window and control interface drawing. is the core middleware of Directui interface implementation.

  7. Component Classes CObject

    Derive and produce various interface components and functional components. is
    The core middleware to realize the Directui concept.

  8. Other

    Is the other, just the other. Thought of, needed the function.

from the original plan design and want to complete SCW 's directui Interface Library to the present. I spent a lot of time on the program framework and the underlying code, repeatedly, and constantly revising. The goal is to study, while practicing, and summing up. In the case of ensuring that the basic framework is more scientific and ideal, efforts are made to improve their own ideas and experience in practice, then continue to explore their own abilities. Although the framework has been rewritten and reconstructed many times, it seems that the complex labor. But every time there is improvement. A person, though no one has the benefit of brainstorming more. But it can be so capricious.

start with a little more time, or even overturn again, several times. This can guarantee the foundation of solid, so as to improve their own. Not satisfied with the high requirements, is the basis for doing any one thing. This summary is not an estimate of the last time. All said the code bitter, now finally realized. Pain is not the hard to knock on the keyboard, but, always have better, never satisfied. This is also: bitter, and happy. It's right to be interested.

Posted, it is hoped that the conscientious will provide more help.

Interested friends can also add Q or group to communicate:

QQ Group: 177,312,461 person qq:48018276


A summary of the thought of Scw-app body based on Directui

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.