0030946: Visualization - Image_AlienPixMap ignores 1-bit pixelformat when using FreeImage
[occt.git] / src / Draw / MainWindow.cxx
CommitLineData
b311480e 1// Created on: 1998-08-06
2// Created by: Administrateur Atelier MDL
3// Copyright (c) 1998-1999 Matra Datavision
973c2be1 4// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 5//
973c2be1 6// This file is part of Open CASCADE Technology software library.
b311480e 7//
d5f74e42 8// This library is free software; you can redistribute it and/or modify it under
9// the terms of the GNU Lesser General Public License version 2.1 as published
973c2be1 10// by the Free Software Foundation, with special exception defined in the file
11// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12// distribution for complete text of the license and disclaimer of any warranty.
b311480e 13//
973c2be1 14// Alternatively, this file may be used under the terms of Open CASCADE
15// commercial license or contractual agreement.
b311480e 16
57c28b61 17#ifdef _WIN32
7fd59977 18
7fd59977 19#include <windows.h>
20#include <DrawRessource.h>
21#include <init.h>
22#include <MainWindow.h>
23#include <Draw_Window.hxx>
24#include <CommandWindow.h>
25
bf03eb83 26Standard_Boolean Draw_Interprete(const char* command); // Implemented in Draw.cxx
7fd59977 27extern Standard_Boolean Draw_IsConsoleSubsystem;
28
29//extern "C" int compat_unlink(const char *fname); // Implemente dans TCL
30
31/*--------------------------------------------------------*\
32| CLIENT WINDOW PROCEDURE
33|
34|
35\*--------------------------------------------------------*/
6a7d83c4 36LRESULT APIENTRY WndProc(HWND hWndFrame, UINT wMsg, WPARAM wParam, LPARAM lParam )
7fd59977 37{
ad03c234 38 switch (wMsg)
7fd59977 39 {
ad03c234 40 case WM_CREATE:
41 {
42 CreateProc (hWndFrame);
43 HWND hWndClient = (HWND )GetWindowLongPtrW (hWndFrame, CLIENTWND);
44 DrawWindow::hWndClientMDI = hWndClient;
45 if (!Draw_IsConsoleSubsystem)
7fd59977 46 {
ad03c234 47 CreateCommandWindow (hWndFrame, 0);
7fd59977 48 }
ad03c234 49 return 0;
50 }
51 case WM_COMMAND:
52 {
53 CmdProc (hWndFrame, LOWORD(wParam), wParam, lParam);
54 return 0;
55 }
56 case WM_DESTROY:
57 {
58 Draw_Interprete ("exit");
59 DestroyProc (hWndFrame);
60 return 0;
61 }
7fd59977 62 }
ad03c234 63 HWND hWndClient = (HWND)GetWindowLongPtrW(hWndFrame, CLIENTWND);
64 return DefFrameProcW(hWndFrame, hWndClient, wMsg, wParam, lParam);
7fd59977 65}
66
67
68/*--------------------------------------------------------------------------*\
69| CLIENT CREATE PROCEDURE
0d969553 70| Handler for message WM_CREATE. Creation of control window MDI
7fd59977 71|
72\*--------------------------------------------------------------------------*/
73BOOL CreateProc(HWND hWndFrame)
74{
773f53f1 75 HWND hWnd = CreateMDIClientWindow (hWndFrame);
76 if (hWnd != NULL)
77 {
78 // Save hWnd in the main window in extra memory in 0
ad03c234 79 SetWindowLongPtrW (hWndFrame, CLIENTWND, (LONG_PTR)hWnd);
773f53f1 80 }
7fd59977 81 return(TRUE);
82}
83
84
85/*--------------------------------------------------------------------------*\
86| COMMAND PROCEDURE
0d969553 87| Handler for message WM_COMMAND
839b8d3c 88| It is used when Draw_IsConsoleSubsystem = Standard_False
cf0786da 89| i.e. in non-console mode (see Draw_main() in Draw_Main.cxx).
7fd59977 90\*--------------------------------------------------------------------------*/
839b8d3c 91LRESULT APIENTRY CmdProc(HWND hWndFrame, UINT wMsg, WPARAM /*wParam*/, LPARAM /*lParam*/)
7fd59977 92{
773f53f1 93 // Handle on window MDI
ad03c234 94 HWND hWndClient = (HWND )GetWindowLongPtrW (hWndFrame, CLIENTWND);
839b8d3c 95 switch (wMsg)
ad03c234 96 {
97 case IDM_WINDOW_NEXT:
98 {
99 if (hWndClient != NULL)
100 {
101 HWND hWndActive = (HWND )SendMessageW (hWndClient, WM_MDIGETACTIVE, 0, 0l);
102 SendMessageW (hWndClient, WM_MDINEXT, (WPARAM )hWndActive, 0l);
103 }
104 break;
105 }
106 case IDM_WINDOW_CASCADE:
107 {
108 if (hWndClient != NULL)
109 {
110 SendMessageW (hWndClient, WM_MDICASCADE, 0, 0l);
111 }
112 break;
113 }
114 case IDM_WINDOW_TILEHOR:
115 {
116 if (hWndClient != NULL)
117 {
118 SendMessageW (hWndClient, WM_MDITILE, MDITILE_HORIZONTAL, 0l);
119 }
120 break;
121 }
122 case IDM_WINDOW_TILEVERT:
123 {
124 if (hWndClient != NULL)
125 {
126 SendMessageW (hWndClient, WM_MDITILE, MDITILE_VERTICAL, 0l);
127 }
128 break;
129 }
130 case IDM_FILE_EXIT:
131 {
132 Draw_Interprete ("exit");
133 DestroyProc (hWndFrame);
134 break;
135 }
839b8d3c 136 }
ad03c234 137 return 0;
7fd59977 138}
139
140
141/*--------------------------------------------------------------------------*\
142| CLIENT DESTROY PROCEDURE
0d969553 143| Handler for message WM_DESTROY.
7fd59977 144|
145\*--------------------------------------------------------------------------*/
146VOID DestroyProc(HWND hWnd)
147{
ad03c234 148 HINSTANCE hInst = (HINSTANCE )GetWindowLongPtrW (hWnd, GWLP_HINSTANCE);
e89e2d67 149
7fd59977 150 Destroy_Appli(hInst);
151 PostQuitMessage(0);
152}
153#endif
154