コード例 #1
0
void EditorBase::Init()
{
    mWorldManager->Init();

    InitTools();

    LoadWorkspace();

    mLastTime = SystemInfo::Instance()->GetSeconds();

    QTimer* refreshTimer = new QTimer( this );
    connect( refreshTimer, SIGNAL(timeout()), SLOT(OnTick()) );
    refreshTimer->start( 1000 / 30 );    
}
コード例 #2
0
/*
 * imgEditInit - initialization
 */
static BOOL imgEditInit( HANDLE currinst, HANDLE previnst, int cmdshow )
{
    WNDCLASS    wc;
    HMENU       menu;
    HDC         hdc;
    BOOL        maximized;
    int         show_state;

    hdc = GetDC( NULL );
    ColorPlanes = GetDeviceCaps( hdc, PLANES );
    BitsPerPixel = GetDeviceCaps( hdc, BITSPIXEL );
    ReleaseDC( NULL, hdc );

    Instance = currinst;
    IEInitErrors( currinst );
    IEInitGlobalStrings();

    if( ImgedIsDDE ) {
        menu = LoadMenu( Instance, "IMGEDDDEMENU" );
    } else {
        menu = LoadMenu( Instance, "IMGEDMENU" );
    }

    hBitmapIcon = LoadIcon( Instance, "BitmapIcon" );
    hIconIcon = LoadIcon( Instance, "IconIcon" );
    hCursorIcon = LoadIcon( Instance, "CursorIcon" );
    hAccel = LoadAccelerators( Instance, "Accelerators" );

    IECtl3dInit( Instance );

#if defined( __NT__ )
    hBkBrush = CreateSolidBrush( GetSysColor( COLOR_BTNFACE ) );
#endif

    /*
     * set up window class
     */
    if( !previnst ) {
        wc.style = 0L;
        wc.lpfnWndProc = ImgEdFrameProc;
        wc.cbClsExtra = 0;
        wc.cbWndExtra = 0;
        wc.hInstance = Instance;
        wc.hIcon = LoadIcon( Instance, "APPLICON" );
        wc.hCursor = LoadCursor( (HANDLE)NULL, IDC_ARROW );
        wc.hbrBackground = NULL;
        wc.lpszMenuName = NULL;
        wc.lpszClassName = className;
        if( !RegisterClass( &wc ) ) {
            return( FALSE );
        }
    }

    /*
     * This is the child of the MDI frame window (of it's client window actually).
     */
    if( !previnst ) {
        wc.style = CS_BYTEALIGNWINDOW | CS_CLASSDC | CS_DBLCLKS;
        wc.lpfnWndProc = DrawAreaWinProc;
        wc.cbClsExtra = sizeof( HCURSOR );
        wc.cbWndExtra = 0;
        wc.hInstance = Instance;
        wc.hIcon = hBitmapIcon;
        wc.hCursor = LoadCursor( (HANDLE)NULL, IDC_ARROW );
        wc.hbrBackground = (HBRUSH)GetStockObject( WHITE_BRUSH );
        wc.lpszMenuName = NULL;
        wc.lpszClassName = DrawAreaClassB;
        if( !RegisterClass( &wc ) ) {
            return( FALSE );
        }
    }

    if( !previnst ) {
        wc.style = CS_BYTEALIGNWINDOW | CS_CLASSDC | CS_DBLCLKS;
        wc.lpfnWndProc = DrawAreaWinProc;
        wc.cbClsExtra = sizeof( HCURSOR );
        wc.cbWndExtra = 0;
        wc.hInstance = Instance;
        wc.hIcon = hIconIcon;
        wc.hCursor = LoadCursor( (HANDLE)NULL, IDC_ARROW );
        wc.hbrBackground = (HBRUSH)GetStockObject( WHITE_BRUSH );
        wc.lpszMenuName = NULL;
        wc.lpszClassName = DrawAreaClassI;
        if( !RegisterClass( &wc ) ) {
            return( FALSE );
        }
    }

    if( !previnst ) {
        wc.style = CS_BYTEALIGNWINDOW | CS_CLASSDC | CS_DBLCLKS;
        wc.lpfnWndProc = DrawAreaWinProc;
        wc.cbClsExtra = sizeof( HCURSOR );
        wc.cbWndExtra = 0;
        wc.hInstance = Instance;
        wc.hIcon = hCursorIcon;
        wc.hCursor = LoadCursor( (HANDLE)NULL, IDC_ARROW );
        wc.hbrBackground = (HBRUSH)GetStockObject( WHITE_BRUSH );
        wc.lpszMenuName = NULL;
        wc.lpszClassName = DrawAreaClassC;
        if( !RegisterClass( &wc ) ) {
            return( FALSE );
        }
    }

    if( !previnst ) {
        wc.style = 0L;
        wc.lpfnWndProc = ViewWindowProc;
        wc.cbClsExtra = 0;
        wc.cbWndExtra = 0;
        wc.hInstance = Instance;
        wc.hIcon = LoadIcon( NULL, IDI_APPLICATION );
        wc.hCursor = LoadCursor( (HANDLE)NULL, IDC_ARROW );
        wc.hbrBackground = (HBRUSH)GetStockObject( WHITE_BRUSH );
        wc.lpszMenuName = NULL;
        wc.lpszClassName = ViewWinClass;
        if( !RegisterClass( &wc ) ) {
            return( FALSE );
        }
    }

    if( !previnst ) {
        wc.style = 0L;
        wc.lpfnWndProc = ColorPalWinProc;
        wc.cbClsExtra = 0;
        wc.cbWndExtra = 0;
        wc.hInstance = Instance;
        wc.hIcon = NULL;
        wc.hCursor = LoadCursor( (HANDLE)NULL, IDC_ARROW );
#if defined( __NT__ )
        wc.hbrBackground = hBkBrush;
#else
        wc.hbrBackground = (HBRUSH)GetStockObject( LTGRAY_BRUSH );
#endif
        wc.lpszMenuName = NULL;
        wc.lpszClassName = PaletteClass;
        if( !RegisterClass( &wc ) ) {
            return( FALSE );
        }
    }

    handCursor = LoadCursor( Instance, "HandCursor" );
    if( !previnst ) {
        wc.style = CS_DBLCLKS;
        wc.lpfnWndProc = ColorsWndProc;
        wc.cbClsExtra = 0;
        wc.cbWndExtra = 0;
        wc.hInstance = Instance;
        wc.hIcon = NULL;
        wc.hCursor = handCursor;
#if defined( __NT__ )
        wc.hbrBackground = hBkBrush;
#else
        wc.hbrBackground = (HBRUSH)GetStockObject( LTGRAY_BRUSH );
#endif
        wc.lpszMenuName = NULL;
        wc.lpszClassName = "ColorsClass";
        if( !RegisterClass( &wc ) ) {
            return( FALSE );
        }
    }

    if( !previnst ) {
        wc.style = CS_DBLCLKS;
        wc.lpfnWndProc = ScreenWndProc;
        wc.cbClsExtra = 0;
        wc.cbWndExtra = 0;
        wc.hInstance = Instance;
        wc.hIcon = NULL;
        wc.hCursor = handCursor;
#if defined( __NT__ )
        wc.hbrBackground = hBkBrush;
#else
        wc.hbrBackground = (HBRUSH)GetStockObject( LTGRAY_BRUSH );
#endif
        wc.lpszMenuName = NULL;
        wc.lpszClassName = "ScreenClass";
        if( !RegisterClass( &wc ) ) {
            return( FALSE );
        }
    }

    if( !previnst ) {
        wc.style = 0L;
        wc.lpfnWndProc = CurrentWndProc;
        wc.cbClsExtra = 0;
        wc.cbWndExtra = 0;
        wc.hInstance = Instance;
        wc.hIcon = NULL;
        wc.hCursor = LoadCursor( (HANDLE)NULL, IDC_ARROW );
#if defined( __NT__ )
        wc.hbrBackground = hBkBrush;
#else
        wc.hbrBackground = (HBRUSH)GetStockObject( LTGRAY_BRUSH );
#endif
        wc.lpszMenuName = NULL;
        wc.lpszClassName = "CurrentClass";
        if( !RegisterClass( &wc ) ) {
            return( FALSE );
        }
    }

    if( !previnst ) {
        wc.style = 0L;
        wc.lpfnWndProc = BitmapPickProc;
        wc.cbClsExtra = 0;
        wc.cbWndExtra = 0;
        wc.hInstance = Instance;
        wc.hIcon = NULL;
        wc.hCursor = NULL;
#if defined( __NT__ )
        wc.hbrBackground = hBkBrush;
#else
        wc.hbrBackground = (HBRUSH)GetStockObject( LTGRAY_BRUSH );
#endif
        wc.lpszMenuName = NULL;
        wc.lpszClassName = BitmapPickClass;
        if( !RegisterClass( &wc ) ) {
            return( FALSE );
        }
    }

    /*
     * Now make the main window.
     */
    LoadImgedConfig();
    maximized = ImgedConfigInfo.ismaximized;

    InitPalette();
    HMainWindow = CreateWindow(
        className,                              /* Window class name */
        IEAppTitle,                             /* Window caption */
        WS_OVERLAPPEDWINDOW | WS_BORDER | WS_CLIPCHILDREN | WS_CLIPSIBLINGS
        | WS_DLGFRAME,                          /* Window style */
        ImgedConfigInfo.x_pos,                  /* Initial X position */
        ImgedConfigInfo.y_pos,                  /* Initial Y position */
        ImgedConfigInfo.width,                  /* Initial X size */
        ImgedConfigInfo.height,                 /* Initial Y size */
        (HWND)NULL,                             /* Parent window handle */
        (HMENU)menu,                            /* Window menu handle */
        Instance,                               /* Program instance handle */
        NULL );                                 /* Create parameters */

    if( HMainWindow == NULL ) {
        return( FALSE );
    }

    if( maximized ) {
        if( cmdshow == SW_SHOW || cmdshow == SW_SHOWNORMAL ) {
            show_state = SW_SHOWMAXIMIZED;
        } else {
            show_state = cmdshow;
        }
    } else {
        show_state = cmdshow;
    }
    ShowWindow( HMainWindow, show_state );
    UpdateWindow( HMainWindow );

    if( !ImgedIsDDE && !NoTitleScreen ) {
        DisplayTitleScreen( Instance, HMainWindow, 2000, IEAppTitle );
    }

    CreateColorPal();
    InitTools( HMainWindow );
    GrayEditOptions();

#ifdef __NT__
    DragAcceptFiles( HMainWindow, TRUE );
#endif
    //SetActiveWindow( HMainWindow );
    BringWindowToTop( HMainWindow );
    return( TRUE );

} /* imgEditInit */
コード例 #3
0
ファイル: main.cpp プロジェクト: kelno/AdtTools
void main(int argc, char* argv[])
{
#ifdef DEBUG_MODE
    std::cout << "Press any key to continue..." << std::endl;
    std::getchar();
#endif

    auto DoExit = [&](int code)
    {
        //erase all tools
        DeleteTools();
        sLogger->WaitUntilEmpty();
        exit(code);
    };

    InitTools();

    //if no command given, list commands
    if(argc == 1)
    {
        sLogger->Out(Logger::LogLevel::LOG_LEVEL_NORMAL, "AdtTools v%s", ADTTOOLS_VERSION);
        sLogger->Out(Logger::LogLevel::LOG_LEVEL_NORMAL, "%s", TOOLS_DESCRIPTION);
        ListCommands();

        DoExit(0);
    }

    //else if command given
    std::string executableName = argv[0];
    std::string commandName = argv[1];

    //check if command exists
    ConsoleTool* tool = GetToolWithName(commandName);
    if(!tool)
    {
        sLogger->Out(Logger::LogLevel::LOG_LEVEL_ERROR, "%s", "No command found with this name.");
        ListCommands();
        DoExit(1);
    }

    if(argc == 2) //if only the command name was given, show extended description
    {
        ShowExtendedDescription(executableName, commandName, tool);
        DoExit(0);
    } else { //if command argument(s) is/are given
        unsigned int argCount = argc - 2;
        if(argCount < tool->GetMinArgumentCount())
        {
            sLogger->Out(Logger::LogLevel::LOG_LEVEL_ERROR, "%s", "Too few arguments.");
            PrintUsage(executableName, commandName, tool);
            DoExit(0);
        } else if (argCount > tool->GetMaxArgumentCount())
        {
            sLogger->Out(Logger::LogLevel::LOG_LEVEL_ERROR, "%s", "Too much arguments.");
            PrintUsage(executableName, commandName, tool);
            DoExit(0);
        }
    }

    //all okay let's get to work
    int error = tool->Work(argc, argv);

    DoExit(error);
}
コード例 #4
0
ファイル: imgedit.c プロジェクト: ABratovic/open-watcom-v2
/*
 * imgEditInit - initialization
 */
static BOOL imgEditInit( HAB hab )
{
    ULONG       flags;
    BOOL        maximized;
    HWND        frame;
    char        clientclass[] = { "IMGEDClientClass" };
    HWND        hwnd;
    WPI_RECT    rect;
    HMENU       hmenu;

    // Change this to use the querycaps routine
    ColourPlanes = 1;
    BitsPerPixel = 4;

    Instance.hab = hab;
    Instance.mod_handle = NULL;
    /*
     * set up window class
     */
    if (!WinRegisterClass( hab,
                           className,
                           (PFNWP)ImgEdFrameProc,
                           CS_MOVENOTIFY | CS_SIZEREDRAW | CS_CLIPCHILDREN,
                           0 )) {
        return( FALSE );
    }
    if (!WinRegisterClass( hab,
                           clientclass,
                           (PFNWP)ClientProc,
                           CS_MOVENOTIFY | CS_SIZEREDRAW | CS_CLIPCHILDREN,
                           0 )) {
        return( FALSE );
    }
    if (!WinRegisterClass( hab,
                           PaletteClass,
                           (PFNWP)ColourPalWinProc,
                           CS_MOVENOTIFY | CS_SIZEREDRAW | CS_CLIPCHILDREN,
                           0 )) {
        return( FALSE );
    }
    if (!WinRegisterClass( hab,
                           CURRENT_CLASS,
                           (PFNWP)CurrentWndProc,
                           CS_SIZEREDRAW | CS_SYNCPAINT,
                           0 )) {
        return( FALSE );
    }
    if (!WinRegisterClass( hab,
                           AVAIL_CLASS,
                           (PFNWP)ColoursWndProc,
                           CS_SIZEREDRAW | CS_SYNCPAINT,
                           0 )) {
        return( FALSE );
    }
    if (!WinRegisterClass( hab,
                           SCREEN_CLASS,
                           (PFNWP)ScreenWndProc,
                           CS_SIZEREDRAW,
                           0 )) {
        return( FALSE );
    }
    if (!WinRegisterClass( hab,
                           DrawAreaClassB,
                           (PFNWP)DrawAreaWinProc,
                           CS_SIZEREDRAW | CS_SYNCPAINT | CS_CLIPSIBLINGS,
                           0 )) {
        return( FALSE );
    }
    if (!WinRegisterClass( hab,
                           DrawAreaClassI,
                           (PFNWP)DrawAreaWinProc,
                           CS_SIZEREDRAW | CS_SYNCPAINT | CS_CLIPSIBLINGS,
                           0 )) {
        return( FALSE );
    }
    if (!WinRegisterClass( hab,
                           DrawAreaClassC,
                           (PFNWP)DrawAreaWinProc,
                           CS_SIZEREDRAW | CS_SYNCPAINT | CS_CLIPSIBLINGS,
                           0 )) {
        return( FALSE );
    }
    if (!WinRegisterClass( hab,
                           ViewWinClass,
                           (PFNWP)ViewWindowProc,
                           CS_MOVENOTIFY | CS_SIZEREDRAW | CS_CLIPCHILDREN,
                           0 )) {
        return( FALSE );
    }

    LoadImgedConfig();
    maximized = ImgedConfigInfo.ismaximized;
    InitPalette();
    /*
     * now make the main window
     */
    flags = FCF_TITLEBAR        |
            FCF_SIZEBORDER      |
            FCF_MINMAX          |
            FCF_SYSMENU         |
            FCF_TASKLIST        |
            FCF_ICON            |
            FCF_MENU;

    frame = WinCreateStdWindow(
        HWND_DESKTOP,
        0L,
        &flags,
        className,
        ImgEdName,
        0L,
        (HMODULE)0,
        IMGED_MAIN,
        &HMainWindow);

    WinSetWindowPos(frame, HWND_TOP, ImgedConfigInfo.x_pos,
                ImgedConfigInfo.y_pos, ImgedConfigInfo.width,
                ImgedConfigInfo.height, SWP_MOVE | SWP_SHOW | SWP_SIZE);

    _wpi_getclientrect( HMainWindow, &rect );
    flags = 0L;
    /*
     * N.B. - NOTE that ClientWindow is actually a FRAME WINDOW!!!!!  The
     *        name is a bit misleading and it is unlike HMainWindow which
     *        is a client window.
     */
    ClientWindow = WinCreateStdWindow( HMainWindow, 0L, &flags, clientclass,
                                        "", 0L, (HMODULE)0, 0, &hwnd);

    WinSetWindowPos(ClientWindow, HWND_TOP, 0, STATUS_WIDTH,
                _wpi_getwidthrect( rect ),
                _wpi_getheightrect(rect) -STATUS_WIDTH -FUNCTIONBAR_WIDTH -1,
                SWP_MOVE | SWP_SHOW | SWP_SIZE);

    CreateColourPal();
    InitFunctionBar( HMainWindow );
    InitTools( _wpi_getframe(HMainWindow) );

    hmenu = _wpi_getmenu( frame );
    if (ImgedConfigInfo.grid_on) {
        CheckGridItem(hmenu);
    }
    SetHintText("Open Watcom Image Editor.");
    WinSetFocus( HWND_DESKTOP, _wpi_getframe(HMainWindow) );
    return( TRUE );
} /* imgEditInit */