├── .gitignore ├── LICENSE ├── Makefile ├── README.md ├── data └── img │ └── encryptor-win-7.png ├── examples └── encryptor.vala ├── res ├── manifest.rc └── manifest.xml ├── src ├── application-window.c ├── application-window.h ├── button.c ├── button.h ├── clipboard.c ├── clipboard.h ├── container.c ├── container.h ├── control.c ├── control.h ├── device-context.c ├── device-context.h ├── edit.c ├── edit.h ├── label.c ├── label.h ├── layout.c ├── layout.h ├── utilities.c ├── utilities.h ├── vala-win32.h ├── window.c ├── window.h ├── wrappers.c └── wrappers.h └── vapi └── libwin32.vapi /.gitignore: -------------------------------------------------------------------------------- 1 | /build/ 2 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 Emre ÖZÇAKIR 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | # Directories 2 | BINDIR = build/bin 3 | CCODEDIR = build/ccode 4 | OBJDIR = build/obj 5 | SRCDIR = src 6 | RESDIR = res 7 | BASEDIR = examples 8 | 9 | # Update the LIBDIR variable to your library path 10 | LIBDIR = 11 | LIBS = "glib-2.0 gobject-2.0 gee-0.8" 12 | PKGCONFIG := $(shell PKG_CONFIG_LIBDIR="$(LIBDIR)/mingw32/lib/pkgconfig" pkg-config --cflags --libs $(LIBS)) 13 | CC = i686-w64-mingw32-gcc 14 | RC = i686-w64-mingw32-windres 15 | CFLAGS := -mwindows -static-libgcc -I$(SRCDIR) 16 | 17 | # Build targets 18 | SAMPLES = encryptor 19 | 20 | EXECUTABLES := $(addprefix $(BINDIR)/,$(addsuffix .exe,$(SAMPLES))) 21 | DEPS := $(notdir $(wildcard $(SRCDIR)/*.c)) 22 | 23 | .PHONY: clean $(SAMPLES) 24 | 25 | default: encryptor 26 | 27 | $(SAMPLES): %: $(BINDIR)/%.exe 28 | @echo SAMPLE BUILT: $^ 29 | 30 | $(EXECUTABLES): $(BINDIR)/%.exe: $(OBJDIR)/%.o $(addprefix $(OBJDIR)/,$(DEPS:.c=.o)) $(OBJDIR)/manifest.o | $(BINDIR) 31 | $(CC) $^ $(CFLAGS) $(PKGCONFIG) -o $@ 32 | 33 | $(patsubst %,$(OBJDIR)/%.o,$(SAMPLES)): $(OBJDIR)/%.o: $(CCODEDIR)/%.c $(SRCDIR)/vala-win32.h | $(OBJDIR) 34 | $(CC) -c $< $(CFLAGS) $(PKGCONFIG) -o $@ 35 | 36 | $(OBJDIR)/%.o: $(SRCDIR)/%.c $(SRCDIR)/%.h | $(OBJDIR) 37 | $(CC) -c $< $(CFLAGS) $(PKGCONFIG) -o $@ 38 | 39 | $(OBJDIR)/manifest.o: $(RESDIR)/manifest.rc $(RESDIR)/manifest.xml 40 | $(RC) $< -o $@ 41 | 42 | $(CCODEDIR)/%.c: $(BASEDIR)/%.vala vapi/libwin32.vapi | $(CCODEDIR) 43 | valac -C $< vapi/libwin32.vapi --pkg gee-0.8 -b $(BASEDIR) -d $(CCODEDIR) 44 | 45 | $(CCODEDIR): 46 | mkdir -p $(CCODEDIR) 47 | 48 | $(BINDIR): 49 | mkdir -p $(BINDIR) 50 | 51 | $(OBJDIR): 52 | mkdir -p $(OBJDIR) 53 | 54 | clean: 55 | $(RM) $(BINDIR)/*.exe $(OBJDIR)/*.o $(CCODEDIR)/*.c 56 | 57 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Vala Bindings for Native Windows Controls 2 | ========================================= 3 | 4 | Though Vala is a quite capable language, when it comes to GUI programming, you don't have a lot of choice, or the choice should I say. The computer I use on a daily basis is a Linux machine with a GNOME desktop environment, so GTK is a reasonable choice for me to use when in need of a GUI toolkit, and I'm happy with that. But when I need to write an application that is supposed to run on Windows, I'd really prefer the look and feel of a native application. Hence the aim of this project is to provide the means of creating a Windows application with the native controls *(widgets)* using Vala. 5 | 6 | Below is a screen shot of the sample application of which you can find the source code [here](examples/encryptor.vala). If you'd like to try it out first, you can download the compiled binary [here](https://github.com/emrevit/vala-win32/releases/download/Samples/samples_v0.1_win_x86_64.zip). 7 | 8 |

9 | 10 |

11 | 12 | __Please Note:__ For the time being, this project is highly experimental and lacks a lot. I have the intention of building a library out of this eventually, but the progress will be really slow (*I really don't have much time.*) 13 | 14 | 15 | Building 16 | ------------------------------------------- 17 | 18 | The sample application is compiled on Ubuntu 20.04 and tested with Wine. The following instructions explain how to do so on Ubuntu. If you'd like to compile on a Windows machine, you can use [MSYS2](https://www.msys2.org/). 19 | 20 | We'll use the C compiler provided by the Mingw-w64 project to cross-compile. You can install the development environment for 32-bit and 64-bit Windows applications by the following command (*if you don't have the development tools package installed already, install the `build-essential` package beforehand*): 21 | 22 | ```shell 23 | sudo apt install mingw-w64 24 | ``` 25 | 26 | after the installation you'll have the following commands at your disposal: 27 | 28 | ```shell 29 | i686-w64-mingw32-gcc # 32-bit C compiler for Windows 30 | x86_64-w64-mingw32-gcc # 64-bit C compiler for Windows 31 | i686-w64-mingw32-g++ # 32-bit C++ compiler for Windows 32 | x86_64-w64-mingw32-g++ # 64-bit C++ compiler for Windows 33 | ``` 34 | 35 | We'll compile the C code generated by the Vala compiler ourselves. To cross-compile the C source, we'll need the Windows specific headers for *GLib, GIO, GObject,* and the other libraries we'll use. Unfortunately, Ubuntu doesn't have these headers and the binaries we'll need at the runtime in its repositories (*Fedora does, by the way,*) so we'll use the ones from the MSYS2 project. 36 | 37 | First, create a directory where we'll place the Windows-specific libraries: 38 | 39 | ```shell 40 | mkdir -p /your/path/to/libs 41 | cd /your/path/to/libs 42 | ``` 43 | 44 | Download the libraries and their dependencies from the MSYS2 project (*as your project grows, you'll need to download additional libraries as well*): 45 | 46 | ```shell 47 | wget https://repo.msys2.org/mingw/mingw32/mingw-w64-i686-glib2-2.72.3-1-any.pkg.tar.zst \ 48 | https://repo.msys2.org/mingw/mingw32/mingw-w64-i686-pcre-8.45-1-any.pkg.tar.zst \ 49 | https://repo.msys2.org/mingw/mingw32/mingw-w64-i686-zlib-1.2.12-1-any.pkg.tar.zst \ 50 | https://repo.msys2.org/mingw/mingw32/mingw-w64-i686-libgee-0.20.5-2-any.pkg.tar.zst \ 51 | https://repo.msys2.org/mingw/mingw32/mingw-w64-i686-libffi-3.3-4-any.pkg.tar.zst \ 52 | https://repo.msys2.org/mingw/mingw32/mingw-w64-i686-gcc-libs-12.1.0-3-any.pkg.tar.zst \ 53 | https://repo.msys2.org/mingw/mingw32/mingw-w64-i686-libiconv-1.17-1-any.pkg.tar.zst \ 54 | https://repo.msys2.org/mingw/mingw32/mingw-w64-i686-gettext-0.21-3-any.pkg.tar.zst \ 55 | https://repo.msys2.org/mingw/mingw32/mingw-w64-i686-libwinpthread-git-10.0.0.r59.gaacb650be-1-any.pkg.tar.zst 56 | ``` 57 | 58 | Extract the packages: 59 | 60 | ```shell 61 | for f in *.tar.zst; do tar --zstd -xf "$f"; done 62 | ``` 63 | 64 | For the `pkg-config` to function properly, we need to correct the `prefix` variable in the package configuration files. To do so, we'll simply filter the config files and change the prefix line via the stream editor: 65 | 66 | ```shell 67 | find -name '*.pc' | while read file; do sed -E -i "s#^prefix=(\S*)#prefix=$PWD\1#" "$file"; done 68 | ``` 69 | 70 | Open the make file in the project root and update the `LIBDIR` line to your library path: 71 | 72 | ```makefile 73 | ... 74 | LIBDIR = "/your/path/to/libs" 75 | ... 76 | ``` 77 | 78 | and finally run `make` to build the sample: 79 | 80 | ```shell 81 | make 82 | ``` 83 | 84 | before executing the sample, copy all the required runtime binaries to the executable's directory (*don't forget to change the path*): 85 | 86 | ```shell 87 | while read file; do 88 | cp "/your/path/to/libs/mingw32/bin/$file" ./build/bin/ 89 | done << "EOL" 90 | libffi-7.dll 91 | libgcc_s_dw2-1.dll 92 | libgee-0.8-2.dll 93 | libgio-2.0-0.dll 94 | libglib-2.0-0.dll 95 | libgmodule-2.0-0.dll 96 | libgobject-2.0-0.dll 97 | libiconv-2.dll 98 | libintl-8.dll 99 | libpcre-1.dll 100 | libwinpthread-1.dll 101 | zlib1.dll 102 | EOL 103 | ``` 104 | 105 | 106 | -------------------------------------------------------------------------------- /data/img/encryptor-win-7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emrevit/vala-win32/fb2ea416280eb4fbed2a953414e46284117d3569/data/img/encryptor-win-7.png -------------------------------------------------------------------------------- /examples/encryptor.vala: -------------------------------------------------------------------------------- 1 | /*--------------------------------------------------------------------------------------------- 2 | * Copyright (c) 2022 Emre ÖZÇAKIR 3 | * Licensed under the MIT License. See License file in the project root for more information. 4 | *-------------------------------------------------------------------------------------------*/ 5 | 6 | using Win32; 7 | using Gee; 8 | 9 | namespace ROT13 { 10 | 11 | string encode(string? text) 12 | { 13 | var buffer = new StringBuilder(); 14 | 15 | buffer.append(text); 16 | // we create a weak reference to avoid unnecessary duplication 17 | // and to edit bytes in place 18 | unowned var byte_array = buffer.data; 19 | uint8 byte; 20 | 21 | // For the 7-bit ASCII character codes, the UTF-8 representation is 22 | // a byte long and equivalent to the corresponding ASCII code. 23 | for (int i=0; i < byte_array.length; i++) 24 | { 25 | byte = byte_array[i]; 26 | 27 | if (byte >= 'A' && byte <= 'Z'){ 28 | byte = 'A' + (byte - 'A' + 13) % 26; 29 | } else if (byte >= 'a' && byte <= 'z'){ 30 | byte = 'a' + (byte - 'a' + 13) % 26; 31 | } 32 | byte_array[i] = byte; 33 | } 34 | // to avoid unnecessary duplication we transfer the ownership 35 | return (owned) buffer.str; 36 | } 37 | } 38 | 39 | class Application 40 | { 41 | private struct UIElements { 42 | public HashMap buttons; 43 | public HashMap edits; 44 | } 45 | 46 | private ApplicationWindow appWindow; 47 | private UIElements ui; 48 | 49 | public Application() 50 | { 51 | create_ui(); 52 | // to get notified when the clipboard contents change 53 | Clipboard.add_format_listener(appWindow); 54 | 55 | if (Clipboard.text == null){ 56 | ui.buttons["paste"].enabled = false; 57 | } 58 | 59 | register_listeners(); 60 | } 61 | 62 | private void create_ui() 63 | { 64 | var buttons = new HashMap(); 65 | var edits = new HashMap(); 66 | 67 | // The root element of our GUI 68 | appWindow = new ApplicationWindow("ROT-13 Encoder/Decoder"){ 69 | min_width = 500, 70 | min_height = 350, 71 | width = 500, 72 | height = 350, 73 | layout = new RelativeLayout() 74 | // Spacing is the margin between the child windows: 75 | // (vertical_spacing, horizontal_spacing) 76 | // If you provide one argument, the vertical and the 77 | // horizontal spacing will be the same. 78 | .with_spacing(9, 5) 79 | // Padding is the margin between the child windows and 80 | // the edges of its parent: (vertical, horizontal) 81 | // If you provide one argument, the vertical and the 82 | // horizontal padding will be the same. 83 | .with_padding(8) 84 | }; 85 | 86 | var label = new Label(appWindow){ 87 | text = "Your text to be encrypted:" 88 | // without positioning data, a child window will be positioned 89 | // at (0,0) of its parent -margins will be taken into account. 90 | }; 91 | 92 | buttons["help"] = new Button(appWindow){ 93 | text = "Help", 94 | width = 70, 95 | positioning = new LayoutData(){ 96 | // Bottom edge of the button will be attached to the bottom 97 | // (100%) of its parent 98 | bottom = Anchor.to_parent(100) 99 | } 100 | }; 101 | 102 | buttons["paste"] = new Button( appWindow){ 103 | text = "Paste", 104 | width = 70, 105 | positioning = new LayoutData(){ 106 | // Top edge of the button will be attached to the bottom of the 107 | // sibling window "label". 108 | top = Anchor.to_sibling(label), 109 | // Right edge of the button will be attached to the right edge 110 | // (100%) of its parent 111 | right = Anchor.to_parent(100) 112 | } 113 | }; 114 | 115 | edits["output"] = new Edit.multiline(appWindow){ 116 | readonly = true, 117 | positioning = new LayoutData(){ 118 | // Because we want the edit to expand its size, we attach all 119 | // of its edges 120 | left = Anchor.to_parent(0), 121 | // Top edge of the edit will be attached to the middle (50%) 122 | // of its parent 123 | top = Anchor.to_parent(50), 124 | // Right edge of the edit will be attached to the left edge of 125 | // the sibling window "paste". 126 | right = Anchor.to_sibling(buttons["paste"]), 127 | // Bottom edge of the edit will be attached to the top of the 128 | // sibling window "help". 129 | bottom = Anchor.to_sibling(buttons["help"]) 130 | } 131 | }; 132 | 133 | var label2 = new Label(appWindow){ 134 | text = "ROT-13 encoded text:", 135 | positioning = new LayoutData(){ 136 | bottom = Anchor.to_sibling(edits["output"]) 137 | } 138 | }; 139 | 140 | edits["input"] = new Edit.multiline(appWindow){ 141 | positioning = new LayoutData(){ 142 | left = Anchor.to_parent(0), 143 | top = Anchor.to_sibling(label), 144 | bottom = Anchor.to_sibling(label2), 145 | right = Anchor.to_sibling(buttons["paste"]) 146 | } 147 | }; 148 | 149 | buttons["copy"] = new Button(appWindow){ 150 | text = "Copy", 151 | positioning = new LayoutData(){ 152 | // Default behaviour is to attach the top edge of the window 153 | // to the bottom edge of the sibling window specified and 154 | // the left edge to the right edge and so on. 155 | // You can change this behaviour by specifying the edge you 156 | // want to attach to. 157 | top = Anchor.to_sibling(edits["output"]).to_edge(Edge.TOP), 158 | left = Anchor.to_sibling(buttons["paste"]).to_edge(Edge.LEFT), 159 | right = Anchor.to_parent(100) 160 | } 161 | }; 162 | 163 | buttons["quit"] = new Button(appWindow){ 164 | text = "Quit", 165 | positioning = new LayoutData(){ 166 | top = Anchor.to_sibling(edits["output"]), 167 | left = Anchor.to_sibling(buttons["paste"]).to_edge(Edge.LEFT), 168 | right = Anchor.to_parent(100) 169 | } 170 | }; 171 | 172 | buttons["encode"] = new Button(appWindow){ 173 | text = "Encode", 174 | positioning = new LayoutData(){ 175 | top = Anchor.to_sibling(buttons["paste"]), 176 | left = Anchor.to_sibling(buttons["paste"]).to_edge(Edge.LEFT), 177 | right = Anchor.to_parent(100) 178 | } 179 | }; 180 | 181 | ui.buttons = buttons; 182 | ui.edits = edits; 183 | } 184 | 185 | // Register Event Listeners 186 | private void register_listeners() 187 | { 188 | ui.buttons["paste"].add_listener(Event.CLICK, (event) => { 189 | ui.edits["input"].text = Clipboard.text; 190 | }); 191 | 192 | ui.buttons["copy"].add_listener(Event.CLICK, (event) => { 193 | Clipboard.text = ui.edits["output"].text; 194 | }); 195 | 196 | ui.buttons["quit"].add_listener( Event.CLICK, (event) => { 197 | post_message(appWindow, WM_CLOSE); 198 | }); 199 | 200 | ui.buttons["encode"].add_listener( Event.CLICK, (event) => { 201 | ui.edits["output"].text = ROT13.encode( ui.edits["input"].text ); 202 | }); 203 | 204 | ui.buttons["help"].add_listener( Event.CLICK, (event) => { 205 | stdout.printf(@"I'm basically useless...\n"); 206 | }); 207 | 208 | appWindow.add_listener(Event.CLIPBOARD_UPDATE, (event) => { 209 | 210 | if ( (Clipboard.text ?? "").strip() != "" ){ 211 | ui.buttons["paste"].enabled = true; 212 | } else { 213 | ui.buttons["paste"].enabled = false; 214 | } 215 | // To prevent further propagation of the event 216 | event.handled = true; 217 | }); 218 | } 219 | 220 | public void display() 221 | { 222 | appWindow.show(); 223 | } 224 | 225 | public int run() 226 | { 227 | Message msg; 228 | // The Windows Message Loop 229 | while ( get_message(out msg) > 0) 230 | { 231 | translate_message(ref msg); 232 | dispatch_message (ref msg); 233 | } 234 | return (int) msg.wParam; 235 | } 236 | } 237 | 238 | int main (string[] argv) { 239 | 240 | var app = new Application(); 241 | 242 | app.display(); 243 | app.run(); 244 | 245 | return 0; 246 | } -------------------------------------------------------------------------------- /res/manifest.rc: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | 1 RT_MANIFEST "manifest.xml" 4 | -------------------------------------------------------------------------------- /res/manifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /src/application-window.c: -------------------------------------------------------------------------------- 1 | /*--------------------------------------------------------------------------------------------- 2 | * Copyright (c) 2022 Emre ÖZÇAKIR 3 | * Licensed under the MIT License. See License file in the project root for more information. 4 | *-------------------------------------------------------------------------------------------*/ 5 | 6 | #include "vala-win32.h" 7 | 8 | static const wchar_t *szClassName = L"WindowClass"; 9 | static gpointer win32_application_window_parent_class = NULL; 10 | 11 | static LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); 12 | static void win32_application_window_finalize (Win32Window * obj); 13 | static GType win32_application_window_get_type_once (void); 14 | 15 | 16 | /* CONSTRUCTOR 17 | ------------------------------------------- */ 18 | Win32ApplicationWindow* win32_application_window_construct (GType object_type, const char * title) 19 | { 20 | Win32ApplicationWindow* self = NULL; 21 | self = (Win32ApplicationWindow*) win32_container_construct (object_type); 22 | Win32Window *window = (Win32Window*) self; 23 | 24 | if ( title != NULL ){ 25 | window->text = _strdup (title); 26 | } 27 | 28 | // Defaults 29 | window->left = CW_USEDEFAULT; // initial x position 30 | window->top = CW_USEDEFAULT; // initial y position 31 | window->width = CW_USEDEFAULT; // initial x size 32 | window->height = CW_USEDEFAULT; // initial y size 33 | 34 | return self; 35 | } 36 | 37 | Win32ApplicationWindow* win32_application_window_new (const char * title) 38 | { 39 | return win32_application_window_construct (WIN32_TYPE_APPLICATION_WINDOW, title); 40 | } 41 | 42 | 43 | /* INTERNAL CREATE 44 | ------------------------------------------- */ 45 | void win32_application_window_create (Win32ApplicationWindow *self) 46 | { 47 | HWND hwnd; 48 | Win32Window * window = (Win32Window*) self; 49 | wchar_t *text = fromUTF8(window->text); 50 | 51 | // Creating the Window 52 | hwnd = CreateWindowEx( 53 | 0, // WS_EX_CLIENTEDGE, 54 | szClassName, 55 | text, 56 | WS_OVERLAPPEDWINDOW, 57 | window->left, 58 | window->top, 59 | window->pref_width, 60 | window->pref_height, 61 | NULL, NULL, 62 | window->hInstance, 63 | window ); 64 | 65 | free(text); 66 | 67 | if(hwnd == NULL) 68 | { 69 | MessageBox(NULL, L"Window Creation Failed!", L"Error!", MB_ICONEXCLAMATION | MB_OK); 70 | exit (1); //exit 71 | } 72 | } 73 | 74 | 75 | /* METHOD SHOW 76 | ------------------------------------------- */ 77 | void win32_application_window_show(Win32ApplicationWindow *self) 78 | { 79 | Win32Window * window = (Win32Window*) self; 80 | Win32Container * container = (Win32Container*) self; 81 | 82 | if ( window->hwnd == NULL ){ 83 | // Update layout if there is any 84 | if (container->layout) container->layout->configure (container); 85 | // Create underlying window object 86 | win32_application_window_create( self ); 87 | } 88 | ShowWindow (window->hwnd, SW_NORMAL); 89 | UpdateWindow (window->hwnd); 90 | } 91 | 92 | 93 | /* PROPERTY SET MIN-WIDTH 94 | ------------------------------------------- */ 95 | void win32_application_window_set_min_width (Win32ApplicationWindow *self, INT min_width) 96 | { 97 | self->min_width = min_width; 98 | } 99 | 100 | /* PROPERTY GET MIN-WIDTH 101 | ------------------------------------------- */ 102 | INT win32_application_window_get_min_width (Win32ApplicationWindow *self) 103 | { 104 | return self->min_width; 105 | } 106 | 107 | /* PROPERTY SET MIN-HEIGHT 108 | ------------------------------------------- */ 109 | void win32_application_window_set_min_height (Win32ApplicationWindow *self, INT min_height) 110 | { 111 | self->min_height = min_height; 112 | } 113 | 114 | /* PROPERTY GET MIN-HEIGHT 115 | ------------------------------------------- */ 116 | INT win32_application_window_get_min_height (Win32ApplicationWindow *self) 117 | { 118 | return self->min_height; 119 | } 120 | 121 | /* PROPERTY SET MAX-WIDTH 122 | ------------------------------------------- */ 123 | void win32_application_window_set_max_width (Win32ApplicationWindow *self, INT max_width) 124 | { 125 | self->max_width = max_width; 126 | } 127 | 128 | /* PROPERTY GET MAX-WIDTH 129 | ------------------------------------------- */ 130 | INT win32_application_window_get_max_width (Win32ApplicationWindow *self) 131 | { 132 | return self->max_width; 133 | } 134 | 135 | /* PROPERTY SET MAX-HEIGHT 136 | ------------------------------------------- */ 137 | void win32_application_window_set_max_height (Win32ApplicationWindow *self, INT max_height) 138 | { 139 | self->max_height = max_height; 140 | } 141 | 142 | /* PROPERTY GET MAX-HEIGHT 143 | ------------------------------------------- */ 144 | INT win32_application_window_get_max_height (Win32ApplicationWindow *self) 145 | { 146 | return self->max_height; 147 | } 148 | 149 | 150 | /* INTERNAL WINDOW PROCEDURE 151 | ------------------------------------------- */ 152 | // the Window Procedure 153 | LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) 154 | { 155 | static Win32ApplicationWindow *applicationWindow = NULL; 156 | if (!applicationWindow) applicationWindow = (Win32ApplicationWindow*) GetWindowLongPtr( hwnd, GWLP_USERDATA); 157 | 158 | LRESULT result; 159 | result = win32_window_default_procedure(hwnd, msg, wParam, lParam); 160 | if ( result == STOP_PROPAGATION ) return 0; 161 | 162 | static HBRUSH hbrush = NULL; 163 | 164 | switch (msg) 165 | { 166 | case WM_COMMAND: 167 | // Forward message 168 | if ( (HWND) lParam != NULL ) SendMessage( (HWND) lParam, FM_COMMAND, 0, 0 ); 169 | return 0; 170 | 171 | case WM_GETMINMAXINFO: {//window's size/position is about to change 172 | if (!applicationWindow) return 0; 173 | // lParam is a pointer to MINMAXINFO structure 174 | LPMINMAXINFO lpMMI = (LPMINMAXINFO) lParam; 175 | if (applicationWindow->min_width > 0 ) lpMMI->ptMinTrackSize.x = applicationWindow->min_width; 176 | if (applicationWindow->min_height > 0 ) lpMMI->ptMinTrackSize.y = applicationWindow->min_height; 177 | if (applicationWindow->max_width > applicationWindow->min_width ) lpMMI->ptMaxTrackSize.x = applicationWindow->max_width; 178 | if (applicationWindow->max_height > applicationWindow->min_height) lpMMI->ptMaxTrackSize.y = applicationWindow->max_height; 179 | return 0; } 180 | 181 | case WM_SIZE: { 182 | // Layout children 183 | Win32Container *container = (Win32Container *) applicationWindow; 184 | if ( container->layout != NULL) container->layout->recalculate (container); 185 | return 0; } 186 | 187 | case WM_CLOSE: 188 | DestroyWindow(hwnd); 189 | break; 190 | 191 | case WM_DESTROY: 192 | PostQuitMessage(0); 193 | break; 194 | } 195 | 196 | return DefWindowProc(hwnd, msg, wParam, lParam); 197 | } 198 | 199 | 200 | /* INTERNAL GTYPE 201 | ------------------------------------------- */ 202 | static void win32_application_window_class_init (Win32ApplicationWindowClass * klass, gpointer klass_data) 203 | { 204 | win32_application_window_parent_class = g_type_class_peek_parent (klass); 205 | ((Win32WindowClass *) klass)->finalize = win32_application_window_finalize; 206 | 207 | WNDCLASSEX wndclass; 208 | HINSTANCE hInstance = GetModuleHandle(NULL); 209 | 210 | // Check if the class is already registered in a previous call 211 | if ( !GetClassInfoEx( hInstance, szClassName, &wndclass) ){ 212 | // Register the Window Class 213 | wndclass.cbSize = sizeof(WNDCLASSEX); 214 | wndclass.style = 0; 215 | wndclass.lpfnWndProc = WndProc; 216 | wndclass.cbClsExtra = 0; 217 | wndclass.cbWndExtra = 0; 218 | wndclass.hInstance = hInstance; 219 | wndclass.hIcon = LoadIcon(NULL, IDI_APPLICATION); 220 | wndclass.hCursor = LoadCursor(NULL, IDC_ARROW); 221 | wndclass.hbrBackground = (HBRUSH)(COLOR_BTNFACE+1); 222 | wndclass.lpszMenuName = NULL; 223 | wndclass.lpszClassName = szClassName; 224 | wndclass.hIconSm = LoadIcon(NULL, IDI_APPLICATION); 225 | 226 | if(!RegisterClassEx(&wndclass)) 227 | { 228 | MessageBox(NULL, L"Window Registration Failed!", L"Error!", MB_ICONEXCLAMATION | MB_OK); 229 | exit (1); // exit 230 | } 231 | } 232 | } 233 | 234 | 235 | static void win32_application_window_instance_init (Win32ApplicationWindow * self, gpointer klass) 236 | { 237 | } 238 | 239 | /* INTERNAL CLEANUP 240 | ------------------------------------------- */ 241 | static void win32_application_window_finalize (Win32Window * obj) 242 | { 243 | Win32ApplicationWindow * self; 244 | self = G_TYPE_CHECK_INSTANCE_CAST (obj, WIN32_TYPE_APPLICATION_WINDOW, Win32ApplicationWindow); 245 | WIN32_WINDOW_CLASS (win32_application_window_parent_class)->finalize (obj); 246 | } 247 | 248 | 249 | /* INTERNAL GTYPE REGISTRATION 250 | ------------------------------------------- */ 251 | static GType win32_application_window_get_type_once (void) 252 | { 253 | static const GTypeInfo g_define_type_info = { 254 | sizeof (Win32ApplicationWindowClass), 255 | (GBaseInitFunc) NULL, 256 | (GBaseFinalizeFunc) NULL, 257 | (GClassInitFunc) win32_application_window_class_init, 258 | (GClassFinalizeFunc) NULL, 259 | NULL, 260 | sizeof (Win32ApplicationWindow), 261 | 0, 262 | (GInstanceInitFunc) win32_application_window_instance_init, 263 | NULL 264 | }; 265 | GType win32_application_window_type_id; 266 | win32_application_window_type_id = g_type_register_static (WIN32_TYPE_CONTAINER, "Win32ApplicationWindow", &g_define_type_info, 0); 267 | return win32_application_window_type_id; 268 | } 269 | 270 | 271 | GType win32_application_window_get_type (void) 272 | { 273 | static volatile gsize win32_application_window_type_id__volatile = 0; 274 | if (g_once_init_enter (&win32_application_window_type_id__volatile)) { 275 | GType win32_application_window_type_id; 276 | win32_application_window_type_id = win32_application_window_get_type_once (); 277 | g_once_init_leave (&win32_application_window_type_id__volatile, win32_application_window_type_id); 278 | } 279 | return win32_application_window_type_id__volatile; 280 | } 281 | 282 | 283 | GType win32_application_window_get_type1 (void* obj) 284 | { 285 | return win32_application_window_get_type (); 286 | } 287 | 288 | -------------------------------------------------------------------------------- /src/application-window.h: -------------------------------------------------------------------------------- 1 | /*--------------------------------------------------------------------------------------------- 2 | * Copyright (c) 2022 Emre ÖZÇAKIR 3 | * Licensed under the MIT License. See License file in the project root for more information. 4 | *-------------------------------------------------------------------------------------------*/ 5 | 6 | #ifndef _WIN32_APPLICATION_WINDOW_H_ 7 | #define _WIN32_APPLICATION_WINDOW_H_ 8 | 9 | #include 10 | #include 11 | #include "window.h" 12 | #include "container.h" 13 | 14 | typedef struct _Win32ApplicationWindow Win32ApplicationWindow; 15 | typedef struct _Win32ApplicationWindowClass Win32ApplicationWindowClass; 16 | 17 | #define WIN32_TYPE_APPLICATION_WINDOW (win32_application_window_get_type ()) 18 | #define WIN32_APPLICATION_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), WIN32_TYPE_APPLICATION_WINDOW, Win32ApplicationWindow)) 19 | #define WIN32_APPLICATION_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), WIN32_TYPE_APPLICATION_WINDOW, Win32ApplicationWindowClass)) 20 | #define WIN32_IS_APPLICATION_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), WIN32_TYPE_APPLICATION_WINDOW)) 21 | #define WIN32_IS_APPLICATION_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), WIN32_TYPE_APPLICATION_WINDOW)) 22 | #define WIN32_APPLICATION_WINDOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), WIN32_TYPE_APPLICATION_WINDOW, Win32ApplicationWindowClass)) 23 | 24 | G_DEFINE_AUTOPTR_CLEANUP_FUNC (Win32ApplicationWindow, win32_window_unref) 25 | 26 | /* CLASS ApplicationWindow 27 | ------------------------------------------- */ 28 | struct _Win32ApplicationWindow { 29 | Win32Container parent_instance; 30 | INT min_width; 31 | INT min_height; 32 | INT max_width; 33 | INT max_height; 34 | }; 35 | 36 | struct _Win32ApplicationWindowClass { 37 | Win32ContainerClass parent_class; 38 | }; 39 | 40 | Win32ApplicationWindow* win32_application_window_new (const char * title); 41 | void win32_application_window_show (Win32ApplicationWindow *self); 42 | 43 | void win32_application_window_set_min_width (Win32ApplicationWindow *self, INT min_width); 44 | INT win32_application_window_get_min_width (Win32ApplicationWindow *self); 45 | 46 | void win32_application_window_set_min_height (Win32ApplicationWindow *self, INT min_height); 47 | INT win32_application_window_get_min_height (Win32ApplicationWindow *self); 48 | 49 | void win32_application_window_set_max_width (Win32ApplicationWindow *self, INT max_width); 50 | INT win32_application_window_get_max_width (Win32ApplicationWindow *self); 51 | 52 | void win32_application_window_set_max_height (Win32ApplicationWindow *self, INT max_height); 53 | INT win32_application_window_get_max_height (Win32ApplicationWindow *self); 54 | 55 | /* INTERNAL */ 56 | void win32_application_window_create (Win32ApplicationWindow *self); 57 | 58 | /* GTYPE */ 59 | GType win32_application_window_get_type (void) G_GNUC_CONST; 60 | Win32ApplicationWindow* win32_application_window_construct (GType object_type, const char * title); 61 | GType win32_application_window_get_type1 (void* obj); 62 | 63 | 64 | #endif 65 | -------------------------------------------------------------------------------- /src/button.c: -------------------------------------------------------------------------------- 1 | /*--------------------------------------------------------------------------------------------- 2 | * Copyright (c) 2022 Emre ÖZÇAKIR 3 | * Licensed under the MIT License. See License file in the project root for more information. 4 | *-------------------------------------------------------------------------------------------*/ 5 | 6 | #include "vala-win32.h" 7 | #include 8 | 9 | static WNDPROC g_controlProc = NULL; 10 | static gpointer win32_button_parent_class = NULL; 11 | 12 | static LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); 13 | static GType win32_button_get_type_once (void); 14 | static void win32_button_finalize (Win32Window * obj); 15 | 16 | HWND win32_button_create (Win32Window *self, Win32Window *parent); 17 | 18 | /* CONSTRUCTOR 19 | ------------------------------------------- */ 20 | Win32Button* win32_button_construct (GType object_type, Win32Window* parent, const char * text) 21 | { 22 | Win32Button* self = NULL; 23 | self = (Win32Button*) win32_control_construct (object_type, parent, win32_button_create, text); 24 | return self; 25 | } 26 | 27 | Win32Button* win32_button_new (Win32Window* parent, const char * text) 28 | { 29 | return win32_button_construct (WIN32_TYPE_BUTTON, parent, text); 30 | } 31 | 32 | 33 | /* INTERNAL CREATE 34 | ------------------------------------------- */ 35 | HWND win32_button_create (Win32Window *self, Win32Window *parent) 36 | { 37 | HWND hwnd; 38 | Win32Window *window = (Win32Window*) self; 39 | Win32Control *control = (Win32Control*) self; 40 | 41 | // defaults for a button 42 | window->width = (window->pref_width > 0) ? window->pref_width : 75; 43 | window->height = (window->pref_height > 0) ? window->pref_height : 23; 44 | 45 | control->id = win32_control_generate_ID(); 46 | wchar_t *text = fromUTF8(window->text); 47 | 48 | // Creating the Window 49 | hwnd = CreateWindow( 50 | L"BUTTON", 51 | text, 52 | // Control Styles: 53 | WS_TABSTOP | WS_VISIBLE | WS_CHILD | BS_PUSHBUTTON, 54 | window->left, // x position 55 | window->top, // y position 56 | window->width, // width 57 | window->height, // height 58 | parent->hwnd, // Parent window 59 | (HANDLE) control->id, // Control ID 60 | window->hInstance, 61 | NULL ); 62 | 63 | window->hwnd = hwnd; 64 | 65 | g_controlProc = (WNDPROC) SetWindowLongPtr( hwnd, GWLP_WNDPROC, (LONG_PTR) WndProc ); 66 | 67 | free(text); 68 | 69 | return hwnd; 70 | } 71 | 72 | 73 | /* INTERNAL WINDOW PROCEDURE 74 | ------------------------------------------- */ 75 | // the Window Procedure 76 | LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) 77 | { 78 | LRESULT result; 79 | result = win32_window_default_procedure(hwnd, msg, wParam, lParam); 80 | if ( result == STOP_PROPAGATION ) return 0; 81 | 82 | return CallWindowProc( g_controlProc, hwnd, msg, wParam, lParam); 83 | } 84 | 85 | 86 | /* INTERNAL GTYPE 87 | ------------------------------------------- */ 88 | static void win32_button_class_init (Win32ButtonClass * klass, gpointer klass_data) 89 | { 90 | win32_button_parent_class = g_type_class_peek_parent (klass); 91 | ((Win32WindowClass *) klass)->finalize = win32_button_finalize; 92 | } 93 | 94 | static void win32_button_instance_init (Win32Button * self, gpointer klass) 95 | { 96 | } 97 | 98 | /* INTERNAL CLEANUP 99 | ------------------------------------------- */ 100 | static void win32_button_finalize (Win32Window * obj) 101 | { 102 | Win32Button * self; 103 | self = G_TYPE_CHECK_INSTANCE_CAST (obj, WIN32_TYPE_BUTTON, Win32Button); 104 | 105 | WIN32_WINDOW_CLASS (win32_button_parent_class)->finalize (obj); 106 | } 107 | 108 | 109 | /* INTERNAL GTYPE REGISTRATION 110 | ------------------------------------------- */ 111 | static GType win32_button_get_type_once (void) 112 | { 113 | static const GTypeInfo g_define_type_info = { 114 | sizeof (Win32ButtonClass), 115 | (GBaseInitFunc) NULL, 116 | (GBaseFinalizeFunc) NULL, 117 | (GClassInitFunc) win32_button_class_init, 118 | (GClassFinalizeFunc) NULL, 119 | NULL, 120 | sizeof (Win32Button), 121 | 0, 122 | (GInstanceInitFunc) win32_button_instance_init, 123 | NULL 124 | }; 125 | GType win32_button_type_id; 126 | win32_button_type_id = g_type_register_static (WIN32_TYPE_CONTROL, "Win32Button", &g_define_type_info, 0); 127 | return win32_button_type_id; 128 | } 129 | 130 | GType win32_button_get_type (void) 131 | { 132 | static volatile gsize win32_button_type_id__volatile = 0; 133 | if (g_once_init_enter (&win32_button_type_id__volatile)) { 134 | GType win32_button_type_id; 135 | win32_button_type_id = win32_button_get_type_once (); 136 | g_once_init_leave (&win32_button_type_id__volatile, win32_button_type_id); 137 | } 138 | return win32_button_type_id__volatile; 139 | } 140 | -------------------------------------------------------------------------------- /src/button.h: -------------------------------------------------------------------------------- 1 | /*--------------------------------------------------------------------------------------------- 2 | * Copyright (c) 2022 Emre ÖZÇAKIR 3 | * Licensed under the MIT License. See License file in the project root for more information. 4 | *-------------------------------------------------------------------------------------------*/ 5 | 6 | #ifndef _WIN32_BUTTON_H_ 7 | #define _WIN32_BUTTON_H_ 8 | 9 | #include 10 | #include 11 | #include "window.h" 12 | #include "control.h" 13 | 14 | typedef struct _Win32Button Win32Button; 15 | typedef struct _Win32ButtonClass Win32ButtonClass; 16 | 17 | #define WIN32_TYPE_BUTTON (win32_button_get_type ()) 18 | #define WIN32_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), WIN32_TYPE_BUTTON, Win32Button)) 19 | #define WIN32_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), WIN32_TYPE_BUTTON, Win32ButtonClass)) 20 | #define WIN32_IS_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), WIN32_TYPE_BUTTON)) 21 | #define WIN32_IS_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), WIN32_TYPE_BUTTON)) 22 | #define WIN32_BUTTON_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), WIN32_TYPE_BUTTON, Win32ButtonClass)) 23 | 24 | G_DEFINE_AUTOPTR_CLEANUP_FUNC (Win32Button, win32_window_unref) 25 | 26 | /* CLASS Button 27 | ------------------------------------------- */ 28 | struct _Win32Button { 29 | Win32Control parent_instance; 30 | }; 31 | 32 | struct _Win32ButtonClass { 33 | Win32ControlClass parent_class; 34 | }; 35 | 36 | Win32Button* win32_button_new (Win32Window* parent, const char * text); 37 | 38 | /* INTERNAL */ 39 | GType win32_button_get_type (void) G_GNUC_CONST; 40 | Win32Button* win32_button_construct (GType object_type, Win32Window* parent, const char *text); 41 | 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /src/clipboard.c: -------------------------------------------------------------------------------- 1 | /*--------------------------------------------------------------------------------------------- 2 | * Copyright (c) 2022 Emre ÖZÇAKIR 3 | * Licensed under the MIT License. See License file in the project root for more information. 4 | *-------------------------------------------------------------------------------------------*/ 5 | 6 | #include "vala-win32.h" 7 | #include 8 | 9 | static void add_format_listener_callback ( Win32Event *event, void *boundData ); 10 | 11 | /* CLIPBOARD SET TEXT 12 | ------------------------------------------- */ 13 | void win32_clipboard_set_text(const char* text) 14 | { 15 | HGLOBAL hmem; // Handle to a moveable memory block 16 | wchar_t *buffer; 17 | 18 | if (!OpenClipboard(NULL)) return; 19 | EmptyClipboard(); 20 | 21 | int length = MultiByteToWideChar(CP_UTF8, 0, text, -1, 0, 0); 22 | 23 | // Allocate a global memory object for the text. 24 | hmem = GlobalAlloc(GMEM_MOVEABLE, (length) * sizeof(wchar_t)); 25 | 26 | if (hmem == NULL){ 27 | CloseClipboard(); 28 | return; 29 | } 30 | 31 | // Lock the handle and copy the text to the buffer. 32 | buffer = GlobalLock(hmem); 33 | MultiByteToWideChar(CP_UTF8, 0, text, -1, buffer, length); 34 | GlobalUnlock(hmem); 35 | 36 | // Place the handle on the clipboard. 37 | SetClipboardData(CF_UNICODETEXT, hmem); 38 | // Close the clipboard. 39 | CloseClipboard(); 40 | } 41 | 42 | 43 | /* CLIPBOARD GET TEXT 44 | ------------------------------------------- */ 45 | char* win32_clipboard_get_text(void) 46 | { 47 | HGLOBAL hmem; // Handle to a moveable memory block 48 | const wchar_t *clipboardData; 49 | char *text = NULL; 50 | 51 | if ( !IsClipboardFormatAvailable(CF_UNICODETEXT) ) return NULL; 52 | if ( !OpenClipboard(NULL) ) return NULL; 53 | 54 | hmem = GetClipboardData(CF_UNICODETEXT); 55 | if (hmem != NULL) 56 | { 57 | clipboardData = GlobalLock(hmem); 58 | if (clipboardData != NULL) 59 | { 60 | text = toUTF8( clipboardData ); 61 | GlobalUnlock(hmem); 62 | } 63 | } 64 | CloseClipboard(); 65 | 66 | return text; 67 | } 68 | 69 | 70 | /* STATIC METHOD 71 | ------------------------------------------- */ 72 | BOOL win32_clipboard_add_format_listener (Win32Window *window) 73 | { 74 | if (window->hwnd) return AddClipboardFormatListener(window->hwnd); 75 | win32_window_insert_into_callback_queue( window, WM_CREATE, add_format_listener_callback, NULL, NULL ); 76 | return FALSE; 77 | } 78 | 79 | static void add_format_listener_callback ( Win32Event *event, void *boundData ) 80 | { 81 | Win32Window *window = event->source; 82 | AddClipboardFormatListener(window->hwnd); 83 | } 84 | 85 | -------------------------------------------------------------------------------- /src/clipboard.h: -------------------------------------------------------------------------------- 1 | /*--------------------------------------------------------------------------------------------- 2 | * Copyright (c) 2022 Emre ÖZÇAKIR 3 | * Licensed under the MIT License. See License file in the project root for more information. 4 | *-------------------------------------------------------------------------------------------*/ 5 | 6 | #ifndef _WIN32_CLIPBOARD_H_ 7 | #define _WIN32_CLIPBOARD_H_ 8 | 9 | #include 10 | #include 11 | 12 | void win32_clipboard_set_text(const char* text); 13 | 14 | char* win32_clipboard_get_text(void); 15 | 16 | BOOL win32_clipboard_add_format_listener (Win32Window *window); 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /src/container.c: -------------------------------------------------------------------------------- 1 | /*--------------------------------------------------------------------------------------------- 2 | * Copyright (c) 2022 Emre ÖZÇAKIR 3 | * Licensed under the MIT License. See License file in the project root for more information. 4 | *-------------------------------------------------------------------------------------------*/ 5 | 6 | #include "vala-win32.h" 7 | 8 | static gpointer win32_container_parent_class = NULL; 9 | 10 | static void win32_container_finalize (Win32Window * obj); 11 | static GType win32_container_get_type_once (void); 12 | 13 | 14 | /* CONSTRUCTOR 15 | ------------------------------------------- */ 16 | Win32Container* win32_container_construct (GType object_type) 17 | { 18 | Win32Container* self = NULL; 19 | self = (Win32Container*) win32_window_construct (object_type); 20 | 21 | // Initialize children list 22 | self->childWindows.items = malloc( sizeof(Win32Window*) * INITIAL_LIST_SIZE ); 23 | memset( self->childWindows.items, 0, sizeof(Win32Window*) * INITIAL_LIST_SIZE ); 24 | self->childWindows.length = 0; 25 | 26 | return self; 27 | } 28 | 29 | 30 | /* METHOD GET CHILDREN 31 | ------------------------------------------- */ 32 | Win32Window ** win32_container_get_children (Win32Container *self, size_t *length ) 33 | { 34 | *length = self->childWindows.length; 35 | Win32Window ** children = malloc( sizeof(Win32Window*) * (*length+1) ); 36 | 37 | for ( int i =0; i < (*length); i++ ){ 38 | children[i] = win32_window_ref (self->childWindows.items[i]); 39 | } 40 | return children; 41 | } 42 | 43 | 44 | /* INTERNAL ADD CHILD 45 | ------------------------------------------- */ 46 | void win32_container_add_child (Win32Container *self, Win32Window *child) 47 | { 48 | Win32Window * window = (Win32Window*) self; 49 | Win32WindowList *childList = &self->childWindows; 50 | size_t length = childList->length; 51 | 52 | // Check if we have enough room in the list 53 | if ( (length+1) % INITIAL_LIST_SIZE == 0 ){ 54 | childList->items = realloc(childList->items, sizeof(Win32Window *) * ((length + 1) + INITIAL_LIST_SIZE) ); 55 | // Initialize newly added slots 56 | memset( childList->items + (length + 1), 0, sizeof(Win32Window *) * INITIAL_LIST_SIZE ); 57 | } 58 | childList->items[ length ] = win32_window_ref( child ); 59 | childList->length += 1; 60 | 61 | // Update layout if there is any 62 | if (window->hwnd && self->layout) self->layout->configure(self); 63 | 64 | } 65 | 66 | 67 | /* PROPERTY SET LAYOUT 68 | ------------------------------------------- */ 69 | void win32_container_set_layout (Win32Container *self, Win32Layout *layout) 70 | { 71 | if ( self->layout != NULL ){ 72 | if (self->layout == layout ) return; 73 | // decrease the reference count of the existing layout 74 | _win32_layout_unref0( self->layout ); 75 | } 76 | 77 | // increase reference count 78 | win32_layout_ref( layout ); 79 | 80 | self->layout = layout; 81 | } 82 | 83 | 84 | /* PROPERTY GET LAYOUT 85 | ------------------------------------------- */ 86 | Win32Layout *win32_container_get_layout (Win32Container *self) 87 | { 88 | return self->layout; 89 | } 90 | 91 | 92 | /* INTERNAL GTYPE 93 | ------------------------------------------- */ 94 | static void win32_container_class_init (Win32ContainerClass * klass, gpointer klass_data) 95 | { 96 | win32_container_parent_class = g_type_class_peek_parent (klass); 97 | // Overrides 98 | ((Win32WindowClass *) klass)->finalize = win32_container_finalize; 99 | } 100 | 101 | static void win32_container_instance_init (Win32Container * self, gpointer klass) 102 | { 103 | } 104 | 105 | 106 | /* INTERNAL CLEANUP 107 | ------------------------------------------- */ 108 | static void win32_container_finalize (Win32Window * obj) 109 | { 110 | Win32Container * self; 111 | self = G_TYPE_CHECK_INSTANCE_CAST (obj, WIN32_TYPE_CONTAINER, Win32Container); 112 | 113 | // Unref children 114 | size_t length = self->childWindows.length; 115 | Win32Window ** children = self->childWindows.items; 116 | for ( int i =0; i < length; i++ ){ 117 | _win32_window_unref0 (children[i]); 118 | } 119 | 120 | free (self->childWindows.items); 121 | WIN32_WINDOW_CLASS (win32_container_parent_class)->finalize (obj); 122 | } 123 | 124 | 125 | /* INTERNAL GTYPE REGISTRATION 126 | ------------------------------------------- */ 127 | static GType win32_container_get_type_once (void) 128 | { 129 | static const GTypeInfo g_define_type_info = { 130 | sizeof (Win32ContainerClass), 131 | (GBaseInitFunc) NULL, 132 | (GBaseFinalizeFunc) NULL, 133 | (GClassInitFunc) win32_container_class_init, 134 | (GClassFinalizeFunc) NULL, 135 | NULL, 136 | sizeof (Win32Container), 137 | 0, 138 | (GInstanceInitFunc) win32_container_instance_init, 139 | NULL 140 | }; 141 | GType win32_container_type_id; 142 | win32_container_type_id = g_type_register_static (WIN32_TYPE_WINDOW, "Win32Container", &g_define_type_info, G_TYPE_FLAG_ABSTRACT); 143 | return win32_container_type_id; 144 | } 145 | 146 | GType win32_container_get_type (void) 147 | { 148 | static volatile gsize win32_container_type_id__volatile = 0; 149 | if (g_once_init_enter (&win32_container_type_id__volatile)) { 150 | GType win32_container_type_id; 151 | win32_container_type_id = win32_container_get_type_once (); 152 | g_once_init_leave (&win32_container_type_id__volatile, win32_container_type_id); 153 | } 154 | return win32_container_type_id__volatile; 155 | } 156 | -------------------------------------------------------------------------------- /src/container.h: -------------------------------------------------------------------------------- 1 | /*--------------------------------------------------------------------------------------------- 2 | * Copyright (c) 2022 Emre ÖZÇAKIR 3 | * Licensed under the MIT License. See License file in the project root for more information. 4 | *-------------------------------------------------------------------------------------------*/ 5 | 6 | #ifndef _WIN32_CONTAINER_H_ 7 | #define _WIN32_CONTAINER_H_ 8 | 9 | #include 10 | #include 11 | #include "window.h" 12 | 13 | typedef struct _Win32WindowList Win32WindowList; 14 | 15 | typedef struct _Win32ContainerClass Win32ContainerClass; 16 | 17 | #define WIN32_TYPE_CONTAINER (win32_container_get_type ()) 18 | #define WIN32_CONTAINER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), WIN32_TYPE_CONTAINER, Win32Container)) 19 | #define WIN32_CONTAINER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), WIN32_TYPE_CONTAINER, Win32ContainerClass)) 20 | #define WIN32_IS_CONTAINER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), WIN32_TYPE_CONTAINER)) 21 | #define WIN32_IS_CONTAINER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), WIN32_TYPE_CONTAINER)) 22 | #define WIN32_CONTAINER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), WIN32_TYPE_CONTAINER, Win32ContainerClass)) 23 | 24 | G_DEFINE_AUTOPTR_CLEANUP_FUNC (Win32Container, win32_window_unref) 25 | 26 | /* CLASS Container 27 | ------------------------------------------- */ 28 | struct _Win32WindowList { 29 | Win32Window ** items; 30 | size_t length; 31 | }; 32 | 33 | struct _Win32Container { 34 | Win32Window parent_instance; 35 | Win32WindowList childWindows; 36 | Win32Layout * layout; 37 | }; 38 | 39 | struct _Win32ContainerClass { 40 | Win32WindowClass parent_class; 41 | }; 42 | 43 | Win32Window ** win32_container_window_get_children (Win32Container *self, size_t *length ); 44 | void win32_container_set_layout (Win32Container *self, Win32Layout *layout); 45 | Win32Layout * win32_container_get_layout (Win32Container *self); 46 | 47 | /* INTERNAL */ 48 | void win32_container_add_child (Win32Container *self, Win32Window *child); 49 | 50 | GType win32_container_get_type (void) G_GNUC_CONST; 51 | Win32Container* win32_container_construct (GType object_type); 52 | 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /src/control.c: -------------------------------------------------------------------------------- 1 | /*--------------------------------------------------------------------------------------------- 2 | * Copyright (c) 2022 Emre ÖZÇAKIR 3 | * Licensed under the MIT License. See License file in the project root for more information. 4 | *-------------------------------------------------------------------------------------------*/ 5 | 6 | #include "vala-win32.h" 7 | #include 8 | 9 | static gpointer win32_control_parent_class = NULL; 10 | 11 | static void creation_callback ( Win32Event *event, void *boundData ); 12 | static void win32_control_finalize (Win32Window * obj); 13 | static GType win32_control_get_type_once (void); 14 | 15 | 16 | /* CONSTRUCTOR 17 | ------------------------------------------- */ 18 | Win32Control* win32_control_construct (GType object_type, 19 | Win32Window *parent, 20 | Win32WindowCreator create_window, 21 | const char *text ) 22 | { 23 | Win32Control* self = NULL; 24 | self = (Win32Control*) win32_window_construct (object_type); 25 | Win32Window * window = (Win32Window*) self; 26 | 27 | window->parent = parent; 28 | 29 | if ( text != NULL ){ 30 | window->text = _strdup (text); 31 | } 32 | 33 | if ( parent->hwnd != NULL ){ 34 | create_window ((Win32Window*) self, parent); 35 | } else { 36 | // postpone control creation until parent window is constructed 37 | Win32CreationData *data = malloc( sizeof(Win32CreationData) ); 38 | data->create_window = create_window; 39 | data->control = self; 40 | win32_window_insert_into_callback_queue( parent, WM_CREATE, creation_callback, data, NULL ); 41 | } 42 | 43 | win32_container_add_child ((Win32Container*) parent, (Win32Window*) self); 44 | 45 | return self; 46 | } 47 | 48 | 49 | /* INTERNAL DELAYED CREATION 50 | ------------------------------------------- */ 51 | void creation_callback ( Win32Event *event, void *boundData ) 52 | { 53 | Win32CreationData * data = (Win32CreationData*) boundData; 54 | Win32WindowCreator create_window = data->create_window; 55 | Win32Control *control = data->control; 56 | Win32Window *window = (Win32Window*) control; 57 | 58 | // window->hwnd is assigned to hwnd inside the create_window function; 59 | HWND hwnd = create_window ((Win32Window*) control, event->source ); 60 | 61 | // Disable control 62 | if (!window->enabled) EnableWindow(hwnd, FALSE); 63 | 64 | // Change the font used to the default gui font 65 | HFONT defaultFont = win32_get_default_gui_font(); 66 | SendMessage(hwnd, WM_SETFONT, (LPARAM) defaultFont, TRUE); 67 | 68 | // by the time we override the control procedure, 69 | // the WM_NCCREATE message has already been processed. 70 | SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR) window ); 71 | 72 | // release CreationData 73 | free (data); 74 | } 75 | 76 | 77 | /* PROPERTY GET ID 78 | ------------------------------------------- */ 79 | UINT control_get_id (Win32Control *self) 80 | { 81 | return self->id; 82 | } 83 | 84 | 85 | /* INTERNAL GTYPE 86 | ------------------------------------------- */ 87 | static void win32_control_class_init (Win32ControlClass * klass, gpointer klass_data) 88 | { 89 | win32_control_parent_class = g_type_class_peek_parent (klass); 90 | ((Win32WindowClass *) klass)->finalize = win32_control_finalize; 91 | } 92 | 93 | static void win32_control_instance_init (Win32Control * self, gpointer klass) 94 | { 95 | } 96 | 97 | 98 | /* INTERNAL CLEANUP 99 | ------------------------------------------- */ 100 | static void win32_control_finalize (Win32Window * obj) 101 | { 102 | Win32Control * self; 103 | self = G_TYPE_CHECK_INSTANCE_CAST (obj, WIN32_TYPE_CONTROL, Win32Control); 104 | 105 | WIN32_WINDOW_CLASS (win32_control_parent_class)->finalize (obj); 106 | } 107 | 108 | 109 | /* INTERNAL GTYPE REGISTRATION 110 | ------------------------------------------- */ 111 | static GType win32_control_get_type_once (void) 112 | { 113 | static const GTypeInfo g_define_type_info = { 114 | sizeof (Win32ControlClass), 115 | (GBaseInitFunc) NULL, 116 | (GBaseFinalizeFunc) NULL, 117 | (GClassInitFunc) win32_control_class_init, 118 | (GClassFinalizeFunc) NULL, 119 | NULL, 120 | sizeof (Win32Control), 121 | 0, 122 | (GInstanceInitFunc) win32_control_instance_init, 123 | NULL 124 | }; 125 | GType win32_control_type_id; 126 | win32_control_type_id = g_type_register_static (WIN32_TYPE_WINDOW, "Win32Control", &g_define_type_info, G_TYPE_FLAG_ABSTRACT); 127 | return win32_control_type_id; 128 | } 129 | 130 | GType win32_control_get_type (void) 131 | { 132 | static volatile gsize win32_control_type_id__volatile = 0; 133 | if (g_once_init_enter (&win32_control_type_id__volatile)) { 134 | GType win32_control_type_id; 135 | win32_control_type_id = win32_control_get_type_once (); 136 | g_once_init_leave (&win32_control_type_id__volatile, win32_control_type_id); 137 | } 138 | return win32_control_type_id__volatile; 139 | } 140 | 141 | 142 | /* UTILITY 143 | ------------------------------------------- */ 144 | unsigned int win32_control_generate_ID(void){ 145 | static unsigned int id = 4000; 146 | return id += 1; 147 | } 148 | -------------------------------------------------------------------------------- /src/control.h: -------------------------------------------------------------------------------- 1 | /*--------------------------------------------------------------------------------------------- 2 | * Copyright (c) 2022 Emre ÖZÇAKIR 3 | * Licensed under the MIT License. See License file in the project root for more information. 4 | *-------------------------------------------------------------------------------------------*/ 5 | 6 | #ifndef _WIN32_CONTROL_H_ 7 | #define _WIN32_CONTROL_H_ 8 | 9 | #include 10 | #include 11 | #include "window.h" 12 | 13 | #define ALIGN_LEFT 0 14 | #define ALIGN_CENTER 1 15 | #define ALIGN_RIGHT 2 16 | 17 | typedef struct _Win32CreationData Win32CreationData; 18 | typedef HWND (*Win32WindowCreator) ( Win32Window *child, Win32Window *parent ); 19 | 20 | typedef struct _Win32Control Win32Control; 21 | typedef struct _Win32ControlClass Win32ControlClass; 22 | 23 | #define WIN32_TYPE_CONTROL (win32_control_get_type ()) 24 | #define WIN32_CONTROL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), WIN32_TYPE_CONTROL, Win32Control)) 25 | #define WIN32_CONTROL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), WIN32_TYPE_CONTROL, Win32ControlClass)) 26 | #define WIN32_IS_CONTROL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), WIN32_TYPE_CONTROL)) 27 | #define WIN32_IS_CONTROL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), WIN32_TYPE_CONTROL)) 28 | #define WIN32_CONTROL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), WIN32_TYPE_CONTROL, Win32ControlClass)) 29 | 30 | G_DEFINE_AUTOPTR_CLEANUP_FUNC (Win32Control, win32_window_unref) 31 | 32 | /* CLASS Control 33 | ------------------------------------------- */ 34 | struct _Win32CreationData { 35 | int ref_count; // not used, just for padding 36 | Win32WindowCreator create_window; 37 | Win32Control * control; 38 | }; 39 | 40 | struct _Win32Control { 41 | Win32Window parent_instance; 42 | UINT id; 43 | }; 44 | 45 | struct _Win32ControlClass { 46 | Win32WindowClass parent_class; 47 | }; 48 | 49 | /* INTERNAL */ 50 | unsigned int win32_control_generate_ID (void); 51 | Win32Control *win32_control_create( Win32Control *control, Win32Window* parent, Win32WindowCreator create_function, const char *text); 52 | 53 | GType win32_control_get_type (void) G_GNUC_CONST; 54 | Win32Control* win32_control_construct (GType object_type, 55 | Win32Window *parent, 56 | Win32WindowCreator create_window, 57 | const char *text ); 58 | 59 | #endif 60 | -------------------------------------------------------------------------------- /src/device-context.c: -------------------------------------------------------------------------------- 1 | /*--------------------------------------------------------------------------------------------- 2 | * Copyright (c) 2022 Emre ÖZÇAKIR 3 | * Licensed under the MIT License. See License file in the project root for more information. 4 | *-------------------------------------------------------------------------------------------*/ 5 | 6 | #include "vala-win32.h" 7 | #include 8 | 9 | void win32_device_context_text_out(HDC hdc, int x, int y, const char * text) 10 | { 11 | wchar_t* _text = fromUTF8( text ); 12 | size_t length = wcslen( _text ); 13 | TextOut( hdc, x, y, _text, length ); 14 | free (_text); 15 | } 16 | -------------------------------------------------------------------------------- /src/device-context.h: -------------------------------------------------------------------------------- 1 | /*--------------------------------------------------------------------------------------------- 2 | * Copyright (c) 2022 Emre ÖZÇAKIR 3 | * Licensed under the MIT License. See License file in the project root for more information. 4 | *-------------------------------------------------------------------------------------------*/ 5 | 6 | #ifndef WIN32_DEVICE_CONTEXT_H 7 | #define WIN32_DEVICE_CONTEXT_H 8 | 9 | #include 10 | #include 11 | #include 12 | 13 | /* CLASS DeviceContext (COMPACT) 14 | ------------------------------------------- */ 15 | void win32_device_context_text_out(HDC hdc, int x, int y, const char * text); 16 | 17 | #endif 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /src/edit.c: -------------------------------------------------------------------------------- 1 | /*--------------------------------------------------------------------------------------------- 2 | * Copyright (c) 2022 Emre ÖZÇAKIR 3 | * Licensed under the MIT License. See License file in the project root for more information. 4 | *-------------------------------------------------------------------------------------------*/ 5 | 6 | #include "vala-win32.h" 7 | #include 8 | 9 | static WNDPROC g_controlProc = NULL; 10 | static gpointer win32_edit_parent_class = NULL; 11 | 12 | static LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); 13 | static GType win32_edit_get_type_once (void); 14 | static void win32_edit_finalize (Win32Window * obj); 15 | 16 | HWND win32_edit_create (Win32Window *self, Win32Window *parent); 17 | 18 | /* CONSTRUCTOR 19 | ------------------------------------------- */ 20 | Win32Edit* win32_edit_construct (GType object_type, Win32Window* parent, const char * text) 21 | { 22 | Win32Edit* self = NULL; 23 | self = (Win32Edit*) win32_control_construct (object_type, parent, win32_edit_create, text); 24 | return self; 25 | } 26 | 27 | Win32Edit* win32_edit_new (Win32Window* parent, const char * text) 28 | { 29 | return win32_edit_construct (WIN32_TYPE_EDIT, parent, text); 30 | } 31 | 32 | Win32Edit* win32_edit_new_multiline (Win32Window* parent, const char * text) 33 | { 34 | Win32Edit* self = win32_edit_construct (WIN32_TYPE_EDIT, parent, text); 35 | self->multiline = TRUE; 36 | return self; 37 | } 38 | 39 | Win32Edit* win32_edit_new_password (Win32Window* parent ) 40 | { 41 | Win32Edit* self = win32_edit_construct (WIN32_TYPE_EDIT, parent, ""); 42 | self->password = TRUE; 43 | return self; 44 | } 45 | 46 | 47 | /* INTERNAL CREATE 48 | ------------------------------------------- */ 49 | HWND win32_edit_create (Win32Window *self, Win32Window *parent) 50 | { 51 | HWND hwnd; 52 | Win32Window *window = (Win32Window*) self; 53 | Win32Control *control = (Win32Control*) self; 54 | Win32Edit *edit = (Win32Edit* ) self; 55 | 56 | control->id = win32_control_generate_ID (); 57 | wchar_t *text = fromUTF8(window->text); 58 | 59 | DWORD styles; // Default is SS_LEFT = 0 60 | switch (edit->text_align){ 61 | case ALIGN_CENTER: 62 | styles = ES_CENTER; 63 | break; 64 | case ALIGN_RIGHT: 65 | styles = ES_RIGHT; 66 | break; 67 | default: 68 | case ALIGN_LEFT: 69 | styles = ES_LEFT; 70 | break; 71 | } 72 | 73 | if (edit->multiline) styles |= WS_VSCROLL | ES_MULTILINE | ES_AUTOVSCROLL; 74 | if (edit->readonly) styles |= ES_READONLY; 75 | if (edit->password) styles |= ES_PASSWORD; 76 | 77 | if (edit->text_align == ALIGN_LEFT && !edit->multiline) styles |= ES_AUTOHSCROLL; 78 | 79 | // default size 80 | window->width = (window->pref_width > 0) ? window->pref_width : 100; 81 | window->height = (window->pref_height > 0) ? window->pref_height : 23; 82 | 83 | // Creating the Window 84 | hwnd = CreateWindowEx( 85 | WS_EX_CLIENTEDGE, 86 | L"EDIT", 87 | text, 88 | // Control Styles: 89 | WS_TABSTOP | WS_VISIBLE | WS_CHILD | styles, 90 | window->left, // x position 91 | window->top, // y position 92 | window->width, // width 93 | window->height, // height 94 | parent->hwnd, // Parent window 95 | (HANDLE) control->id, // Control ID 96 | window->hInstance, 97 | NULL ); 98 | 99 | window->hwnd = hwnd; 100 | 101 | g_controlProc = (WNDPROC) SetWindowLongPtr( hwnd, GWLP_WNDPROC, (LONG_PTR) WndProc ); 102 | 103 | free(text); 104 | 105 | return hwnd; 106 | } 107 | 108 | 109 | /* PROPERTY SET TEXT-ALIGNMENT 110 | ------------------------------------------- */ 111 | void win32_edit_set_text_align (Win32Edit *instance, int alignment) 112 | { 113 | Win32Window *window = (Win32Window*) instance; 114 | 115 | DWORD new_style; // Default is ES_LEFT = 0 116 | LONG_PTR style; 117 | 118 | /*NOOP*/ 119 | if (instance->text_align == alignment) return; 120 | 121 | switch (alignment){ 122 | case ALIGN_CENTER: 123 | new_style = ES_CENTER; 124 | break; 125 | case ALIGN_RIGHT: 126 | new_style = ES_RIGHT; 127 | break; 128 | default: 129 | case ALIGN_LEFT: 130 | new_style = ES_LEFT; 131 | break; 132 | } 133 | instance->text_align = (int) new_style; 134 | 135 | if (alignment == ALIGN_LEFT && !instance->multiline) new_style |= ES_AUTOHSCROLL; 136 | 137 | if (window->hwnd != NULL){ 138 | style = GetWindowLongPtr( window->hwnd, GWL_STYLE ); 139 | // Clear the previous alignment style then apply the new one 140 | style = ( style & ~(ES_LEFT | ES_CENTER | ES_RIGHT | ES_AUTOHSCROLL) ) | new_style; 141 | SetWindowLongPtr( window->hwnd, GWL_STYLE, style ); 142 | InvalidateRect( window->hwnd, NULL, TRUE ); 143 | } 144 | } 145 | 146 | 147 | /* PROPERTY GET TEXT-ALIGNMENT 148 | ------------------------------------------- */ 149 | int win32_edit_get_text_align (Win32Edit *instance) 150 | { 151 | return instance->text_align; 152 | } 153 | 154 | 155 | /* PROPERTY SET READONLY 156 | ------------------------------------------- */ 157 | void win32_edit_set_readonly (Win32Edit *instance, BOOL value) 158 | { 159 | Win32Window *window = (Win32Window*) instance; 160 | // NOOP 161 | if (instance->readonly == value) return; 162 | 163 | instance->readonly = value; 164 | 165 | if (window->hwnd != NULL) 166 | { 167 | if (instance->readonly) SendMessage(window->hwnd, EM_SETREADONLY, (LPARAM) TRUE, 0); 168 | else SendMessage(window->hwnd, EM_SETREADONLY, (LPARAM) FALSE, 0); 169 | 170 | InvalidateRect( window->hwnd, NULL, TRUE ); 171 | } 172 | } 173 | 174 | 175 | /* PROPERTY GET READONLY 176 | ------------------------------------------- */ 177 | BOOL win32_edit_get_readonly (Win32Edit *instance) 178 | { 179 | return instance->readonly; 180 | } 181 | 182 | 183 | /* INTERNAL WINDOW PROCEDURE 184 | ------------------------------------------- */ 185 | // the Window Procedure 186 | LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) 187 | { 188 | LRESULT result; 189 | result = win32_window_default_procedure(hwnd, msg, wParam, lParam); 190 | if ( result == STOP_PROPAGATION ) return 0; 191 | 192 | return CallWindowProc( g_controlProc, hwnd, msg, wParam, lParam); 193 | } 194 | 195 | /* INTERNAL GTYPE 196 | ------------------------------------------- */ 197 | static void win32_edit_class_init (Win32EditClass * klass, gpointer klass_data) 198 | { 199 | win32_edit_parent_class = g_type_class_peek_parent (klass); 200 | ((Win32WindowClass *) klass)->finalize = win32_edit_finalize; 201 | } 202 | 203 | static void win32_edit_instance_init (Win32Edit * self, gpointer klass) 204 | { 205 | } 206 | 207 | /* INTERNAL CLEANUP 208 | ------------------------------------------- */ 209 | static void win32_edit_finalize (Win32Window * obj) 210 | { 211 | Win32Edit * self; 212 | self = G_TYPE_CHECK_INSTANCE_CAST (obj, WIN32_TYPE_EDIT, Win32Edit); 213 | WIN32_WINDOW_CLASS (win32_edit_parent_class)->finalize (obj); 214 | } 215 | 216 | 217 | /* INTERNAL GTYPE REGISTRATION 218 | ------------------------------------------- */ 219 | static GType win32_edit_get_type_once (void) 220 | { 221 | static const GTypeInfo g_define_type_info = { 222 | sizeof (Win32EditClass), 223 | (GBaseInitFunc) NULL, 224 | (GBaseFinalizeFunc) NULL, 225 | (GClassInitFunc) win32_edit_class_init, 226 | (GClassFinalizeFunc) NULL, 227 | NULL, 228 | sizeof (Win32Edit), 229 | 0, 230 | (GInstanceInitFunc) win32_edit_instance_init, 231 | NULL 232 | }; 233 | GType win32_edit_type_id; 234 | win32_edit_type_id = g_type_register_static (WIN32_TYPE_CONTROL, "Win32Edit", &g_define_type_info, 0); 235 | return win32_edit_type_id; 236 | } 237 | 238 | GType win32_edit_get_type (void) 239 | { 240 | static volatile gsize win32_edit_type_id__volatile = 0; 241 | if (g_once_init_enter (&win32_edit_type_id__volatile)) { 242 | GType win32_edit_type_id; 243 | win32_edit_type_id = win32_edit_get_type_once (); 244 | g_once_init_leave (&win32_edit_type_id__volatile, win32_edit_type_id); 245 | } 246 | return win32_edit_type_id__volatile; 247 | } 248 | -------------------------------------------------------------------------------- /src/edit.h: -------------------------------------------------------------------------------- 1 | /*--------------------------------------------------------------------------------------------- 2 | * Copyright (c) 2022 Emre ÖZÇAKIR 3 | * Licensed under the MIT License. See License file in the project root for more information. 4 | *-------------------------------------------------------------------------------------------*/ 5 | 6 | #ifndef _WIN32_EDIT_H_ 7 | #define _WIN32_EDIT_H_ 8 | 9 | #include 10 | #include 11 | #include "window.h" 12 | #include "control.h" 13 | 14 | typedef struct _Win32Edit Win32Edit; 15 | typedef struct _Win32EditClass Win32EditClass; 16 | 17 | #define WIN32_TYPE_EDIT (win32_edit_get_type ()) 18 | #define WIN32_EDIT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), WIN32_TYPE_EDIT, Win32Edit)) 19 | #define WIN32_EDIT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), WIN32_TYPE_EDIT, Win32EditClass)) 20 | #define WIN32_IS_EDIT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), WIN32_TYPE_EDIT)) 21 | #define WIN32_IS_EDIT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), WIN32_TYPE_EDIT)) 22 | #define WIN32_EDIT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), WIN32_TYPE_EDIT, Win32EditClass)) 23 | 24 | G_DEFINE_AUTOPTR_CLEANUP_FUNC (Win32Edit, win32_window_unref) 25 | 26 | /* CLASS Edit 27 | ------------------------------------------- */ 28 | struct _Win32Edit { 29 | Win32Control parent_instance; 30 | int text_align; 31 | BOOL multiline; 32 | BOOL readonly; 33 | BOOL password; 34 | }; 35 | 36 | struct _Win32EditClass { 37 | Win32ControlClass parent_class; 38 | }; 39 | 40 | Win32Edit* win32_edit_new (Win32Window* parent, const char * text); 41 | Win32Edit* win32_edit_new_multiline (Win32Window* parent, const char * text); 42 | Win32Edit* win32_edit_new_password (Win32Window* parent ); 43 | 44 | void win32_edit_set_text_align (Win32Edit *instance, int alignment); 45 | int win32_edit_get_text_align (Win32Edit *instance); 46 | 47 | void win32_edit_set_readonly (Win32Edit *instance, BOOL value); 48 | BOOL win32_edit_get_readonly (Win32Edit *instance); 49 | 50 | /* INTERNAL */ 51 | GType win32_edit_get_type (void) G_GNUC_CONST; 52 | Win32Edit* win32_edit_construct (GType object_type, Win32Window* parent, const char *text); 53 | 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /src/label.c: -------------------------------------------------------------------------------- 1 | /*--------------------------------------------------------------------------------------------- 2 | * Copyright (c) 2022 Emre ÖZÇAKIR 3 | * Licensed under the MIT License. See License file in the project root for more information. 4 | *-------------------------------------------------------------------------------------------*/ 5 | 6 | #include "vala-win32.h" 7 | #include 8 | 9 | static WNDPROC g_controlProc = NULL; 10 | static gpointer win32_label_parent_class = NULL; 11 | 12 | static LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); 13 | static GType win32_label_get_type_once (void); 14 | static void win32_label_finalize (Win32Window * obj); 15 | static void win32_label_auto_resize (Win32Window *window, const void *data); 16 | 17 | HWND win32_label_create (Win32Window *self, Win32Window *parent); 18 | 19 | /* CONSTRUCTOR 20 | ------------------------------------------- */ 21 | Win32Label* win32_label_construct (GType object_type, Win32Window* parent, const char * text) 22 | { 23 | Win32Label* self = NULL; 24 | self = (Win32Label*) win32_control_construct (object_type, parent, win32_label_create, text); 25 | return self; 26 | } 27 | 28 | Win32Label* win32_label_new (Win32Window* parent, const char * text) 29 | { 30 | return win32_label_construct (WIN32_TYPE_LABEL, parent, text); 31 | } 32 | 33 | 34 | /* INTERNAL CREATE 35 | ------------------------------------------- */ 36 | HWND win32_label_create (Win32Window *self, Win32Window *parent) 37 | { 38 | HWND hwnd; 39 | Win32Window *window = (Win32Window*) self; 40 | Win32Control *control = (Win32Control*) self; 41 | Win32Label *label = (Win32Label* ) self; 42 | 43 | control->id = win32_control_generate_ID(); 44 | wchar_t *text = fromUTF8(window->text); 45 | 46 | DWORD style; // Default is SS_LEFT = 0 47 | switch (label->text_align){ 48 | case ALIGN_CENTER: 49 | style = SS_CENTER; 50 | break; 51 | case ALIGN_RIGHT: 52 | style = SS_RIGHT; 53 | break; 54 | default: 55 | case ALIGN_LEFT: 56 | style = SS_LEFT | SS_LEFTNOWORDWRAP; 57 | break; 58 | } 59 | 60 | // resize label when text is changed 61 | window->auto_resize = TRUE; 62 | 63 | // Creating the Window 64 | hwnd = CreateWindow( 65 | L"STATIC", 66 | text, 67 | // Control Styles: 68 | WS_VISIBLE | WS_CHILD | SS_NOPREFIX | style, 69 | window->left, // x position 70 | window->top, // y position 71 | window->pref_width, // width 72 | window->pref_height, // height 73 | parent->hwnd, // Parent window 74 | (HANDLE) control->id, // Control ID 75 | window->hInstance, 76 | NULL ); 77 | 78 | window->hwnd = hwnd; 79 | 80 | g_controlProc = (WNDPROC) SetWindowLongPtr( hwnd, GWLP_WNDPROC, (LONG_PTR) WndProc ); 81 | 82 | // resize to fit the contents of the label 83 | win32_label_auto_resize (window, text); 84 | 85 | free (text); 86 | 87 | return hwnd; 88 | } 89 | 90 | 91 | /* PROPERTY SET TEXT-ALIGNMENT 92 | ------------------------------------------- */ 93 | void win32_label_set_text_align (Win32Label *instance, int alignment) 94 | { 95 | Win32Window *window = (Win32Window*) instance; 96 | 97 | /* NOOP */ 98 | if (instance->text_align == alignment) return; 99 | /* RANGE CHECK */ 100 | if (alignment < ALIGN_LEFT || alignment > ALIGN_RIGHT) return; 101 | 102 | instance->text_align = (int) alignment; 103 | 104 | if (window->hwnd != NULL) 105 | { 106 | DWORD new_style; // Default is SS_LEFT = 0 107 | LONG_PTR style; 108 | 109 | switch (alignment){ 110 | case ALIGN_CENTER: 111 | new_style = SS_CENTER; 112 | break; 113 | case ALIGN_RIGHT: 114 | new_style = SS_RIGHT; 115 | break; 116 | default: 117 | case ALIGN_LEFT: 118 | new_style = SS_LEFT | SS_LEFTNOWORDWRAP; 119 | break; 120 | } 121 | style = GetWindowLongPtr( window->hwnd, GWL_STYLE ); 122 | // Clear the previous alignment style then apply the new one 123 | style = ( style & ~(SS_LEFT | SS_CENTER | SS_RIGHT | SS_LEFTNOWORDWRAP) ) | new_style; 124 | SetWindowLongPtr( window->hwnd, GWL_STYLE, style ); 125 | InvalidateRect( window->hwnd, NULL, TRUE ); 126 | } 127 | } 128 | 129 | 130 | /* PROPERTY GET TEXT-ALIGNMENT 131 | ------------------------------------------- */ 132 | int win32_label_get_text_align (Win32Label *instance) 133 | { 134 | return instance->text_align; 135 | } 136 | 137 | 138 | /* INTERNAL VIRTUAL PROCEDURE 139 | ------------------------------------------- */ 140 | void win32_label_auto_resize (Win32Window *window, const void *data) 141 | { 142 | // respect the user-provided lengths 143 | if ( window->pref_width != 0 && window->pref_height != 0 ) return; 144 | if (!window->hwnd) return; 145 | 146 | SIZE size; 147 | wchar_t *text = (wchar_t*) data; 148 | int length = lstrlen(text); 149 | 150 | HDC context = GetDC(window->hwnd); 151 | if ( length == 0 ) GetTextExtentPoint32 (context, L"Dummy", 5, &size ); 152 | else GetTextExtentPoint32 (context, text, length, &size ); 153 | ReleaseDC (window->hwnd, context); 154 | 155 | if (window->pref_width) size.cx = window->pref_width; 156 | if (window->pref_height) size.cy = window->pref_height; 157 | 158 | window->width = size.cx; 159 | window->height = size.cy; 160 | 161 | win32_window_resize (window, size.cx, size.cy); 162 | } 163 | 164 | 165 | 166 | /* INTERNAL WINDOW PROCEDURE 167 | ------------------------------------------- */ 168 | // the Window Procedure 169 | LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) 170 | { 171 | LRESULT result; 172 | result = win32_window_default_procedure(hwnd, msg, wParam, lParam); 173 | if ( result == STOP_PROPAGATION ) return 0; 174 | 175 | return CallWindowProc( g_controlProc, hwnd, msg, wParam, lParam); 176 | } 177 | 178 | 179 | /* INTERNAL GTYPE 180 | ------------------------------------------- */ 181 | static void win32_label_class_init (Win32LabelClass * klass, gpointer klass_data) 182 | { 183 | win32_label_parent_class = g_type_class_peek_parent (klass); 184 | ((Win32WindowClass *) klass)->finalize = win32_label_finalize; 185 | ((Win32WindowClass *) klass)->auto_resize = win32_label_auto_resize; 186 | } 187 | 188 | static void win32_label_instance_init (Win32Label * self, gpointer klass) 189 | { 190 | } 191 | 192 | /* INTERNAL CLEANUP 193 | ------------------------------------------- */ 194 | static void win32_label_finalize (Win32Window * obj) 195 | { 196 | Win32Label * self; 197 | self = G_TYPE_CHECK_INSTANCE_CAST (obj, WIN32_TYPE_LABEL, Win32Label); 198 | WIN32_WINDOW_CLASS (win32_label_parent_class)->finalize (obj); 199 | } 200 | 201 | 202 | /* INTERNAL GTYPE REGISTRATION 203 | ------------------------------------------- */ 204 | static GType win32_label_get_type_once (void) 205 | { 206 | static const GTypeInfo g_define_type_info = { 207 | sizeof (Win32LabelClass), 208 | (GBaseInitFunc) NULL, 209 | (GBaseFinalizeFunc) NULL, 210 | (GClassInitFunc) win32_label_class_init, 211 | (GClassFinalizeFunc) NULL, 212 | NULL, 213 | sizeof (Win32Label), 214 | 0, 215 | (GInstanceInitFunc) win32_label_instance_init, 216 | NULL 217 | }; 218 | GType win32_label_type_id; 219 | win32_label_type_id = g_type_register_static (WIN32_TYPE_CONTROL, "Win32Label", &g_define_type_info, 0); 220 | return win32_label_type_id; 221 | } 222 | 223 | GType win32_label_get_type (void) 224 | { 225 | static volatile gsize win32_label_type_id__volatile = 0; 226 | if (g_once_init_enter (&win32_label_type_id__volatile)) { 227 | GType win32_label_type_id; 228 | win32_label_type_id = win32_label_get_type_once (); 229 | g_once_init_leave (&win32_label_type_id__volatile, win32_label_type_id); 230 | } 231 | return win32_label_type_id__volatile; 232 | } 233 | -------------------------------------------------------------------------------- /src/label.h: -------------------------------------------------------------------------------- 1 | /*--------------------------------------------------------------------------------------------- 2 | * Copyright (c) 2022 Emre ÖZÇAKIR 3 | * Licensed under the MIT License. See License file in the project root for more information. 4 | *-------------------------------------------------------------------------------------------*/ 5 | 6 | #ifndef _WIN32_LABEL_H_ 7 | #define _WIN32_LABEL_H_ 8 | 9 | #include 10 | #include 11 | #include "window.h" 12 | #include "control.h" 13 | 14 | typedef struct _Win32Label Win32Label; 15 | typedef struct _Win32LabelClass Win32LabelClass; 16 | 17 | #define WIN32_TYPE_LABEL (win32_label_get_type ()) 18 | #define WIN32_LABEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), WIN32_TYPE_LABEL, Win32Label)) 19 | #define WIN32_LABEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), WIN32_TYPE_LABEL, Win32LabelClass)) 20 | #define WIN32_IS_LABEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), WIN32_TYPE_LABEL)) 21 | #define WIN32_IS_LABEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), WIN32_TYPE_LABEL)) 22 | #define WIN32_LABEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), WIN32_TYPE_LABEL, Win32LabelClass)) 23 | 24 | G_DEFINE_AUTOPTR_CLEANUP_FUNC (Win32Label, win32_window_unref) 25 | 26 | /* CLASS Label 27 | ------------------------------------------- */ 28 | struct _Win32Label { 29 | Win32Control parent_instance; 30 | int text_align; 31 | }; 32 | 33 | struct _Win32LabelClass { 34 | Win32ControlClass parent_class; 35 | }; 36 | 37 | Win32Label* win32_label_new (Win32Window* parent, const char * text); 38 | 39 | void win32_label_set_text_align (Win32Label *instance, int alignment); 40 | int win32_label_get_text_align (Win32Label *instance); 41 | 42 | /* INTERNAL */ 43 | GType win32_label_get_type (void) G_GNUC_CONST; 44 | Win32Label* win32_label_construct (GType object_type, Win32Window* parent, const char *text); 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /src/layout.c: -------------------------------------------------------------------------------- 1 | /*--------------------------------------------------------------------------------------------- 2 | * Copyright (c) 2022 Emre ÖZÇAKIR 3 | * Licensed under the MIT License. See License file in the project root for more information. 4 | *-------------------------------------------------------------------------------------------*/ 5 | 6 | #include "vala-win32.h" 7 | #include 8 | 9 | void win32_edge_list_append (Win32EdgeList *list, Win32Window *item, int edge); 10 | BOOL win32_edge_list_includes (Win32EdgeList *list, Win32Window *item, int edge); 11 | void win32_edge_list_prepend_referred_edges (Win32EdgeList *list, Win32Window *item, int edge); 12 | 13 | /* CONSTRUCTOR 14 | ------------------------------------------- */ 15 | Win32RelativeLayout* win32_relative_layout_new (UINT padding, UINT spacing) 16 | { 17 | Win32RelativeLayout *relativeLayout = malloc( sizeof(Win32RelativeLayout) ); 18 | memset( relativeLayout, 0, sizeof(Win32RelativeLayout) ); 19 | Win32Layout *layout = (Win32Layout*) relativeLayout; 20 | 21 | // increase reference count 22 | win32_layout_ref( relativeLayout ); 23 | 24 | layout->recalculate = win32_relative_layout_recalculate; 25 | layout->configure = win32_relative_layout_configure; 26 | relativeLayout->vPadding = padding; 27 | relativeLayout->hPadding = padding; 28 | relativeLayout->hSpacing = spacing; 29 | relativeLayout->vSpacing = spacing; 30 | relativeLayout->scale = 100; 31 | 32 | return relativeLayout; 33 | } 34 | 35 | 36 | /* METHOD SET SCALE 37 | ------------------------------------------- */ 38 | Win32RelativeLayout* win32_relative_layout_set_scale(Win32RelativeLayout* self, UINT scale) 39 | { 40 | self->scale = scale; 41 | return self; 42 | } 43 | 44 | 45 | /* METHOD SET SPACING 46 | ------------------------------------------- */ 47 | Win32RelativeLayout* win32_relative_layout_with_spacing(Win32RelativeLayout* self, UINT vSpacing, UINT hSpacing) 48 | { 49 | self->vSpacing = vSpacing; 50 | self->hSpacing = (hSpacing == -1) ? vSpacing : hSpacing; 51 | return self; 52 | } 53 | 54 | 55 | /* METHOD SET PADDING 56 | ------------------------------------------- */ 57 | Win32RelativeLayout* win32_relative_layout_with_padding(Win32RelativeLayout* self, UINT vPadding, UINT hPadding) 58 | { 59 | self->vPadding = vPadding; 60 | self->hPadding = (hPadding == -1) ? vPadding : hPadding; 61 | return self; 62 | } 63 | 64 | 65 | /* INTERNAL LAYOUT SETUP 66 | ------------------------------------------- */ 67 | void win32_relative_layout_configure(Win32Container* container) 68 | { 69 | Win32RelativeLayout *layout = (Win32RelativeLayout*) container->layout; 70 | 71 | Win32Window ** children = container->childWindows.items; 72 | size_t numChildren = container->childWindows.length; 73 | 74 | // initialize lists 75 | free(layout->edgeList.items); // freeing an empty list (i.e. NULL pointer) is OK 76 | layout->edgeList.length = numChildren * 4; 77 | layout->edgeList.items = malloc( sizeof(Win32EdgeListItem) * layout->edgeList.length ); 78 | memset( layout->edgeList.items, 0, sizeof(Win32EdgeListItem) * layout->edgeList.length ); 79 | 80 | Win32Window *child; 81 | Win32Window *reference; 82 | Win32Anchor *anchor, *pair; 83 | // Re-arrange children 84 | int edge, pairEdge; 85 | for (int i=0; iedgeList, child, edge) ) continue; 93 | 94 | win32_edge_list_prepend_referred_edges (&layout->edgeList, child, edge ); 95 | win32_edge_list_append (&layout->edgeList, child, edge ); 96 | }// END LOOP 97 | 98 | }// END OUTER LOOP 99 | } 100 | 101 | 102 | /* INTERNAL LAYOUT UTILITY 103 | ------------------------------------------- */ 104 | void win32_edge_list_prepend_referred_edges(Win32EdgeList *list, Win32Window *item, int edge) 105 | { 106 | Win32Window *child = item; 107 | Win32Anchor *anchor, *pair; 108 | int pairEdge; 109 | 110 | switch (edge){ 111 | case EDGE_LEFT: 112 | anchor = child->positioning->left; 113 | pair = child->positioning->right; 114 | pairEdge = EDGE_RIGHT; 115 | break; 116 | case EDGE_TOP: 117 | anchor = child->positioning->top; 118 | pair = child->positioning->bottom; 119 | pairEdge = EDGE_BOTTOM; 120 | break; 121 | case EDGE_RIGHT: 122 | anchor = child->positioning->right; 123 | pair = child->positioning->left; 124 | pairEdge = EDGE_LEFT; 125 | break; 126 | case EDGE_BOTTOM: 127 | anchor = child->positioning->bottom; 128 | pair = child->positioning->top; 129 | pairEdge = EDGE_TOP; 130 | break; 131 | } 132 | // NULL anchor 133 | if ( !anchor ){ 134 | // LEFT-RIGHT and TOP-BOTTOM edges are considered pairs. 135 | // If only one element of a pair is NULL, the calculated value of the 136 | // NULL anchor will be dependent upon the non-null pair. 137 | if ( pair && !win32_edge_list_includes(list, child, pairEdge) ) 138 | { 139 | win32_edge_list_prepend_referred_edges(list, child, pairEdge); 140 | win32_edge_list_append(list, child, pairEdge); 141 | } 142 | return; 143 | } 144 | // Anchored to the parent 145 | if (!anchor->reference) return; 146 | 147 | // Anchored to a sibling 148 | if (anchor->edge == 0){ 149 | switch (edge){ 150 | case EDGE_LEFT: anchor->edge = EDGE_RIGHT; 151 | break; 152 | case EDGE_TOP: anchor->edge = EDGE_BOTTOM; 153 | break; 154 | case EDGE_RIGHT: anchor->edge = EDGE_LEFT; 155 | break; 156 | case EDGE_BOTTOM: anchor->edge = EDGE_TOP; 157 | break; 158 | } 159 | } 160 | // Check if the anchored window's edge is already in the list 161 | if ( win32_edge_list_includes(list, anchor->reference, anchor->edge) ) return; 162 | 163 | win32_edge_list_prepend_referred_edges(list, anchor->reference, anchor->edge); 164 | win32_edge_list_append(list, anchor->reference, anchor->edge); 165 | } 166 | 167 | 168 | /* INTERNAL LAYOUT UTILITY 169 | ------------------------------------------- */ 170 | void win32_edge_list_append(Win32EdgeList *list, Win32Window *item, int edge) 171 | { 172 | // insert the item into the first available spot 173 | size_t length = list->length; 174 | for ( int i=0; iitems[i].window == NULL ){ 176 | list->items[i].window = item; 177 | list->items[i].edge = edge; 178 | break; 179 | } 180 | } 181 | } 182 | 183 | 184 | /* INTERNAL LAYOUT UTILITY 185 | ------------------------------------------- */ 186 | BOOL win32_edge_list_includes(Win32EdgeList *list, Win32Window *item, int edge) 187 | { 188 | size_t length = list->length; 189 | for ( int i=0; iitems[i].window == item && list->items[i].edge == edge ) return TRUE; 191 | } 192 | return FALSE; 193 | } 194 | 195 | 196 | /* INTERNAL LAYOUT CHILDREN 197 | ------------------------------------------- */ 198 | void win32_relative_layout_recalculate(Win32Container* container) 199 | { 200 | Win32RelativeLayout *layout = (Win32RelativeLayout*) container->layout; 201 | Win32Window * window = (Win32Window*) container; 202 | 203 | double scale = (double) layout->scale; 204 | UINT halfSpacing_L = layout->vSpacing / 2 + (layout->vSpacing % 2); 205 | UINT halfSpacing_R = layout->vSpacing / 2; 206 | UINT halfSpacing_T = layout->hSpacing / 2 + (layout->hSpacing % 2); 207 | UINT halfSpacing_B = layout->hSpacing / 2; 208 | 209 | RECT rect; 210 | GetClientRect( window->hwnd, &rect); 211 | int containerWidth = rect.right - rect.left - 2 * layout->vPadding + layout->vSpacing; 212 | int containerHeight = rect.bottom - rect.top - 2 * layout->hPadding + layout->hSpacing; 213 | 214 | Win32EdgeList *edgeList = &layout->edgeList; 215 | 216 | Win32Window *child; 217 | Win32Window *reference; 218 | int *left, *top, *bottom, *right, withPadding; 219 | for (int i=0; i< edgeList->length; i++) 220 | { 221 | child = edgeList->items[i].window; 222 | 223 | switch ( edgeList->items[i].edge ) 224 | { 225 | case EDGE_LEFT: 226 | left = &child->positioning->_left; 227 | 228 | if ( child->positioning->left ){ 229 | // Positioning relative to a sibling 230 | // [!] Assignment is intentional 231 | if ( reference = child->positioning->left->reference ){ 232 | if ( child->positioning->left->edge == EDGE_RIGHT ){ 233 | *left = reference->positioning->_right + layout->vSpacing;; 234 | } else if ( child->positioning->left->edge == EDGE_LEFT ){ 235 | *left = reference->positioning->_left; 236 | } 237 | // Positioning relative to the parent 238 | } else { 239 | *left = child->positioning->left->ratio / scale * containerWidth; 240 | // Add spacing 241 | *left += halfSpacing_R; 242 | } 243 | // No anchor is provided 244 | } else if (child->positioning->right){ 245 | *left = child->positioning->_right - child->width; 246 | } else { 247 | *left = halfSpacing_R; // 0 248 | } 249 | break; 250 | 251 | case EDGE_TOP: 252 | top = &child->positioning->_top; 253 | 254 | if ( child->positioning->top ){ 255 | // Positioning relative to a sibling 256 | // [!] Assignment is intentional 257 | if ( reference = child->positioning->top->reference ){ 258 | if ( child->positioning->top->edge == EDGE_BOTTOM ){ 259 | *top = reference->positioning->_bottom + layout->hSpacing; 260 | } else if ( child->positioning->top->edge == EDGE_TOP ){ 261 | *top = reference->positioning->_top; 262 | } 263 | // Positioning relative to the parent 264 | } else { 265 | *top = child->positioning->top->ratio / scale * containerHeight; 266 | // Add spacing 267 | *top += halfSpacing_B; 268 | } 269 | // No anchor is provided 270 | } else if (child->positioning->bottom){ 271 | *top = child->positioning->_bottom - child->height; 272 | } else { 273 | *top = halfSpacing_B; // 0 274 | } 275 | break; 276 | 277 | case EDGE_RIGHT: 278 | right = &child->positioning->_right; 279 | 280 | if ( child->positioning->right ){ 281 | // Positioning relative to a sibling 282 | // [!] Assignment is intentional 283 | if ( reference = child->positioning->right->reference ){ 284 | if ( child->positioning->right->edge == EDGE_RIGHT ){ 285 | *right = reference->positioning->_right; 286 | } else if ( child->positioning->right->edge == EDGE_LEFT ){ 287 | *right = reference->positioning->_left - layout->vSpacing; 288 | } 289 | // Positioning relative to the parent 290 | } else { 291 | *right = child->positioning->right->ratio / scale * containerWidth; 292 | // Add spacing 293 | *right -= halfSpacing_L; 294 | } 295 | // No anchor is provided 296 | } else *right = child->positioning->_left + child->width; 297 | 298 | break; 299 | 300 | case EDGE_BOTTOM: 301 | bottom = &child->positioning->_bottom; 302 | 303 | if ( child->positioning->bottom ){ 304 | // Positioning relative to a sibling 305 | // [!] Assignment is intentional 306 | if ( reference = child->positioning->bottom->reference ){ 307 | if ( child->positioning->bottom->edge == EDGE_BOTTOM ){ 308 | *bottom = reference->positioning->_bottom; 309 | } else if ( child->positioning->bottom->edge == EDGE_TOP ){ 310 | *bottom = reference->positioning->_top - layout->hSpacing; 311 | } 312 | // Positioning relative to the parent 313 | } else { 314 | *bottom = child->positioning->bottom->ratio / scale * containerHeight; 315 | // Add spacing 316 | *bottom -= halfSpacing_T; 317 | } 318 | // No anchor is provided 319 | } else *bottom = child->positioning->_top + child->height; 320 | 321 | break; 322 | } 323 | }// END LOOP 324 | 325 | int width, height; 326 | size_t numChildren = container->childWindows.length; 327 | for (int i=0; ichildWindows.items[i]; 330 | 331 | width = child->positioning->_right - child->positioning->_left; 332 | height = child->positioning->_bottom - child->positioning->_top; 333 | 334 | win32_window_move_and_resize ( (Win32Window*) child, child->positioning->_left + layout->vPadding - halfSpacing_R, 335 | child->positioning->_top + layout->hPadding - halfSpacing_B, width, height); 336 | 337 | } 338 | } 339 | 340 | 341 | /* INTERNAL REF LAYOUT 342 | ------------------------------------------- */ 343 | void* win32_layout_ref (void* instance) 344 | { 345 | Win32Layout * self = instance; 346 | g_atomic_int_inc (&self->ref_count); 347 | return self; 348 | } 349 | 350 | 351 | /* INTERNAL UNREF LAYOUT 352 | ------------------------------------------- */ 353 | void win32_layout_unref (void* instance) 354 | { 355 | Win32Layout * self = instance; 356 | if (g_atomic_int_dec_and_test (&self->ref_count)) { 357 | free (self); 358 | } 359 | } 360 | 361 | /*┌────────────────────────────────────────────────────────┐ 362 | │ ANCHOR │ 363 | └────────────────────────────────────────────────────────┘*/ 364 | 365 | /* CONSTRUCT 366 | ------------------------------------------- */ 367 | Win32Anchor *win32_anchor_to_parent( UINT ratio, int offset ) 368 | { 369 | Win32Anchor* anchor = malloc( sizeof(Win32Anchor) ); 370 | memset( anchor, 0, sizeof(Win32Anchor) ); 371 | 372 | // increase reference count 373 | win32_anchor_ref( anchor ); 374 | 375 | anchor->ratio = ratio; 376 | anchor->offset = offset; 377 | 378 | return anchor; 379 | } 380 | 381 | 382 | /* CONSTRUCT 383 | ------------------------------------------- */ 384 | Win32Anchor *win32_anchor_to_sibling( Win32Window *sibling, int offset ) 385 | { 386 | Win32Anchor* anchor = malloc( sizeof(Win32Anchor) ); 387 | memset( anchor, 0, sizeof(Win32Anchor) ); 388 | 389 | // increase reference count 390 | win32_anchor_ref( anchor ); 391 | 392 | anchor->reference = sibling; 393 | anchor->offset = offset; 394 | 395 | return anchor; 396 | } 397 | 398 | 399 | /* METHOD TO EDGE 400 | ------------------------------------------- */ 401 | Win32Anchor *win32_anchor_to_edge(Win32Anchor *self, int edge) 402 | { 403 | self->edge = edge; 404 | return self; 405 | } 406 | 407 | 408 | /* METHOD WITH OFFSET 409 | ------------------------------------------- */ 410 | Win32Anchor *win32_anchor_with_offset(Win32Anchor *self, int offset) 411 | { 412 | self->offset = offset; 413 | return self; 414 | } 415 | 416 | 417 | /* INTERNAL REF ANCHOR 418 | ------------------------------------------- */ 419 | void* win32_anchor_ref (void* instance) 420 | { 421 | Win32Anchor * self = (Win32Anchor *) instance; 422 | g_atomic_int_inc (&self->ref_count); 423 | return self; 424 | } 425 | 426 | 427 | /* INTERNAL UNREF ANCHOR 428 | ------------------------------------------- */ 429 | void win32_anchor_unref (void* instance) 430 | { 431 | Win32Anchor * self = instance; 432 | if (g_atomic_int_dec_and_test (&self->ref_count)) { 433 | free (self); 434 | } 435 | } 436 | 437 | 438 | /*┌────────────────────────────────────────────────────────┐ 439 | │ LAYOUT DATA │ 440 | └────────────────────────────────────────────────────────┘*/ 441 | Win32LayoutData *win32_layout_data_new (void) 442 | { 443 | Win32LayoutData *instance; 444 | 445 | instance = malloc( sizeof(Win32LayoutData) ); 446 | memset( instance, 0, sizeof(Win32LayoutData) ); 447 | win32_layout_data_ref (instance); 448 | 449 | return instance; 450 | } 451 | 452 | /* PROPERTY SET LEFT 453 | ------------------------------------------- */ 454 | void win32_layout_data_set_left (Win32LayoutData *instance, Win32Anchor* anchor) 455 | { 456 | if ( instance->left != NULL ){ 457 | if (instance->left == anchor ) return; 458 | // decrease the reference count of the existing anchor 459 | win32_anchor_unref( instance->left ); 460 | } 461 | 462 | // increase reference count 463 | win32_anchor_ref( anchor ); 464 | 465 | instance->left = anchor; 466 | } 467 | 468 | 469 | /* PROPERTY GET LEFT 470 | ------------------------------------------- */ 471 | Win32Anchor* win32_layout_data_get_left (Win32LayoutData *instance) 472 | { 473 | return instance->left; 474 | } 475 | 476 | 477 | /* PROPERTY SET TOP 478 | ------------------------------------------- */ 479 | void win32_layout_data_set_top (Win32LayoutData *instance, Win32Anchor* anchor) 480 | { 481 | if ( instance->top != NULL ){ 482 | if (instance->top == anchor ) return; 483 | // decrease the reference count of the existing anchor 484 | win32_anchor_unref( instance->top ); 485 | } 486 | 487 | // increase reference count 488 | win32_anchor_ref( anchor ); 489 | 490 | instance->top = anchor; 491 | } 492 | 493 | 494 | /* PROPERTY GET TOP 495 | ------------------------------------------- */ 496 | Win32Anchor* win32_layout_data_get_top (Win32LayoutData *instance) 497 | { 498 | return instance->top; 499 | } 500 | 501 | 502 | /* PROPERTY SET RIGHT 503 | ------------------------------------------- */ 504 | void win32_layout_data_set_right (Win32LayoutData *instance, Win32Anchor* anchor) 505 | { 506 | if ( instance->right != NULL ){ 507 | if (instance->right == anchor ) return; 508 | // decrease the reference count of the existing anchor 509 | win32_anchor_unref( instance->right ); 510 | } 511 | 512 | // increase reference count 513 | win32_anchor_ref( anchor ); 514 | 515 | instance->right = anchor; 516 | } 517 | 518 | 519 | /* PROPERTY GET RIGHT 520 | ------------------------------------------- */ 521 | Win32Anchor* win32_layout_data_get_right (Win32LayoutData *instance) 522 | { 523 | return instance->right; 524 | } 525 | 526 | 527 | /* PROPERTY SET BOTTOM 528 | ------------------------------------------- */ 529 | void win32_layout_data_set_bottom (Win32LayoutData *instance, Win32Anchor* anchor) 530 | { 531 | if ( instance->bottom != NULL ){ 532 | if (instance->bottom == anchor ) return; 533 | // decrease the reference count of the existing anchor 534 | win32_anchor_unref( instance->bottom ); 535 | } 536 | 537 | // increase reference count 538 | win32_anchor_ref( anchor ); 539 | 540 | instance->bottom = anchor; 541 | } 542 | 543 | 544 | /* PROPERTY GET BOTTOM 545 | ------------------------------------------- */ 546 | Win32Anchor* win32_layout_data_get_bottom (Win32LayoutData *instance) 547 | { 548 | return instance->bottom; 549 | } 550 | 551 | 552 | /* INTERNAL REF LAYOUT DATA 553 | ------------------------------------------- */ 554 | void* win32_layout_data_ref (void* instance) 555 | { 556 | Win32LayoutData * self = instance; 557 | g_atomic_int_inc (&self->ref_count); 558 | return self; 559 | } 560 | 561 | 562 | /* INTERNAL UNREF LAYOUT DATA 563 | ------------------------------------------- */ 564 | void win32_layout_data_unref (void* instance) 565 | { 566 | Win32LayoutData * self = instance; 567 | if (g_atomic_int_dec_and_test (&self->ref_count)) { 568 | free (self); 569 | } 570 | } 571 | -------------------------------------------------------------------------------- /src/layout.h: -------------------------------------------------------------------------------- 1 | /*--------------------------------------------------------------------------------------------- 2 | * Copyright (c) 2022 Emre ÖZÇAKIR 3 | * Licensed under the MIT License. See License file in the project root for more information. 4 | *-------------------------------------------------------------------------------------------*/ 5 | 6 | #ifndef _WIN32_LAYOUT_H_ 7 | #define _WIN32_LAYOUT_H_ 8 | 9 | #include 10 | #include 11 | 12 | #define EDGE_LEFT 1 13 | #define EDGE_TOP 2 14 | #define EDGE_RIGHT 4 15 | #define EDGE_BOTTOM 8 16 | 17 | #define _win32_anchor_unref0(var) ((var == NULL) ? NULL : (var = (win32_anchor_unref (var), NULL))) 18 | #define _win32_layout_unref0(var) ((var == NULL) ? NULL : (var = (win32_layout_unref (var), NULL))) 19 | 20 | /* CLASS Anchor 21 | ------------------------------------------- */ 22 | typedef struct _Win32Anchor { 23 | volatile int ref_count; 24 | Win32Window *reference; 25 | UINT ratio; 26 | int offset; 27 | int edge; 28 | } Win32Anchor; 29 | 30 | Win32Anchor *win32_anchor_to_parent( UINT ratio, int offset ); 31 | Win32Anchor *win32_anchor_to_sibling( Win32Window *sibling, int offset ); 32 | 33 | Win32Anchor *win32_anchor_to_edge(Win32Anchor *instance, int edge); 34 | Win32Anchor *win32_anchor_with_offset(Win32Anchor *instance, int offset); 35 | 36 | /* INTERNAL */ 37 | void* win32_anchor_ref (void*); 38 | void win32_anchor_unref (void*); 39 | 40 | /* CLASS LayoutData 41 | ------------------------------------------- */ 42 | typedef struct _Win32LayoutData { 43 | volatile int ref_count; 44 | Win32Anchor *left; 45 | Win32Anchor *top; 46 | Win32Anchor *right; 47 | Win32Anchor *bottom; 48 | int _left; 49 | int _top; 50 | int _right; 51 | int _bottom; 52 | int _width; 53 | int _height; 54 | } Win32LayoutData; 55 | 56 | Win32LayoutData* win32_layout_data_new (void); 57 | 58 | void win32_layout_data_set_left (Win32LayoutData *instance, Win32Anchor* anchor); 59 | Win32Anchor* win32_layout_data_get_left (Win32LayoutData *instance); 60 | 61 | void win32_layout_data_set_top (Win32LayoutData *instance, Win32Anchor* anchor); 62 | Win32Anchor* win32_layout_data_get_top (Win32LayoutData *instance); 63 | 64 | void win32_layout_data_set_right (Win32LayoutData *instance, Win32Anchor* anchor); 65 | Win32Anchor* win32_layout_data_get_right (Win32LayoutData *instance); 66 | 67 | void win32_layout_data_set_bottom (Win32LayoutData *instance, Win32Anchor* anchor); 68 | Win32Anchor* win32_layout_data_get_bottom (Win32LayoutData *instance); 69 | 70 | /* INTERNAL */ 71 | void* win32_layout_data_ref (void*); 72 | void win32_layout_data_unref (void*); 73 | 74 | 75 | typedef struct _Win32Layout { 76 | volatile int ref_count; 77 | void (*recalculate)(Win32Container *container); 78 | void (*configure) (Win32Container *container); 79 | } Win32Layout; 80 | 81 | /* INTERNAL */ 82 | void* win32_layout_ref (void*); 83 | void win32_layout_unref (void*); 84 | 85 | 86 | /* CLASS RelativeLayout 87 | ------------------------------------------- */ 88 | typedef struct _Win32EdgeListItem { 89 | Win32Window * window; 90 | int edge; 91 | } Win32EdgeListItem; 92 | 93 | typedef struct _Win32EdgeList { 94 | Win32EdgeListItem * items; 95 | size_t length; 96 | } Win32EdgeList; 97 | 98 | typedef struct _Win32RelativeLayout { 99 | Win32Layout layout; 100 | UINT vPadding; 101 | UINT hPadding; 102 | UINT hSpacing; 103 | UINT vSpacing; 104 | UINT scale; 105 | Win32EdgeList edgeList; 106 | } Win32RelativeLayout; 107 | 108 | Win32RelativeLayout* win32_relative_layout_new (UINT padding, UINT spacing); 109 | Win32RelativeLayout* win32_relative_layout_set_scale(Win32RelativeLayout* self, UINT scale); 110 | Win32RelativeLayout* win32_relative_layout_with_spacing(Win32RelativeLayout* self, UINT vSpacing, UINT hSpacing); 111 | Win32RelativeLayout* win32_relative_layout_with_padding(Win32RelativeLayout* self, UINT vPadding, UINT hPadding); 112 | void win32_relative_layout_recalculate(Win32Container* container); 113 | void win32_relative_layout_configure(Win32Container* container); 114 | 115 | 116 | #endif 117 | -------------------------------------------------------------------------------- /src/utilities.c: -------------------------------------------------------------------------------- 1 | /*--------------------------------------------------------------------------------------------- 2 | * Copyright (c) 2022 Emre ÖZÇAKIR 3 | * Licensed under the MIT License. See License file in the project root for more information. 4 | *-------------------------------------------------------------------------------------------*/ 5 | 6 | #include "utilities.h" 7 | 8 | /* UTILITY 9 | ------------------------------------------- */ 10 | HFONT win32_get_default_gui_font(void) 11 | { 12 | static HFONT hFont = NULL; 13 | 14 | if (hFont) return hFont; 15 | 16 | NONCLIENTMETRICS ncMetrics; 17 | ncMetrics.cbSize = sizeof(NONCLIENTMETRICS); 18 | SystemParametersInfo( SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS), &ncMetrics, 0 ); 19 | hFont = CreateFontIndirect(&ncMetrics.lfMessageFont); 20 | 21 | return hFont; 22 | } 23 | 24 | 25 | /* UTILITY 26 | ------------------------------------------- */ 27 | wchar_t* fromUTF8 (const char* src) 28 | { 29 | if(!src) return NULL; 30 | 31 | int des_len = MultiByteToWideChar(CP_UTF8, 0, src, -1, 0, 0); 32 | wchar_t *buffer = malloc( (des_len) * sizeof(wchar_t) ); 33 | 34 | if (buffer) { 35 | MultiByteToWideChar(CP_UTF8, 0, src, -1, buffer, des_len); 36 | } 37 | 38 | return buffer; 39 | } 40 | 41 | /* UTILITY 42 | ------------------------------------------- */ 43 | char* toUTF8(const wchar_t* src) 44 | { 45 | if(!src) return NULL; 46 | 47 | int des_len = WideCharToMultiByte(CP_UTF8, 0, src, -1, 0, 0, NULL, NULL); 48 | char *buffer = malloc( (des_len) * sizeof(char) ); 49 | 50 | if (buffer) { 51 | WideCharToMultiByte(CP_UTF8, 0, src, -1, buffer, des_len, NULL, NULL); 52 | } 53 | 54 | return buffer; 55 | } 56 | -------------------------------------------------------------------------------- /src/utilities.h: -------------------------------------------------------------------------------- 1 | /*--------------------------------------------------------------------------------------------- 2 | * Copyright (c) 2022 Emre ÖZÇAKIR 3 | * Licensed under the MIT License. See License file in the project root for more information. 4 | *-------------------------------------------------------------------------------------------*/ 5 | 6 | #ifndef WIN32_UTILITIES_H 7 | #define WIN32_UTILITIES_H 8 | 9 | #include 10 | #include 11 | #include 12 | 13 | wchar_t* fromUTF8 (const char* src); 14 | char* toUTF8 (const wchar_t* src); 15 | HFONT win32_get_default_gui_font(void); 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /src/vala-win32.h: -------------------------------------------------------------------------------- 1 | /*--------------------------------------------------------------------------------------------- 2 | * Copyright (c) 2022 Emre ÖZÇAKIR 3 | * Licensed under the MIT License. See License file in the project root for more information. 4 | *-------------------------------------------------------------------------------------------*/ 5 | 6 | #ifndef WIN32_APPLICATION_H 7 | #define WIN32_APPLICATION_H 8 | 9 | #define UNICODE 10 | #define _UNICODE 11 | 12 | #define WINVER 0x0601 // Windows 7 13 | 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | 21 | #define INITIAL_LIST_SIZE 16 // Initial size and also the growing size of the event list 22 | #define INITIAL_QUEUE_SIZE 2 // the same for the callback list 23 | 24 | #define FM_COMMAND 0x4000 // FM: Forwarded Message 25 | #define FM_CLICKED FM_COMMAND 26 | 27 | typedef struct _Win32Window Win32Window; 28 | typedef struct _Win32Container Win32Container; 29 | 30 | #include "utilities.h" 31 | #include "clipboard.h" 32 | #include "wrappers.h" 33 | #include "device-context.h" 34 | #include "layout.h" 35 | #include "window.h" 36 | #include "container.h" 37 | #include "application-window.h" 38 | #include "control.h" 39 | #include "button.h" 40 | #include "label.h" 41 | #include "edit.h" 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /src/window.c: -------------------------------------------------------------------------------- 1 | /*--------------------------------------------------------------------------------------------- 2 | * Copyright (c) 2022 Emre ÖZÇAKIR 3 | * Licensed under the MIT License. See License file in the project root for more information. 4 | *-------------------------------------------------------------------------------------------*/ 5 | 6 | #include "vala-win32.h" 7 | 8 | static gpointer win32_window_parent_class = NULL; 9 | static void win32_window_auto_resize_default (Win32Window *self, const void *data); 10 | static void win32_window_finalize (Win32Window * obj); 11 | static GType win32_window_get_type_once (void); 12 | 13 | 14 | /* METHOD 15 | ------------------------------------------- */ 16 | int win32_window_add_listener( Win32Window *self, 17 | UINT eventID, 18 | Win32Callback callback, 19 | void *boundData, 20 | Win32ReleaseFunction releaseData ) 21 | { 22 | return WIN32_WINDOW_GET_CLASS (self)->add_listener (self, eventID, callback, boundData, releaseData); 23 | } 24 | 25 | 26 | /* INTERNAL INSERT CALLBACK 27 | ------------------------------------------- */ 28 | int win32_window_insert_into_callback_queue ( Win32Window *self, 29 | UINT eventID, 30 | Win32Callback callback, 31 | void *boundData, 32 | Win32ReleaseFunction releaseData ) 33 | { 34 | Win32Window * window = (Win32Window*) self; 35 | Win32EventList * eventList = &window->attachedEvents; 36 | size_t num_ev = eventList->length; 37 | // Check if we have enough room in the list 38 | if ( (num_ev + 1) % INITIAL_LIST_SIZE == 0 ){ 39 | eventList->items = realloc(eventList->items, sizeof(Win32EventListItem) * ((num_ev + 1) + INITIAL_LIST_SIZE) ); 40 | // Initialize newly added slots 41 | memset( eventList->items + (num_ev + 1), 0, sizeof(Win32EventListItem) * INITIAL_LIST_SIZE ); 42 | } 43 | 44 | Win32EventListItem *events = eventList->items; 45 | 46 | // Find the event's index in the list. 47 | // If it's not already in the list, it'll be appended to the list 48 | int i = 0; 49 | while ( events[i].eventID != WM_NULL && events[i].eventID != eventID ) i++; 50 | 51 | if ( events[i].callbacks == NULL ){ 52 | events[i].callbacks = malloc( sizeof(Win32Callback) * INITIAL_QUEUE_SIZE ); 53 | memset( events[i].callbacks, 0, sizeof(Win32Callback) * INITIAL_QUEUE_SIZE ); 54 | // Check if memory allocation fails 55 | events[i].boundData = malloc( sizeof(void*) * INITIAL_QUEUE_SIZE ); 56 | memset( events[i].boundData, 0, sizeof(void*) * INITIAL_QUEUE_SIZE ); 57 | 58 | events[i].releaseData = malloc( sizeof(void*) * INITIAL_QUEUE_SIZE ); 59 | memset( events[i].releaseData, 0, sizeof(void*) * INITIAL_QUEUE_SIZE ); 60 | } 61 | 62 | size_t num_cb = events[i].numCallbacks; 63 | 64 | // Check if we have enough room in the callback queue 65 | if ( (num_cb + 1) % INITIAL_QUEUE_SIZE == 0 ){ 66 | events[i].callbacks = realloc(events[i].callbacks, sizeof(Win32Callback) * ((num_cb + 1) + INITIAL_QUEUE_SIZE) ); 67 | events[i].boundData = realloc(events[i].boundData, sizeof(void*) * ((num_cb + 1) + INITIAL_QUEUE_SIZE) ); 68 | events[i].releaseData = realloc(events[i].releaseData, sizeof(void*) * ((num_cb + 1) + INITIAL_QUEUE_SIZE) ); 69 | // Initialize newly added slots 70 | memset( events[i].callbacks + (num_cb + 1), 0, sizeof(Win32Callback) * INITIAL_QUEUE_SIZE ); 71 | memset( events[i].boundData + (num_cb + 1), 0, sizeof(void*) * INITIAL_QUEUE_SIZE ); 72 | memset( events[i].releaseData + (num_cb + 1), 0, sizeof(void*) * INITIAL_QUEUE_SIZE ); 73 | } 74 | 75 | // We're adding a new event to the list so increase the item count 76 | if (events[i].eventID == 0 ){ 77 | events[i].eventID = eventID; 78 | eventList->length += 1; 79 | } 80 | 81 | events[i].callbacks[num_cb] = callback; 82 | events[i].boundData[num_cb] = boundData; 83 | events[i].releaseData[num_cb] = releaseData; 84 | // increase callback number 85 | events[i].numCallbacks += 1; 86 | return TRUE; 87 | } 88 | 89 | 90 | /* INTERNAL INVOKE CALLBACK 91 | ------------------------------------------- */ 92 | LRESULT invoke_callback (Win32Window *window, UINT msg, WPARAM wParam, LPARAM lParam, Win32Callback callback, void * boundData) 93 | { 94 | Win32Event event; 95 | event.id = msg; 96 | event.source = window; 97 | event.wParam = wParam; 98 | event.lParam = lParam; 99 | event.handled = 0; // Hand over the event to the default window procedure after processing it 100 | 101 | callback( &event, boundData ); 102 | 103 | if ( event.handled == 1 ) return STOP_PROPAGATION; 104 | else return 0; 105 | } 106 | 107 | 108 | /* INTERNAL DEFAULT WINDOW PROCEDURE 109 | ------------------------------------------- */ 110 | LRESULT win32_window_default_procedure(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) 111 | { 112 | Win32Window *window = (Win32Window *) GetWindowLongPtr( hwnd, GWLP_USERDATA); 113 | Win32EventList *eventList = NULL; 114 | Win32EventListItem *events = NULL; 115 | // [!] Assignment is intentional 116 | if ( window != NULL ){ 117 | eventList = &window->attachedEvents; 118 | events = eventList->items; 119 | } 120 | 121 | if ( msg == WM_NCCREATE ){ 122 | //attach the event list to the window 123 | window = ((CREATESTRUCT*) lParam)->lpCreateParams; 124 | window->hwnd = hwnd; 125 | SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR) window); 126 | } else if ( msg == WM_DESTROY ){ 127 | // Clear event list 128 | Win32ReleaseFunction bound_data_unref; 129 | 130 | if (events != NULL){ 131 | int i = 0, n; 132 | // events array is a null terminated list 133 | while ( events[i].eventID != WM_NULL ){ 134 | // callbacks array is a null terminated list 135 | n = 0; 136 | while ( events[i].callbacks[n] != NULL ){ 137 | if ( events[i].releaseData[n] ){ 138 | bound_data_unref = events[i].releaseData[n]; 139 | bound_data_unref( events[i].boundData[n] ); 140 | } 141 | n += 1; 142 | } 143 | free(events[i].callbacks); 144 | free(events[i].boundData); 145 | free(events[i].releaseData); 146 | i += 1; 147 | } 148 | memset( eventList->items, 0, sizeof(Win32EventListItem) * eventList->length ); 149 | eventList->length = 0; 150 | } 151 | }// END IF 152 | 153 | LRESULT result = 0; 154 | // To prevent memory access issues before the list is initialized 155 | if (events != NULL){ 156 | int i = 0, n = 0; 157 | // events array is a null terminated list 158 | while ( events[i].eventID != WM_NULL ){ 159 | // Check if the event has a registered callback 160 | if ( events[i].eventID == msg){ 161 | // callbacks array is a null terminated list 162 | while ( events[i].callbacks[n] != NULL ){ 163 | result = invoke_callback( window, msg, wParam, lParam, events[i].callbacks[n], events[i].boundData[n]); 164 | n += 1; 165 | } 166 | break; // No need to check further events in the list 167 | } 168 | i += 1; 169 | } 170 | }// END IF 171 | return result; 172 | } 173 | 174 | 175 | /* PROPERTY SET LAYOUT DATA 176 | ------------------------------------------- */ 177 | void win32_window_set_positioning (Win32Window *instance, Win32LayoutData* layoutData) 178 | { 179 | if ( instance->positioning != NULL ){ 180 | if (instance->positioning == layoutData ) return; 181 | // decrease the reference count of the existing anchor 182 | win32_layout_data_unref( instance->positioning ); 183 | } 184 | 185 | // increase reference count 186 | instance->positioning = win32_layout_data_ref( layoutData ); 187 | } 188 | 189 | 190 | /* PROPERTY GET LAYOUT DATA 191 | ------------------------------------------- */ 192 | Win32LayoutData* win32_window_get_positioning (Win32Window *window) 193 | { 194 | return window->positioning; 195 | } 196 | 197 | 198 | /* PROPERTY SET LEFT 199 | ------------------------------------------- */ 200 | void win32_window_set_left (Win32Window *window, int left) 201 | { 202 | window->left = left; 203 | 204 | if (window->hwnd != NULL){ 205 | RECT rect; 206 | GetClientRect( window->hwnd, &rect ); 207 | MapWindowPoints( window->hwnd, GetParent(window->hwnd), (LPPOINT) &rect, 2); 208 | 209 | int height = rect.bottom - rect.top; 210 | int width = rect.right - rect.left; 211 | 212 | MoveWindow( window->hwnd, left, rect.top, width, height, /*REPAINT*/ TRUE ); 213 | } 214 | } 215 | 216 | 217 | /* PROPERTY GET LEFT 218 | ------------------------------------------- */ 219 | int win32_window_get_left (Win32Window *window) 220 | { 221 | if (window->hwnd != NULL){ 222 | RECT rect; 223 | GetClientRect( window->hwnd, &rect ); 224 | MapWindowPoints( window->hwnd, GetParent(window->hwnd), (LPPOINT) &rect, 2); 225 | 226 | window->left = rect.left; 227 | } 228 | return window->left; 229 | } 230 | 231 | 232 | /* PROPERTY SET TOP 233 | ------------------------------------------- */ 234 | void win32_window_set_top (Win32Window *window, int top) 235 | { 236 | window->top = top; 237 | 238 | if (window->hwnd != NULL){ 239 | RECT rect; 240 | GetClientRect( window->hwnd, &rect ); 241 | MapWindowPoints( window->hwnd, GetParent(window->hwnd), (LPPOINT) &rect, 2); 242 | 243 | int height = rect.bottom - rect.top; 244 | int width = rect.right - rect.left; 245 | 246 | MoveWindow( window->hwnd, rect.left, top, width, height, /*REPAINT*/ TRUE ); 247 | } 248 | } 249 | 250 | 251 | /* PROPERTY GET TOP 252 | ------------------------------------------- */ 253 | int win32_window_get_top (Win32Window *window) 254 | { 255 | if (window->hwnd != NULL){ 256 | RECT rect; 257 | GetClientRect( window->hwnd, &rect ); 258 | MapWindowPoints( window->hwnd, GetParent(window->hwnd), (LPPOINT) &rect, 2); 259 | window->top = rect.top; 260 | } 261 | return window->top; 262 | } 263 | 264 | 265 | /* PROPERTY SET WIDTH 266 | ------------------------------------------- */ 267 | void win32_window_set_width (Win32Window *window, int width) 268 | { 269 | window->pref_width = width; 270 | 271 | if (window->hwnd != NULL){ 272 | RECT rect; 273 | GetClientRect( window->hwnd, &rect ); 274 | MapWindowPoints( window->hwnd, GetParent(window->hwnd), (LPPOINT) &rect, 2); 275 | 276 | int height = rect.bottom - rect.top; 277 | 278 | MoveWindow( window->hwnd, rect.left, rect.top, width, height, /*REPAINT*/ TRUE ); 279 | } 280 | } 281 | 282 | 283 | /* PROPERTY GET WIDTH 284 | ------------------------------------------- */ 285 | int win32_window_get_width (Win32Window *window) 286 | { 287 | if (window->hwnd != NULL){ 288 | RECT rect; 289 | GetClientRect( window->hwnd, &rect ); 290 | MapWindowPoints( window->hwnd, GetParent(window->hwnd), (LPPOINT) &rect, 2); 291 | 292 | int width = rect.right - rect.left; 293 | return window->width = width; 294 | } 295 | return window->pref_width; 296 | } 297 | 298 | 299 | /* PROPERTY SET HEIGHT 300 | ------------------------------------------- */ 301 | void win32_window_set_height (Win32Window *window, int height) 302 | { 303 | window->pref_height = height; 304 | 305 | if (window->hwnd != NULL){ 306 | RECT rect; 307 | GetClientRect( window->hwnd, &rect ); 308 | MapWindowPoints( window->hwnd, GetParent(window->hwnd), (LPPOINT) &rect, 2); 309 | 310 | int width = rect.right - rect.left; 311 | 312 | MoveWindow( window->hwnd, rect.left, rect.top, width, height, /*REPAINT*/ TRUE ); 313 | } 314 | } 315 | 316 | 317 | /* PROPERTY GET HEIGHT 318 | ------------------------------------------- */ 319 | int win32_window_get_height (Win32Window *window) 320 | { 321 | if (window->hwnd != NULL){ 322 | RECT rect; 323 | GetClientRect( window->hwnd, &rect ); 324 | MapWindowPoints( window->hwnd, GetParent(window->hwnd), (LPPOINT) &rect, 2); 325 | 326 | int height = rect.bottom - rect.top; 327 | return window->height = height; 328 | } 329 | return window->pref_height; 330 | } 331 | 332 | 333 | /* PROPERTY SET TEXT 334 | ------------------------------------------- */ 335 | void win32_window_set_text (Win32Window *window, const char* text) 336 | { 337 | char* tmp0; 338 | wchar_t* tmp1; 339 | tmp0 = window->text; 340 | window->text = _strdup (text); 341 | tmp1 = fromUTF8( window->text ); 342 | 343 | if (window->hwnd != NULL){ 344 | SetWindowText( window->hwnd, tmp1); 345 | if (window->auto_resize){ 346 | WIN32_WINDOW_GET_CLASS(window)->auto_resize(window, tmp1); 347 | } 348 | } 349 | free (tmp1); 350 | free (tmp0); 351 | } 352 | 353 | 354 | /* PROPERTY GET TEXT 355 | ------------------------------------------- */ 356 | char* win32_window_get_text (Win32Window *window) 357 | { 358 | if (window->hwnd == NULL) return window->text; 359 | 360 | int bufferSize = GetWindowTextLength(window->hwnd); 361 | 362 | if ( bufferSize == 0 ) return ""; //NULL; 363 | 364 | wchar_t * buffer = malloc( sizeof(wchar_t) * (bufferSize+1) ); 365 | memset(buffer, 0, sizeof(wchar_t) * (bufferSize+1) ); 366 | GetWindowText(window->hwnd, buffer, bufferSize+1); 367 | 368 | char * tmp0 = window->text; 369 | window->text = toUTF8( buffer ); 370 | 371 | free (tmp0); 372 | free (buffer); 373 | 374 | return window->text; 375 | } 376 | 377 | 378 | /* PROPERTY SET ENABLED 379 | ------------------------------------------- */ 380 | void win32_window_set_enabled (Win32Window *self, BOOL isEnabled) 381 | { 382 | self->enabled = isEnabled; 383 | 384 | if (self->hwnd != NULL){ 385 | EnableWindow(self->hwnd, isEnabled); 386 | } 387 | } 388 | 389 | 390 | /* PROPERTY GET ENABLED 391 | ------------------------------------------- */ 392 | BOOL win32_window_get_enabled (Win32Window *self) 393 | { 394 | if (self->hwnd != NULL){ 395 | self->enabled = IsWindowEnabled(self->hwnd); 396 | } 397 | return self->enabled; 398 | } 399 | 400 | 401 | /* METHOD 402 | ------------------------------------------- */ 403 | void win32_window_move (Win32Window *window, int left, int top) 404 | { 405 | window->left = left; 406 | window->top = top; 407 | 408 | if (window->hwnd != NULL){ 409 | RECT rect; 410 | GetWindowRect( window->hwnd, &rect); 411 | 412 | int height = rect.bottom - rect.top; 413 | int width = rect.right - rect.left; 414 | 415 | MoveWindow( window->hwnd, left, top, width, height, /*REPAINT*/ TRUE ); 416 | } 417 | } 418 | 419 | 420 | /* METHOD 421 | ------------------------------------------- */ 422 | void win32_window_resize (Win32Window *window, int width, int height) 423 | { 424 | window->width = width; 425 | window->height = height; 426 | 427 | if (window->hwnd != NULL){ 428 | RECT rect; 429 | GetClientRect( window->hwnd, &rect); 430 | MapWindowPoints( window->hwnd, GetParent(window->hwnd), (LPPOINT) &rect, 2); 431 | MoveWindow( window->hwnd, rect.left, rect.top, width, height, /*REPAINT*/ TRUE ); 432 | } 433 | } 434 | 435 | 436 | /* METHOD 437 | ------------------------------------------- */ 438 | void win32_window_move_and_resize (Win32Window *window, int left, int top, int width, int height) 439 | { 440 | window->left = left; 441 | window->top = top; 442 | window->width = width; 443 | window->height = height; 444 | 445 | if (window->hwnd != NULL){ 446 | RECT *rect = malloc( sizeof(RECT) ); 447 | GetWindowRect( window->hwnd, rect); 448 | MoveWindow( window->hwnd, left, top, width, height, /*REPAINT*/ TRUE ); 449 | free (rect); 450 | } 451 | } 452 | 453 | 454 | /* METHOD 455 | ------------------------------------------- */ 456 | HDC win32_window_begin_paint(Win32Window *window, PAINTSTRUCT *ps) 457 | { 458 | return BeginPaint (window->hwnd, ps); 459 | } 460 | 461 | 462 | /* METHOD 463 | ------------------------------------------- */ 464 | void win32_window_end_paint(Win32Window *window, PAINTSTRUCT *ps) 465 | { 466 | EndPaint (window->hwnd, ps); 467 | } 468 | 469 | /* METHOD 470 | ------------------------------------------- */ 471 | Win32Rect* win32_window_get_window_rect(Win32Window *window) 472 | { 473 | Win32Rect *result = malloc( sizeof(Win32Rect) ); 474 | memset( result, 0, sizeof(Win32Rect) ); 475 | g_atomic_int_inc (&result->ref_count); 476 | if ( GetWindowRect( window->hwnd, (RECT*) result) ) return result; 477 | else return NULL; 478 | } 479 | 480 | 481 | /* METHOD 482 | ------------------------------------------- */ 483 | Win32Rect* win32_window_get_client_rect(Win32Window *window) 484 | { 485 | Win32Rect *result = malloc( sizeof(Win32Rect) ); 486 | memset( result, 0, sizeof(Win32Rect) ); 487 | g_atomic_int_inc (&result->ref_count); 488 | if ( GetClientRect( window->hwnd, (RECT*) result) ) return result; 489 | else return NULL; 490 | } 491 | 492 | 493 | /* INTERNAL VIRTUAL METHOD 494 | ------------------------------------------- */ 495 | void win32_window_auto_resize_default (Win32Window *self, const void *data) 496 | { 497 | // NO-OP 498 | } 499 | 500 | 501 | /* INTERNAL GTYPE 502 | ------------------------------------------- */ 503 | static void value_win32_window_init (GValue* value) 504 | { 505 | value->data[0].v_pointer = NULL; 506 | } 507 | 508 | static void value_win32_window_free_value (GValue* value) 509 | { 510 | if (value->data[0].v_pointer) { 511 | win32_window_unref (value->data[0].v_pointer); 512 | } 513 | } 514 | 515 | static void value_win32_window_copy_value (const GValue* src_value, GValue* dest_value) 516 | { 517 | if (src_value->data[0].v_pointer) { 518 | dest_value->data[0].v_pointer = win32_window_ref (src_value->data[0].v_pointer); 519 | } else { 520 | dest_value->data[0].v_pointer = NULL; 521 | } 522 | } 523 | 524 | gpointer value_get_win32_window (const GValue* value) 525 | { 526 | g_return_val_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, WIN32_TYPE_WINDOW), NULL); 527 | return value->data[0].v_pointer; 528 | } 529 | 530 | void value_set_win32_window (GValue* value, gpointer v_object) 531 | { 532 | Win32Window * old; 533 | g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, WIN32_TYPE_WINDOW)); 534 | old = value->data[0].v_pointer; 535 | if (v_object) { 536 | g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, WIN32_TYPE_WINDOW)); 537 | g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value))); 538 | value->data[0].v_pointer = v_object; 539 | win32_window_ref (value->data[0].v_pointer); 540 | } else { 541 | value->data[0].v_pointer = NULL; 542 | } 543 | if (old) { 544 | win32_window_unref (old); 545 | } 546 | } 547 | 548 | void value_take_win32_window (GValue* value, gpointer v_object) 549 | { 550 | Win32Window * old; 551 | g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, WIN32_TYPE_WINDOW)); 552 | old = value->data[0].v_pointer; 553 | if (v_object) { 554 | g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, WIN32_TYPE_WINDOW)); 555 | g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value))); 556 | value->data[0].v_pointer = v_object; 557 | } else { 558 | value->data[0].v_pointer = NULL; 559 | } 560 | if (old) { 561 | win32_window_unref (old); 562 | } 563 | } 564 | 565 | static void win32_window_class_init (Win32WindowClass * klass, gpointer klass_data) 566 | { 567 | win32_window_parent_class = g_type_class_peek_parent (klass); 568 | ((Win32WindowClass *) klass)->finalize = win32_window_finalize; 569 | ((Win32WindowClass *) klass)->auto_resize = win32_window_auto_resize_default; 570 | ((Win32WindowClass *) klass)->add_listener = win32_window_insert_into_callback_queue; 571 | } 572 | 573 | static void win32_window_instance_init (Win32Window * self, gpointer klass) 574 | { 575 | self->ref_count = 1; 576 | } 577 | 578 | static GType win32_window_get_type_once (void) 579 | { 580 | static const GTypeValueTable g_define_type_value_table = { 581 | value_win32_window_init, 582 | value_win32_window_free_value, 583 | value_win32_window_copy_value, 584 | NULL, NULL, NULL, NULL, NULL 585 | }; 586 | static const GTypeInfo g_define_type_info = { 587 | sizeof (Win32WindowClass), 588 | (GBaseInitFunc) NULL, 589 | (GBaseFinalizeFunc) NULL, 590 | (GClassInitFunc) win32_window_class_init, 591 | (GClassFinalizeFunc) NULL, 592 | NULL, 593 | sizeof (Win32Window), 594 | 0, 595 | (GInstanceInitFunc) win32_window_instance_init, 596 | &g_define_type_value_table 597 | }; 598 | static const GTypeFundamentalInfo g_define_type_fundamental_info = { 599 | (G_TYPE_FLAG_CLASSED | G_TYPE_FLAG_INSTANTIATABLE | G_TYPE_FLAG_DERIVABLE | G_TYPE_FLAG_DEEP_DERIVABLE) 600 | }; 601 | 602 | GType win32_window_type_id; 603 | win32_window_type_id = g_type_register_fundamental ( 604 | g_type_fundamental_next (), 605 | "Win32Window", 606 | &g_define_type_info, 607 | &g_define_type_fundamental_info, 608 | G_TYPE_FLAG_ABSTRACT 609 | ); 610 | 611 | return win32_window_type_id; 612 | } 613 | 614 | GType win32_window_get_type (void) 615 | { 616 | static volatile gsize win32_window_type_id__volatile = 0; 617 | if (g_once_init_enter (&win32_window_type_id__volatile)) { 618 | GType win32_window_type_id; 619 | win32_window_type_id = win32_window_get_type_once (); 620 | g_once_init_leave (&win32_window_type_id__volatile, win32_window_type_id); 621 | } 622 | return win32_window_type_id__volatile; 623 | } 624 | 625 | /* INTERNAL CONSTRUCT 626 | ------------------------------------------- */ 627 | Win32Window* win32_window_construct (GType object_type) 628 | { 629 | Win32Window* self = NULL; 630 | self = (Win32Window*) g_type_create_instance (object_type); 631 | 632 | self->hInstance = GetModuleHandle(NULL); 633 | self->enabled = TRUE; 634 | 635 | // Initialize callback list for the window 636 | Win32EventList * eventList = &self->attachedEvents; 637 | eventList->items = malloc( sizeof(Win32EventListItem) * INITIAL_LIST_SIZE ); 638 | memset( eventList->items, 0, sizeof(Win32EventListItem) * INITIAL_LIST_SIZE ); 639 | 640 | // Layout data 641 | //*TODO*/ allow different structures to be used for positioning 642 | self->positioning = malloc( sizeof(Win32LayoutData) ); 643 | memset( self->positioning, 0, sizeof(Win32LayoutData) ); 644 | win32_layout_data_ref (self->positioning); 645 | 646 | return self; 647 | } 648 | 649 | 650 | /* INTERNAL CLEANUP 651 | ------------------------------------------- */ 652 | static void win32_window_finalize (Win32Window * obj) 653 | { 654 | Win32Window * self; 655 | self = G_TYPE_CHECK_INSTANCE_CAST (obj, WIN32_TYPE_WINDOW, Win32Window); 656 | 657 | // Underlying window may not be created yet 658 | if (self->hwnd != NULL) DestroyWindow (self->hwnd); 659 | 660 | if ( self->positioning != NULL ){ 661 | if ( self->positioning->left != NULL ) win32_anchor_unref (self->positioning->left); 662 | if ( self->positioning->top != NULL ) win32_anchor_unref (self->positioning->top); 663 | if ( self->positioning->right != NULL ) win32_anchor_unref (self->positioning->right); 664 | if ( self->positioning->bottom != NULL ) win32_anchor_unref (self->positioning->bottom); 665 | win32_layout_data_unref (self->positioning); 666 | } 667 | // free event queue 668 | // Note: event lists are freed after WM_DESTROY message 669 | free (self->attachedEvents.items); 670 | 671 | free (self->text); 672 | } 673 | 674 | 675 | /* INTERNAL REF 676 | ------------------------------------------- */ 677 | void* win32_window_ref (void* instance) 678 | { 679 | Win32Window * self = instance; 680 | g_atomic_int_inc (&self->ref_count); 681 | return instance; 682 | } 683 | 684 | 685 | /* INTERNAL UNREF 686 | ------------------------------------------- */ 687 | void win32_window_unref (gpointer instance) 688 | { 689 | Win32Window * self = instance; 690 | if (g_atomic_int_dec_and_test (&self->ref_count)) { 691 | WIN32_WINDOW_GET_CLASS (self)->finalize (self); 692 | g_type_free_instance ((GTypeInstance *) self); 693 | } 694 | } 695 | 696 | /*┌────────────────────────────────────────────────────────┐ 697 | │ EVENT OBJECT │ 698 | └────────────────────────────────────────────────────────┘*/ 699 | 700 | /* PROPERTY SET 701 | ------------------------------------------- */ 702 | BOOL win32_event_get_handled (Win32Event *event) 703 | { 704 | return event->handled; 705 | } 706 | 707 | 708 | /* PROPERTY SET 709 | ------------------------------------------- */ 710 | void win32_event_set_handled (Win32Event *event, BOOL value) 711 | { 712 | event->handled = value; 713 | } 714 | -------------------------------------------------------------------------------- /src/window.h: -------------------------------------------------------------------------------- 1 | /*--------------------------------------------------------------------------------------------- 2 | * Copyright (c) 2022 Emre ÖZÇAKIR 3 | * Licensed under the MIT License. See License file in the project root for more information. 4 | *-------------------------------------------------------------------------------------------*/ 5 | 6 | #ifndef _WIN32_WINDOW_H_ 7 | #define _WIN32_WINDOW_H_ 8 | 9 | #include 10 | #include 11 | 12 | typedef struct _Win32Event Win32Event; 13 | typedef struct _Win32EventList Win32EventList; 14 | 15 | typedef struct _Win32WindowClass Win32WindowClass; 16 | 17 | // Delegates 18 | typedef void (*Win32Callback) ( Win32Event *event, void *boundData); 19 | typedef void (*Win32ReleaseFunction) (void* userData); 20 | 21 | /* EVENT Declarations 22 | ------------------------------------------- */ 23 | // Event Object 24 | struct _Win32Event { 25 | UINT id; 26 | Win32Window *source; 27 | WPARAM wParam; 28 | LPARAM lParam; 29 | BOOL handled; 30 | }; 31 | 32 | typedef struct _Win32EventListItem { 33 | UINT eventID; 34 | Win32Callback *callbacks; 35 | Win32ReleaseFunction *releaseData; 36 | void ** boundData; 37 | size_t numCallbacks; 38 | } Win32EventListItem; 39 | 40 | struct _Win32EventList { 41 | Win32EventListItem *items; 42 | size_t length; 43 | }; 44 | 45 | #define STOP_PROPAGATION 8000 46 | 47 | BOOL win32_event_get_handled (Win32Event *event); 48 | void win32_event_set_handled (Win32Event *event, BOOL value); 49 | 50 | /* CLASS Window 51 | ------------------------------------------- */ 52 | #define WIN32_TYPE_WINDOW (win32_window_get_type ()) 53 | #define WIN32_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), WIN32_TYPE_WINDOW, Win32Window)) 54 | #define WIN32_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), WIN32_TYPE_WINDOW, Win32WindowClass)) 55 | #define WIN32_IS_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), WIN32_TYPE_WINDOW)) 56 | #define WIN32_IS_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), WIN32_TYPE_WINDOW)) 57 | #define WIN32_WINDOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), WIN32_TYPE_WINDOW, Win32WindowClass)) 58 | 59 | #define _win32_window_unref0(var) ((var == NULL) ? NULL : (var = (win32_window_unref (var), NULL))) 60 | 61 | struct _Win32Window { 62 | GTypeInstance parent_instance; 63 | volatile int ref_count; 64 | HWND hwnd; 65 | Win32Window* parent; 66 | HINSTANCE hInstance; 67 | char* text; 68 | BOOL enabled; 69 | INT top; 70 | INT left; 71 | INT width; 72 | INT height; 73 | Win32LayoutData* positioning; 74 | INT pref_width; 75 | INT pref_height; 76 | BOOL auto_resize; 77 | Win32EventList attachedEvents; 78 | }; 79 | 80 | struct _Win32WindowClass { 81 | GTypeClass parent_class; 82 | void (*finalize) (Win32Window *self); 83 | void (*auto_resize) (Win32Window *window, const void *data); 84 | int (*add_listener)(Win32Window *window, UINT eventID, Win32Callback callback, void * boundData, Win32ReleaseFunction releaseData); 85 | }; 86 | 87 | Win32Window* win32_window_new (void); 88 | Win32Window* win32_window_construct (GType object_type); 89 | 90 | // Window* window_new (void); 91 | int win32_window_add_listener (Win32Window *window, 92 | UINT eventID, 93 | Win32Callback callback, 94 | void *boundData, 95 | Win32ReleaseFunction releaseData); 96 | 97 | /* PROPERTIES */ 98 | void win32_window_set_positioning (Win32Window *window, Win32LayoutData* layoutData); 99 | Win32LayoutData* win32_window_get_positioning (Win32Window *window); 100 | 101 | void win32_window_set_text (Win32Window *window, const char* text); 102 | char* win32_window_get_text (Win32Window *window); 103 | 104 | void win32_window_set_enabled (Win32Window *window, BOOL isEnabled); 105 | BOOL win32_window_get_enabled (Win32Window *window); 106 | 107 | void win32_window_set_top (Win32Window *window, int top); 108 | int win32_window_get_top (Win32Window *window); 109 | 110 | void win32_window_set_left (Win32Window *window, int left); 111 | int win32_window_get_left (Win32Window *window); 112 | 113 | void win32_window_set_width (Win32Window *window, int width); 114 | int win32_window_get_width (Win32Window *window); 115 | 116 | void win32_window_set_height (Win32Window *window, int height); 117 | int win32_window_get_height (Win32Window *window); 118 | 119 | /* METHODS */ 120 | Win32Rect* win32_window_get_window_rect(Win32Window *window); 121 | Win32Rect* win32_window_get_client_rect(Win32Window *window); 122 | 123 | void win32_window_move (Win32Window *window, int left, int top); 124 | void win32_window_resize (Win32Window *window, int width, int height); 125 | void win32_window_move_and_resize (Win32Window *window, int left, int top, int width, int height); 126 | 127 | HDC win32_window_begin_paint(Win32Window *window, PAINTSTRUCT *ps); 128 | void win32_window_end_paint(Win32Window *window, PAINTSTRUCT *ps); 129 | 130 | /* INTERNAL */ 131 | LRESULT win32_window_default_procedure(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); 132 | BOOL win32_window_insert_into_callback_queue (Win32Window *window, 133 | UINT eventID, 134 | Win32Callback callback, 135 | void *boundData, 136 | Win32ReleaseFunction releaseData); 137 | 138 | gpointer win32_window_ref (gpointer instance); 139 | void win32_window_unref (gpointer instance); 140 | 141 | void value_set_win32_window (GValue* value, gpointer v_object); 142 | void value_take_win32_window (GValue* value, gpointer v_object); 143 | gpointer value_get_win32_window (const GValue* value); 144 | 145 | GType win32_window_get_type (void) G_GNUC_CONST; 146 | G_DEFINE_AUTOPTR_CLEANUP_FUNC (Win32Window, win32_window_unref) 147 | 148 | #endif 149 | -------------------------------------------------------------------------------- /src/wrappers.c: -------------------------------------------------------------------------------- 1 | /*--------------------------------------------------------------------------------------------- 2 | * Copyright (c) 2022 Emre ÖZÇAKIR 3 | * Licensed under the MIT License. See License file in the project root for more information. 4 | *-------------------------------------------------------------------------------------------*/ 5 | 6 | #include "vala-win32.h" 7 | 8 | 9 | LRESULT win32_send_message(Win32Window* window, UINT msg, WPARAM wParam, LPARAM lParam) 10 | { 11 | return SendMessage(window->hwnd, msg, wParam, lParam); 12 | } 13 | 14 | 15 | BOOL win32_post_message(Win32Window* window, UINT msg, WPARAM wParam, LPARAM lParam) 16 | { 17 | return PostMessage(window->hwnd, msg, wParam, lParam); 18 | } 19 | 20 | 21 | /* INTERNAL REF RECT 22 | ------------------------------------------- */ 23 | void* win32_rect_ref (void* instance) 24 | { 25 | Win32Rect * self = instance; 26 | g_atomic_int_inc (&self->ref_count); 27 | return self; 28 | } 29 | 30 | 31 | /* INTERNAL UNREF RECT 32 | ------------------------------------------- */ 33 | void win32_rect_unref (void* instance) 34 | { 35 | Win32Rect * self = instance; 36 | if (g_atomic_int_dec_and_test (&self->ref_count)) { 37 | free (self); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/wrappers.h: -------------------------------------------------------------------------------- 1 | /*--------------------------------------------------------------------------------------------- 2 | * Copyright (c) 2022 Emre ÖZÇAKIR 3 | * Licensed under the MIT License. See License file in the project root for more information. 4 | *-------------------------------------------------------------------------------------------*/ 5 | 6 | #ifndef WIN32_WRAPPERS_H 7 | #define WIN32_WRAPPERS_H 8 | 9 | #include 10 | #include 11 | #include 12 | 13 | /* STRUCT WRAPPER RECT (REF COUNTED) 14 | ------------------------------------------- */ 15 | typedef struct _Win32Rect { 16 | LONG left; 17 | LONG top; 18 | LONG right; 19 | LONG bottom; 20 | volatile int ref_count; 21 | } Win32Rect; 22 | 23 | void* win32_rect_ref (void*); 24 | void win32_rect_unref (void*); 25 | 26 | #endif 27 | 28 | 29 | LRESULT win32_send_message(Win32Window* window, UINT msg, WPARAM wParam, LPARAM lParam); 30 | 31 | BOOL win32_post_message(Win32Window* window, UINT msg, WPARAM wParam, LPARAM lParam); -------------------------------------------------------------------------------- /vapi/libwin32.vapi: -------------------------------------------------------------------------------- 1 | /*--------------------------------------------------------------------------------------------- 2 | * Copyright (c) 2022 Emre ÖZÇAKIR 3 | * Licensed under the MIT License. See License file in the project root for more information. 4 | *-------------------------------------------------------------------------------------------*/ 5 | 6 | [CCode (cheader_filename = "vala-win32.h")] 7 | namespace Win32 8 | { 9 | delegate void Callback( Event event ); 10 | 11 | /* POINTER */ 12 | [Compact] 13 | [CCode (cname="void")] 14 | public class Handle {} 15 | 16 | #if WIN64 17 | [SimpleType] 18 | [CCode (cname = "LONG_PTR", has_type_id = false)] 19 | public struct LONG_PTR : int64 {} 20 | 21 | [SimpleType] 22 | [CCode (cname = "UINT_PTR", has_type_id = false)] 23 | public struct UINT_PTR : int64 {} 24 | #else 25 | [SimpleType] 26 | [CCode (cname = "LONG_PTR", has_type_id = false)] 27 | public struct LONG_PTR : long {} 28 | 29 | [SimpleType] 30 | [CCode (cname = "UINT_PTR", has_type_id = false)] 31 | public struct UINT_PTR : uint {} 32 | #endif 33 | 34 | [SimpleType] 35 | [CCode (cname = "LRESULT", has_type_id = false)] 36 | public struct LRESULT : LONG_PTR {} 37 | 38 | [SimpleType] 39 | [CCode (cname = "WPARAM", has_type_id = false)] 40 | public struct WPARAM : UINT_PTR {} 41 | 42 | [SimpleType] 43 | [CCode (cname = "LPARAM", has_type_id = false)] 44 | public struct LPARAM : LONG_PTR {} 45 | 46 | [CCode (cname="MSG", has_type_id = false)] 47 | public struct Message { 48 | WPARAM wParam; 49 | LPARAM lParam; 50 | } 51 | 52 | [CCode (cname = "GetMessageW")] 53 | int get_message (out Message msg, Handle? hwnd = null, uint wMsgFilterMin = 0, uint wMsgFilterMax = 0); 54 | 55 | [CCode (cname = "TranslateMessage")] 56 | bool translate_message (ref Message msg); 57 | 58 | [CCode (cname = "DispatchMessageW")] 59 | LRESULT dispatch_message (ref Message msg); 60 | 61 | LRESULT send_message(Window window, uint msg, WPARAM wParam = 0, LPARAM lParam = 0); 62 | 63 | bool post_message(Window? window, uint msg, WPARAM wParam = 0, LPARAM lParam = 0); 64 | 65 | 66 | [CCode (cname="PAINTSTRUCT", has_type_id = false)] 67 | struct PaintStruct {} 68 | 69 | [CCode (has_type_id = false)] 70 | class Rect { 71 | public long left; 72 | public long top; 73 | public long right; 74 | public long bottom; 75 | } 76 | 77 | [Compact] 78 | [CCode (cname="void", has_type_id = false, free_function="")] 79 | class DeviceContext 80 | { 81 | public void text_out(int x, int y, string text); 82 | } 83 | 84 | [CCode (type_id = "WIN32_TYPE_WINDOW")] 85 | abstract class Window 86 | { 87 | public string? text { get; set; } 88 | public bool enabled { get; set; } 89 | public int left { get; set; } 90 | public int top { get; set; } 91 | public int width { get; set; } 92 | public int height { get; set; } 93 | 94 | public LayoutData positioning { get; set; } 95 | 96 | public void add_listener( uint event_id, owned Callback callback ); 97 | 98 | public Rect get_client_rect(); 99 | public Rect get_window_rect(); 100 | 101 | public DeviceContext begin_paint(out PaintStruct ps); 102 | public void end_paint(out PaintStruct ps); 103 | 104 | public void move (int left, int top); 105 | public void resize (int width, int height); 106 | public void move_and_resize (int left, int top, int width, int height); 107 | } 108 | 109 | [CCode (type_id = "WIN32_TYPE_CONTAINER")] 110 | abstract class Container : Window 111 | { 112 | public Layout layout { get; set; } 113 | 114 | [CCode (array_length_type="size_t")] 115 | public Window[] get_children(); 116 | } 117 | 118 | [CCode (type_id = "WIN32_TYPE_APPLICATION_WINDOW")] 119 | class ApplicationWindow : Container 120 | { 121 | public int min_width { get; set; } 122 | public int min_height { get; set; } 123 | public int max_width { get; set; } 124 | public int max_height { get; set; } 125 | 126 | public ApplicationWindow( string title ); 127 | 128 | public void show(); 129 | 130 | [CCode (cname = "win32_application_window_get_type1")] 131 | public GLib.Type get_type(); 132 | } 133 | 134 | [CCode (has_type_id = true)] 135 | abstract class Control : Window 136 | { 137 | public uint id { get; private set; } 138 | } 139 | 140 | [CCode (has_type_id = true)] 141 | class Button : Control 142 | { 143 | public Button( Window parent, string text="" ); 144 | } 145 | 146 | [CCode (has_type_id = true)] 147 | class Label : Control 148 | { 149 | public Alignment text_align { get; set; } 150 | 151 | public Label( Window parent, string text="" ); 152 | } 153 | 154 | [CCode (has_type_id = true)] 155 | class Edit : Control 156 | { 157 | //public Alignment text_align { get; set; } 158 | public bool readonly { get; set; } 159 | 160 | public Edit( Window parent, string text="" ); 161 | public Edit.multiline( Window parent, string text="" ); 162 | // public Edit.multiline( Window parent, Alignment text_align=Alignment.LEFT ); 163 | public Edit.password ( Window parent ); 164 | } 165 | 166 | [Compact] 167 | [CCode (has_type_id = false)] 168 | class Event { 169 | 170 | WPARAM wParam; 171 | LPARAM lParam; 172 | 173 | public Window source; 174 | 175 | public bool handled { get; set;} 176 | 177 | [CCode (cname="FM_CLICKED")] 178 | public const uint CLICK; 179 | [CCode (cname="WM_CREATE")] 180 | public const uint CREATE; 181 | [CCode (cname="WM_PAINT")] 182 | public const uint PAINT; 183 | [CCode (cname="WM_SIZE")] 184 | public const uint SIZE; 185 | [CCode (cname="WM_LBUTTONDOWN")] 186 | public const uint LBUTTON_DOWN; 187 | [CCode (cname="WM_COMMAND")] 188 | public const uint Command; 189 | [CCode (cname="WM_CLIPBOARDUPDATE")] 190 | public const uint CLIPBOARD_UPDATE; 191 | } 192 | 193 | /* LAYOUT */ 194 | [CCode (has_type_id = false)] 195 | abstract class Layout 196 | { 197 | public void layout(); 198 | } 199 | 200 | [CCode (has_type_id = false)] 201 | class RelativeLayout : Layout 202 | { 203 | public RelativeLayout(uint padding=0, uint spacing=0 ); 204 | //public unowned RelativeLayout set_grid(uint scale); 205 | public unowned RelativeLayout with_spacing(uint vSpacing, uint hSpacing=-1); 206 | public unowned RelativeLayout with_padding(uint vPadding, uint hPadding=-1); 207 | } 208 | 209 | [CCode (has_type_id = false)] 210 | class LayoutData 211 | { 212 | public Anchor left { get; set; } 213 | public Anchor top { get; set; } 214 | public Anchor right { get; set; } 215 | public Anchor bottom { get; set; } 216 | 217 | public LayoutData (); 218 | } 219 | 220 | [CCode (has_type_id = false)] 221 | class Anchor 222 | { 223 | // private Window reference; 224 | // private int offset; 225 | 226 | public static Anchor to_parent( uint ratio, int offset = 0 ); 227 | public static Anchor to_sibling( Window sibling, int offset = 0); 228 | 229 | public unowned Anchor to_edge(Edge edge); 230 | public unowned Anchor with_offset(int offset); 231 | } 232 | 233 | [CCode (cname = "int", cprefix = "EDGE_", has_type_id = false)] 234 | public enum Edge { 235 | TOP, 236 | LEFT, 237 | BOTTOM, 238 | RIGHT 239 | } 240 | 241 | [CCode (cname = "int", cprefix = "ALIGN_", has_type_id = false)] 242 | public enum Alignment { 243 | LEFT, 244 | CENTER, 245 | RIGHT 246 | } 247 | 248 | [CCode (has_type_id = false)] 249 | class Clipboard { 250 | public static string? text { owned get; set; } 251 | public static bool add_format_listener (Window window); 252 | 253 | //public static owned string? get_text(); 254 | 255 | private Clipboard (); 256 | } 257 | 258 | }// END Win32 259 | 260 | // Standard Windows messages 261 | public const uint WM_NULL; 262 | public const uint WM_CREATE; 263 | public const uint WM_DESTROY; 264 | public const uint WM_MOVE; 265 | public const uint WM_SIZE; 266 | public const uint WM_ACTIVATE; 267 | public const uint WM_SETFOCUS; 268 | public const uint WM_KILLFOCUS; 269 | public const uint WM_ENABLE; 270 | public const uint WM_SETREDRAW; 271 | public const uint WM_SETTEXT; 272 | public const uint WM_GETTEXT; 273 | public const uint WM_GETTEXTLENGTH; 274 | public const uint WM_PAINT; 275 | public const uint WM_CLOSE; 276 | public const uint WM_QUERYENDSESSION; 277 | public const uint WM_QUIT; 278 | public const uint WM_QUERYOPEN; 279 | public const uint WM_ERASEBKGND; 280 | public const uint WM_SYSCOLORCHANGE; 281 | public const uint WM_ENDSESSION; 282 | public const uint WM_SHOWWINDOW; 283 | public const uint WM_CTLCOLOR; 284 | public const uint WM_WININICHANGE; 285 | public const uint WM_DEVMODECHANGE; 286 | public const uint WM_ACTIVATEAPP; 287 | public const uint WM_FONTCHANGE; 288 | public const uint WM_TIMECHANGE; 289 | public const uint WM_CANCELMODE; 290 | public const uint WM_SETCURSOR; 291 | public const uint WM_MOUSEACTIVATE; 292 | public const uint WM_CHILDACTIVATE; 293 | public const uint WM_QUEUESYNC; 294 | public const uint WM_GETMINMAXINFO; 295 | public const uint WM_PAINTICON; 296 | public const uint WM_ICONERASEBKGND; 297 | public const uint WM_NEXTDLGCTL; 298 | public const uint WM_SPOOLERSTATUS; 299 | public const uint WM_DRAWITEM; 300 | public const uint WM_MEASUREITEM; 301 | public const uint WM_DELETEITEM; 302 | public const uint WM_VKEYTOITEM; 303 | public const uint WM_CHARTOITEM; 304 | public const uint WM_SETFONT; 305 | public const uint WM_GETFONT; 306 | public const uint WM_SETHOTKEY; 307 | public const uint WM_GETHOTKEY; 308 | public const uint WM_QUERYDRAGICON; 309 | public const uint WM_COMPAREITEM; 310 | public const uint WM_GETOBJECT; 311 | public const uint WM_COMPACTING; 312 | public const uint WM_COMMNOTIFY; 313 | public const uint WM_WINDOWPOSCHANGING; 314 | public const uint WM_WINDOWPOSCHANGED; 315 | public const uint WM_POWER; 316 | public const uint WM_COPYGLOBALDATA; 317 | public const uint WM_COPYDATA; 318 | public const uint WM_CANCELJOURNAL; 319 | public const uint WM_NOTIFY; 320 | public const uint WM_INPUTLANGCHANGEREQUEST; 321 | public const uint WM_INPUTLANGCHANGE; 322 | public const uint WM_TCARD; 323 | public const uint WM_HELP; 324 | public const uint WM_USERCHANGED; 325 | public const uint WM_NOTIFYFORMAT; 326 | public const uint WM_CONTEXTMENU; 327 | public const uint WM_STYLECHANGING; 328 | public const uint WM_STYLECHANGED; 329 | public const uint WM_DISPLAYCHANGE; 330 | public const uint WM_GETICON; 331 | public const uint WM_SETICON; 332 | public const uint WM_NCCREATE; 333 | public const uint WM_NCDESTROY; 334 | public const uint WM_NCCALCSIZE; 335 | public const uint WM_NCHITTEST; 336 | public const uint WM_NCPAINT; 337 | public const uint WM_NCACTIVATE; 338 | public const uint WM_GETDLGCODE; 339 | public const uint WM_SYNCPAINT; 340 | public const uint WM_NCMOUSEMOVE; 341 | public const uint WM_NCLBUTTONDOWN; 342 | public const uint WM_NCLBUTTONUP; 343 | public const uint WM_NCLBUTTONDBLCLK; 344 | public const uint WM_NCRBUTTONDOWN; 345 | public const uint WM_NCRBUTTONUP; 346 | public const uint WM_NCRBUTTONDBLCLK; 347 | public const uint WM_NCMBUTTONDOWN; 348 | public const uint WM_NCMBUTTONUP; 349 | public const uint WM_NCMBUTTONDBLCLK; 350 | public const uint WM_NCXBUTTONDOWN; 351 | public const uint WM_NCXBUTTONUP; 352 | public const uint WM_NCXBUTTONDBLCLK; 353 | public const uint EM_GETSEL; 354 | public const uint EM_SETSEL; 355 | public const uint EM_GETRECT; 356 | public const uint EM_SETRECT; 357 | public const uint EM_SETRECTNP; 358 | public const uint EM_SCROLL; 359 | public const uint EM_LINESCROLL; 360 | public const uint EM_SCROLLCARET; 361 | public const uint EM_GETMODIFY; 362 | public const uint EM_SETMODIFY; 363 | public const uint EM_GETLINECOUNT; 364 | public const uint EM_LINEINDEX; 365 | public const uint EM_SETHANDLE; 366 | public const uint EM_GETHANDLE; 367 | public const uint EM_GETTHUMB; 368 | public const uint EM_LINELENGTH; 369 | public const uint EM_REPLACESEL; 370 | public const uint EM_SETFONT; 371 | public const uint EM_GETLINE; 372 | public const uint EM_LIMITTEXT; 373 | public const uint EM_SETLIMITTEXT; 374 | public const uint EM_CANUNDO; 375 | public const uint EM_UNDO; 376 | public const uint EM_FMTLINES; 377 | public const uint EM_LINEFROMCHAR; 378 | public const uint EM_SETWORDBREAK; 379 | public const uint EM_SETTABSTOPS; 380 | public const uint EM_SETPASSWORDCHAR; 381 | public const uint EM_EMPTYUNDOBUFFER; 382 | public const uint EM_GETFIRSTVISIBLELINE; 383 | public const uint EM_SETREADONLY; 384 | public const uint EM_SETWORDBREAKPROC; 385 | public const uint EM_GETWORDBREAKPROC; 386 | public const uint EM_GETPASSWORDCHAR; 387 | public const uint EM_SETMARGINS; 388 | public const uint EM_GETMARGINS; 389 | public const uint EM_GETLIMITTEXT; 390 | public const uint EM_POSFROMCHAR; 391 | public const uint EM_CHARFROMPOS; 392 | public const uint EM_SETIMESTATUS; 393 | public const uint EM_GETIMESTATUS; 394 | public const uint SBM_SETPOS; 395 | public const uint SBM_GETPOS; 396 | public const uint SBM_SETRANGE; 397 | public const uint SBM_GETRANGE; 398 | public const uint SBM_ENABLE_ARROWS; 399 | public const uint SBM_SETRANGEREDRAW; 400 | public const uint SBM_SETSCROLLINFO; 401 | public const uint SBM_GETSCROLLINFO; 402 | public const uint SBM_GETSCROLLBARINFO; 403 | public const uint BM_GETCHECK; 404 | public const uint BM_SETCHECK; 405 | public const uint BM_GETSTATE; 406 | public const uint BM_SETSTATE; 407 | public const uint BM_SETSTYLE; 408 | public const uint BM_CLICK; 409 | public const uint BM_GETIMAGE; 410 | public const uint BM_SETIMAGE; 411 | public const uint BM_SETDONTCLICK; 412 | public const uint WM_INPUT; 413 | public const uint WM_KEYDOWN; 414 | public const uint WM_KEYFIRST; 415 | public const uint WM_KEYUP; 416 | public const uint WM_CHAR; 417 | public const uint WM_DEADCHAR; 418 | public const uint WM_SYSKEYDOWN; 419 | public const uint WM_SYSKEYUP; 420 | public const uint WM_SYSCHAR; 421 | public const uint WM_SYSDEADCHAR; 422 | public const uint WM_UNICHAR; 423 | public const uint WM_KEYLAST; 424 | public const uint WM_WNT_CONVERTREQUESTEX; 425 | public const uint WM_CONVERTREQUEST; 426 | public const uint WM_CONVERTRESULT; 427 | public const uint WM_INTERIM; 428 | public const uint WM_IME_STARTCOMPOSITION; 429 | public const uint WM_IME_ENDCOMPOSITION; 430 | public const uint WM_IME_COMPOSITION; 431 | public const uint WM_IME_KEYLAST; 432 | public const uint WM_INITDIALOG; 433 | public const uint WM_COMMAND; 434 | public const uint WM_SYSCOMMAND; 435 | public const uint WM_TIMER; 436 | public const uint WM_HSCROLL; 437 | public const uint WM_VSCROLL; 438 | public const uint WM_INITMENU; 439 | public const uint WM_INITMENUPOPUP; 440 | public const uint WM_SYSTIMER; 441 | public const uint WM_MENUSELECT; 442 | public const uint WM_MENUCHAR; 443 | public const uint WM_ENTERIDLE; 444 | public const uint WM_MENURBUTTONUP; 445 | public const uint WM_MENUDRAG; 446 | public const uint WM_MENUGETOBJECT; 447 | public const uint WM_UNINITMENUPOPUP; 448 | public const uint WM_MENUCOMMAND; 449 | public const uint WM_CHANGEUISTATE; 450 | public const uint WM_UPDATEUISTATE; 451 | public const uint WM_QUERYUISTATE; 452 | public const uint WM_LBTRACKPOINT; 453 | public const uint WM_CTLCOLORMSGBOX; 454 | public const uint WM_CTLCOLOREDIT; 455 | public const uint WM_CTLCOLORLISTBOX; 456 | public const uint WM_CTLCOLORBTN; 457 | public const uint WM_CTLCOLORDLG; 458 | public const uint WM_CTLCOLORSCROLLBAR; 459 | public const uint WM_CTLCOLORSTATIC; 460 | public const uint CB_GETEDITSEL; 461 | public const uint CB_LIMITTEXT; 462 | public const uint CB_SETEDITSEL; 463 | public const uint CB_ADDSTRING; 464 | public const uint CB_DELETESTRING; 465 | public const uint CB_DIR; 466 | public const uint CB_GETCOUNT; 467 | public const uint CB_GETCURSEL; 468 | public const uint CB_GETLBTEXT; 469 | public const uint CB_GETLBTEXTLEN; 470 | public const uint CB_INSERTSTRING; 471 | public const uint CB_RESETCONTENT; 472 | public const uint CB_FINDSTRING; 473 | public const uint CB_SELECTSTRING; 474 | public const uint CB_SETCURSEL; 475 | public const uint CB_SHOWDROPDOWN; 476 | public const uint CB_GETITEMDATA; 477 | public const uint CB_SETITEMDATA; 478 | public const uint CB_GETDROPPEDCONTROLRECT; 479 | public const uint CB_SETITEMHEIGHT; 480 | public const uint CB_GETITEMHEIGHT; 481 | public const uint CB_SETEXTENDEDUI; 482 | public const uint CB_GETEXTENDEDUI; 483 | public const uint CB_GETDROPPEDSTATE; 484 | public const uint CB_FINDSTRINGEXACT; 485 | public const uint CB_SETLOCALE; 486 | public const uint CB_GETLOCALE; 487 | public const uint CB_GETTOPINDEX; 488 | public const uint CB_SETTOPINDEX; 489 | public const uint CB_GETHORIZONTALEXTENT; 490 | public const uint CB_SETHORIZONTALEXTENT; 491 | public const uint CB_GETDROPPEDWIDTH; 492 | public const uint CB_SETDROPPEDWIDTH; 493 | public const uint CB_INITSTORAGE; 494 | public const uint CB_MULTIPLEADDSTRING; 495 | public const uint CB_GETCOMBOBOXINFO; 496 | public const uint CB_MSGMAX; 497 | public const uint WM_MOUSEFIRST; 498 | public const uint WM_MOUSEMOVE; 499 | public const uint WM_LBUTTONDOWN; 500 | public const uint WM_LBUTTONUP; 501 | public const uint WM_LBUTTONDBLCLK; 502 | public const uint WM_RBUTTONDOWN; 503 | public const uint WM_RBUTTONUP; 504 | public const uint WM_RBUTTONDBLCLK; 505 | public const uint WM_MBUTTONDOWN; 506 | public const uint WM_MBUTTONUP; 507 | public const uint WM_MBUTTONDBLCLK; 508 | public const uint WM_MOUSELAST; 509 | public const uint WM_MOUSEWHEEL; 510 | public const uint WM_XBUTTONDOWN; 511 | public const uint WM_XBUTTONUP; 512 | public const uint WM_XBUTTONDBLCLK; 513 | public const uint WM_MOUSEHWHEEL; 514 | public const uint WM_PARENTNOTIFY; 515 | public const uint WM_ENTERMENULOOP; 516 | public const uint WM_EXITMENULOOP; 517 | public const uint WM_NEXTMENU; 518 | public const uint WM_SIZING; 519 | public const uint WM_CAPTURECHANGED; 520 | public const uint WM_MOVING; 521 | public const uint WM_POWERBROADCAST; 522 | public const uint WM_DEVICECHANGE; 523 | public const uint WM_MDICREATE; 524 | public const uint WM_MDIDESTROY; 525 | public const uint WM_MDIACTIVATE; 526 | public const uint WM_MDIRESTORE; 527 | public const uint WM_MDINEXT; 528 | public const uint WM_MDIMAXIMIZE; 529 | public const uint WM_MDITILE; 530 | public const uint WM_MDICASCADE; 531 | public const uint WM_MDIICONARRANGE; 532 | public const uint WM_MDIGETACTIVE; 533 | public const uint WM_MDISETMENU; 534 | public const uint WM_ENTERSIZEMOVE; 535 | public const uint WM_EXITSIZEMOVE; 536 | public const uint WM_DROPFILES; 537 | public const uint WM_MDIREFRESHMENU; 538 | public const uint WM_IME_REPORT; 539 | public const uint WM_IME_SETCONTEXT; 540 | public const uint WM_IME_NOTIFY; 541 | public const uint WM_IME_CONTROL; 542 | public const uint WM_IME_COMPOSITIONFULL; 543 | public const uint WM_IME_SELECT; 544 | public const uint WM_IME_CHAR; 545 | public const uint WM_IME_REQUEST; 546 | public const uint WM_IMEKEYDOWN; 547 | public const uint WM_IME_KEYDOWN; 548 | public const uint WM_IMEKEYUP; 549 | public const uint WM_IME_KEYUP; 550 | public const uint WM_NCMOUSEHOVER; 551 | public const uint WM_MOUSEHOVER; 552 | public const uint WM_NCMOUSELEAVE; 553 | public const uint WM_MOUSELEAVE; 554 | public const uint WM_CUT; 555 | public const uint WM_COPY; 556 | public const uint WM_PASTE; 557 | public const uint WM_CLEAR; 558 | public const uint WM_UNDO; 559 | public const uint WM_RENDERFORMAT; 560 | public const uint WM_RENDERALLFORMATS; 561 | public const uint WM_DESTROYCLIPBOARD; 562 | public const uint WM_DRAWCLIPBOARD; 563 | public const uint WM_PAINTCLIPBOARD; 564 | public const uint WM_VSCROLLCLIPBOARD; 565 | public const uint WM_SIZECLIPBOARD; 566 | public const uint WM_ASKCBFORMATNAME; 567 | public const uint WM_CHANGECBCHAIN; 568 | public const uint WM_HSCROLLCLIPBOARD; 569 | public const uint WM_QUERYNEWPALETTE; 570 | public const uint WM_PALETTEISCHANGING; 571 | public const uint WM_PALETTECHANGED; 572 | public const uint WM_HOTKEY; 573 | public const uint WM_PRINT; 574 | public const uint WM_PRINTCLIENT; 575 | public const uint WM_APPCOMMAND; 576 | public const uint WM_HANDHELDFIRST; 577 | public const uint WM_HANDHELDLAST; 578 | public const uint WM_AFXFIRST; 579 | public const uint WM_AFXLAST; 580 | public const uint WM_PENWINFIRST; 581 | public const uint WM_RCRESULT; 582 | public const uint WM_HOOKRCRESULT; 583 | public const uint WM_GLOBALRCCHANGE; 584 | public const uint WM_PENMISCINFO; 585 | public const uint WM_SKB; 586 | public const uint WM_HEDITCTL; 587 | public const uint WM_PENCTL; 588 | public const uint WM_PENMISC; 589 | public const uint WM_CTLINIT; 590 | public const uint WM_PENEVENT; 591 | public const uint WM_PENWINLAST; 592 | public const uint DDM_SETFMT; 593 | public const uint DM_GETDEFID; 594 | public const uint NIN_SELECT; 595 | public const uint TBM_GETPOS; 596 | public const uint WM_PSD_PAGESETUPDLG; 597 | public const uint WM_USER; 598 | public const uint CBEM_INSERTITEMA; 599 | public const uint DDM_DRAW; 600 | public const uint DM_SETDEFID; 601 | public const uint HKM_SETHOTKEY; 602 | public const uint PBM_SETRANGE; 603 | public const uint RB_INSERTBANDA; 604 | public const uint SB_SETTEXTA; 605 | public const uint TB_ENABLEBUTTON; 606 | public const uint TBM_GETRANGEMIN; 607 | public const uint TTM_ACTIVATE; 608 | public const uint WM_CHOOSEFONT_GETLOGFONT; 609 | public const uint WM_PSD_FULLPAGERECT; 610 | public const uint CBEM_SETIMAGELIST; 611 | public const uint DDM_CLOSE; 612 | public const uint DM_REPOSITION; 613 | public const uint HKM_GETHOTKEY; 614 | public const uint PBM_SETPOS; 615 | public const uint RB_DELETEBAND; 616 | public const uint SB_GETTEXTA; 617 | public const uint TB_CHECKBUTTON; 618 | public const uint TBM_GETRANGEMAX; 619 | public const uint WM_PSD_MINMARGINRECT; 620 | public const uint CBEM_GETIMAGELIST; 621 | public const uint DDM_BEGIN; 622 | public const uint HKM_SETRULES; 623 | public const uint PBM_DELTAPOS; 624 | public const uint RB_GETBARINFO; 625 | public const uint SB_GETTEXTLENGTHA; 626 | public const uint TBM_GETTIC; 627 | public const uint TB_PRESSBUTTON; 628 | public const uint TTM_SETDELAYTIME; 629 | public const uint WM_PSD_MARGINRECT; 630 | public const uint CBEM_GETITEMA; 631 | public const uint DDM_END; 632 | public const uint PBM_SETSTEP; 633 | public const uint RB_SETBARINFO; 634 | public const uint SB_SETPARTS; 635 | public const uint TB_HIDEBUTTON; 636 | public const uint TBM_SETTIC; 637 | public const uint TTM_ADDTOOLA; 638 | public const uint WM_PSD_GREEKTEXTRECT; 639 | public const uint CBEM_SETITEMA; 640 | public const uint PBM_STEPIT; 641 | public const uint TB_INDETERMINATE; 642 | public const uint TBM_SETPOS; 643 | public const uint TTM_DELTOOLA; 644 | public const uint WM_PSD_ENVSTAMPRECT; 645 | public const uint CBEM_GETCOMBOCONTROL; 646 | public const uint PBM_SETRANGE32; 647 | public const uint RB_SETBANDINFOA; 648 | public const uint SB_GETPARTS; 649 | public const uint TB_MARKBUTTON; 650 | public const uint TBM_SETRANGE; 651 | public const uint TTM_NEWTOOLRECTA; 652 | public const uint WM_PSD_YAFULLPAGERECT; 653 | public const uint CBEM_GETEDITCONTROL; 654 | public const uint PBM_GETRANGE; 655 | public const uint RB_SETPARENT; 656 | public const uint SB_GETBORDERS; 657 | public const uint TBM_SETRANGEMIN; 658 | public const uint TTM_RELAYEVENT; 659 | public const uint CBEM_SETEXSTYLE; 660 | public const uint PBM_GETPOS; 661 | public const uint RB_HITTEST; 662 | public const uint SB_SETMINHEIGHT; 663 | public const uint TBM_SETRANGEMAX; 664 | public const uint TTM_GETTOOLINFOA; 665 | public const uint CBEM_GETEXSTYLE; 666 | public const uint CBEM_GETEXTENDEDSTYLE; 667 | public const uint PBM_SETBARCOLOR; 668 | public const uint RB_GETRECT; 669 | public const uint SB_SIMPLE; 670 | public const uint TB_ISBUTTONENABLED; 671 | public const uint TBM_CLEARTICS; 672 | public const uint TTM_SETTOOLINFOA; 673 | public const uint CBEM_HASEDITCHANGED; 674 | public const uint RB_INSERTBANDW; 675 | public const uint SB_GETRECT; 676 | public const uint TB_ISBUTTONCHECKED; 677 | public const uint TBM_SETSEL; 678 | public const uint TTM_HITTESTA; 679 | public const uint WIZ_QUERYNUMPAGES; 680 | public const uint CBEM_INSERTITEMW; 681 | public const uint RB_SETBANDINFOW; 682 | public const uint SB_SETTEXTW; 683 | public const uint TB_ISBUTTONPRESSED; 684 | public const uint TBM_SETSELSTART; 685 | public const uint TTM_GETTEXTA; 686 | public const uint WIZ_NEXT; 687 | public const uint CBEM_SETITEMW; 688 | public const uint RB_GETBANDCOUNT; 689 | public const uint SB_GETTEXTLENGTHW; 690 | public const uint TB_ISBUTTONHIDDEN; 691 | public const uint TBM_SETSELEND; 692 | public const uint TTM_UPDATETIPTEXTA; 693 | public const uint WIZ_PREV; 694 | public const uint CBEM_GETITEMW; 695 | public const uint RB_GETROWCOUNT; 696 | public const uint SB_GETTEXTW; 697 | public const uint TB_ISBUTTONINDETERMINATE; 698 | public const uint TTM_GETTOOLCOUNT; 699 | public const uint CBEM_SETEXTENDEDSTYLE; 700 | public const uint RB_GETROWHEIGHT; 701 | public const uint SB_ISSIMPLE; 702 | public const uint TB_ISBUTTONHIGHLIGHTED; 703 | public const uint TBM_GETPTICS; 704 | public const uint TTM_ENUMTOOLSA; 705 | public const uint SB_SETICON; 706 | public const uint TBM_GETTICPOS; 707 | public const uint TTM_GETCURRENTTOOLA; 708 | public const uint RB_IDTOINDEX; 709 | public const uint SB_SETTIPTEXTA; 710 | public const uint TBM_GETNUMTICS; 711 | public const uint TTM_WINDOWFROMPOINT; 712 | public const uint RB_GETTOOLTIPS; 713 | public const uint SB_SETTIPTEXTW; 714 | public const uint TBM_GETSELSTART; 715 | public const uint TB_SETSTATE; 716 | public const uint TTM_TRACKACTIVATE; 717 | public const uint RB_SETTOOLTIPS; 718 | public const uint SB_GETTIPTEXTA; 719 | public const uint TB_GETSTATE; 720 | public const uint TBM_GETSELEND; 721 | public const uint TTM_TRACKPOSITION; 722 | public const uint RB_SETBKCOLOR; 723 | public const uint SB_GETTIPTEXTW; 724 | public const uint TB_ADDBITMAP; 725 | public const uint TBM_CLEARSEL; 726 | public const uint TTM_SETTIPBKCOLOR; 727 | public const uint RB_GETBKCOLOR; 728 | public const uint SB_GETICON; 729 | public const uint TB_ADDBUTTONSA; 730 | public const uint TBM_SETTICFREQ; 731 | public const uint TTM_SETTIPTEXTCOLOR; 732 | public const uint RB_SETTEXTCOLOR; 733 | public const uint TB_INSERTBUTTONA; 734 | public const uint TBM_SETPAGESIZE; 735 | public const uint TTM_GETDELAYTIME; 736 | public const uint RB_GETTEXTCOLOR; 737 | public const uint TB_DELETEBUTTON; 738 | public const uint TBM_GETPAGESIZE; 739 | public const uint TTM_GETTIPBKCOLOR; 740 | public const uint RB_SIZETORECT; 741 | public const uint TB_GETBUTTON; 742 | public const uint TBM_SETLINESIZE; 743 | public const uint TTM_GETTIPTEXTCOLOR; 744 | public const uint RB_BEGINDRAG; 745 | public const uint TB_BUTTONCOUNT; 746 | public const uint TBM_GETLINESIZE; 747 | public const uint TTM_SETMAXTIPWIDTH; 748 | public const uint RB_ENDDRAG; 749 | public const uint TB_COMMANDTOINDEX; 750 | public const uint TBM_GETTHUMBRECT; 751 | public const uint TTM_GETMAXTIPWIDTH; 752 | public const uint RB_DRAGMOVE; 753 | public const uint TBM_GETCHANNELRECT; 754 | public const uint TB_SAVERESTOREA; 755 | public const uint TTM_SETMARGIN; 756 | public const uint RB_GETBARHEIGHT; 757 | public const uint TB_CUSTOMIZE; 758 | public const uint TBM_SETTHUMBLENGTH; 759 | public const uint TTM_GETMARGIN; 760 | public const uint RB_GETBANDINFOW; 761 | public const uint TB_ADDSTRINGA; 762 | public const uint TBM_GETTHUMBLENGTH; 763 | public const uint TTM_POP; 764 | public const uint RB_GETBANDINFOA; 765 | public const uint TB_GETITEMRECT; 766 | public const uint TBM_SETTOOLTIPS; 767 | public const uint TTM_UPDATE; 768 | public const uint RB_MINIMIZEBAND; 769 | public const uint TB_BUTTONSTRUCTSIZE; 770 | public const uint TBM_GETTOOLTIPS; 771 | public const uint TTM_GETBUBBLESIZE; 772 | public const uint RB_MAXIMIZEBAND; 773 | public const uint TBM_SETTIPSIDE; 774 | public const uint TB_SETBUTTONSIZE; 775 | public const uint TTM_ADJUSTRECT; 776 | public const uint TBM_SETBUDDY; 777 | public const uint TB_SETBITMAPSIZE; 778 | public const uint TTM_SETTITLEA; 779 | public const uint MSG_FTS_JUMP_VA; 780 | public const uint TB_AUTOSIZE; 781 | public const uint TBM_GETBUDDY; 782 | public const uint TTM_SETTITLEW; 783 | public const uint RB_GETBANDBORDERS; 784 | public const uint MSG_FTS_JUMP_QWORD; 785 | public const uint RB_SHOWBAND; 786 | public const uint TB_GETTOOLTIPS; 787 | public const uint MSG_REINDEX_REQUEST; 788 | public const uint TB_SETTOOLTIPS; 789 | public const uint MSG_FTS_WHERE_IS_IT; 790 | public const uint RB_SETPALETTE; 791 | public const uint TB_SETPARENT; 792 | public const uint RB_GETPALETTE; 793 | public const uint RB_MOVEBAND; 794 | public const uint TB_SETROWS; 795 | public const uint TB_GETROWS; 796 | public const uint TB_GETBITMAPFLAGS; 797 | public const uint TB_SETCMDID; 798 | public const uint RB_PUSHCHEVRON; 799 | public const uint TB_CHANGEBITMAP; 800 | public const uint TB_GETBITMAP; 801 | public const uint MSG_GET_DEFFONT; 802 | public const uint TB_GETBUTTONTEXTA; 803 | public const uint TB_REPLACEBITMAP; 804 | public const uint TB_SETINDENT; 805 | public const uint TB_SETIMAGELIST; 806 | public const uint TB_GETIMAGELIST; 807 | public const uint TB_LOADIMAGES; 808 | public const uint EM_CANPASTE; 809 | public const uint TTM_ADDTOOLW; 810 | public const uint EM_DISPLAYBAND; 811 | public const uint TB_GETRECT; 812 | public const uint TTM_DELTOOLW; 813 | public const uint EM_EXGETSEL; 814 | public const uint TB_SETHOTIMAGELIST; 815 | public const uint TTM_NEWTOOLRECTW; 816 | public const uint EM_EXLIMITTEXT; 817 | public const uint TB_GETHOTIMAGELIST; 818 | public const uint TTM_GETTOOLINFOW; 819 | public const uint EM_EXLINEFROMCHAR; 820 | public const uint TB_SETDISABLEDIMAGELIST; 821 | public const uint TTM_SETTOOLINFOW; 822 | public const uint EM_EXSETSEL; 823 | public const uint TB_GETDISABLEDIMAGELIST; 824 | public const uint TTM_HITTESTW; 825 | public const uint EM_FINDTEXT; 826 | public const uint TB_SETSTYLE; 827 | public const uint TTM_GETTEXTW; 828 | public const uint EM_FORMATRANGE; 829 | public const uint TB_GETSTYLE; 830 | public const uint TTM_UPDATETIPTEXTW; 831 | public const uint EM_GETCHARFORMAT; 832 | public const uint TB_GETBUTTONSIZE; 833 | public const uint TTM_ENUMTOOLSW; 834 | public const uint EM_GETEVENTMASK; 835 | public const uint TB_SETBUTTONWIDTH; 836 | public const uint TTM_GETCURRENTTOOLW; 837 | public const uint EM_GETOLEINTERFACE; 838 | public const uint TB_SETMAXTEXTROWS; 839 | public const uint EM_GETPARAFORMAT; 840 | public const uint TB_GETTEXTROWS; 841 | public const uint EM_GETSELTEXT; 842 | public const uint TB_GETOBJECT; 843 | public const uint EM_HIDESELECTION; 844 | public const uint TB_GETBUTTONINFOW; 845 | public const uint EM_PASTESPECIAL; 846 | public const uint TB_SETBUTTONINFOW; 847 | public const uint EM_REQUESTRESIZE; 848 | public const uint TB_GETBUTTONINFOA; 849 | public const uint EM_SELECTIONTYPE; 850 | public const uint TB_SETBUTTONINFOA; 851 | public const uint EM_SETBKGNDCOLOR; 852 | public const uint TB_INSERTBUTTONW; 853 | public const uint EM_SETCHARFORMAT; 854 | public const uint TB_ADDBUTTONSW; 855 | public const uint EM_SETEVENTMASK; 856 | public const uint TB_HITTEST; 857 | public const uint EM_SETOLECALLBACK; 858 | public const uint TB_SETDRAWTEXTFLAGS; 859 | public const uint EM_SETPARAFORMAT; 860 | public const uint TB_GETHOTITEM; 861 | public const uint EM_SETTARGETDEVICE; 862 | public const uint TB_SETHOTITEM; 863 | public const uint EM_STREAMIN; 864 | public const uint TB_SETANCHORHIGHLIGHT; 865 | public const uint EM_STREAMOUT; 866 | public const uint TB_GETANCHORHIGHLIGHT; 867 | public const uint EM_GETTEXTRANGE; 868 | public const uint TB_GETBUTTONTEXTW; 869 | public const uint EM_FINDWORDBREAK; 870 | public const uint TB_SAVERESTOREW; 871 | public const uint EM_SETOPTIONS; 872 | public const uint TB_ADDSTRINGW; 873 | public const uint EM_GETOPTIONS; 874 | public const uint TB_MAPACCELERATORA; 875 | public const uint EM_FINDTEXTEX; 876 | public const uint TB_GETINSERTMARK; 877 | public const uint EM_GETWORDBREAKPROCEX; 878 | public const uint TB_SETINSERTMARK; 879 | public const uint EM_SETWORDBREAKPROCEX; 880 | public const uint TB_INSERTMARKHITTEST; 881 | public const uint EM_SETUNDOLIMIT; 882 | public const uint TB_MOVEBUTTON; 883 | public const uint TB_GETMAXSIZE; 884 | public const uint EM_REDO; 885 | public const uint TB_SETEXTENDEDSTYLE; 886 | public const uint EM_CANREDO; 887 | public const uint TB_GETEXTENDEDSTYLE; 888 | public const uint EM_GETUNDONAME; 889 | public const uint TB_GETPADDING; 890 | public const uint EM_GETREDONAME; 891 | public const uint TB_SETPADDING; 892 | public const uint EM_STOPGROUPTYPING; 893 | public const uint TB_SETINSERTMARKCOLOR; 894 | public const uint EM_SETTEXTMODE; 895 | public const uint TB_GETINSERTMARKCOLOR; 896 | public const uint EM_GETTEXTMODE; 897 | public const uint TB_MAPACCELERATORW; 898 | public const uint EM_AUTOURLDETECT; 899 | public const uint TB_GETSTRINGW; 900 | public const uint EM_GETAUTOURLDETECT; 901 | public const uint TB_GETSTRINGA; 902 | public const uint EM_SETPALETTE; 903 | public const uint EM_GETTEXTEX; 904 | public const uint EM_GETTEXTLENGTHEX; 905 | public const uint EM_SHOWSCROLLBAR; 906 | public const uint EM_SETTEXTEX; 907 | public const uint TAPI_REPLY; 908 | public const uint ACM_OPENA; 909 | public const uint BFFM_SETSTATUSTEXTA; 910 | public const uint CDM_FIRST; 911 | public const uint CDM_GETSPEC; 912 | public const uint EM_SETPUNCTUATION; 913 | public const uint IPM_CLEARADDRESS; 914 | public const uint WM_CAP_UNICODE_START; 915 | public const uint ACM_PLAY; 916 | public const uint BFFM_ENABLEOK; 917 | public const uint CDM_GETFILEPATH; 918 | public const uint EM_GETPUNCTUATION; 919 | public const uint IPM_SETADDRESS; 920 | public const uint PSM_SETCURSEL; 921 | public const uint UDM_SETRANGE; 922 | public const uint WM_CHOOSEFONT_SETLOGFONT; 923 | public const uint ACM_STOP; 924 | public const uint BFFM_SETSELECTIONA; 925 | public const uint CDM_GETFOLDERPATH; 926 | public const uint EM_SETWORDWRAPMODE; 927 | public const uint IPM_GETADDRESS; 928 | public const uint PSM_REMOVEPAGE; 929 | public const uint UDM_GETRANGE; 930 | public const uint WM_CAP_SET_CALLBACK_ERRORW; 931 | public const uint WM_CHOOSEFONT_SETFLAGS; 932 | public const uint ACM_OPENW; 933 | public const uint BFFM_SETSELECTIONW; 934 | public const uint CDM_GETFOLDERIDLIST; 935 | public const uint EM_GETWORDWRAPMODE; 936 | public const uint IPM_SETRANGE; 937 | public const uint PSM_ADDPAGE; 938 | public const uint UDM_SETPOS; 939 | public const uint WM_CAP_SET_CALLBACK_STATUSW; 940 | public const uint BFFM_SETSTATUSTEXTW; 941 | public const uint CDM_SETCONTROLTEXT; 942 | public const uint EM_SETIMECOLOR; 943 | public const uint IPM_SETFOCUS; 944 | public const uint PSM_CHANGED; 945 | public const uint UDM_GETPOS; 946 | public const uint CDM_HIDECONTROL; 947 | public const uint EM_GETIMECOLOR; 948 | public const uint IPM_ISBLANK; 949 | public const uint PSM_RESTARTWINDOWS; 950 | public const uint UDM_SETBUDDY; 951 | public const uint CDM_SETDEFEXT; 952 | public const uint EM_SETIMEOPTIONS; 953 | public const uint PSM_REBOOTSYSTEM; 954 | public const uint UDM_GETBUDDY; 955 | public const uint EM_GETIMEOPTIONS; 956 | public const uint PSM_CANCELTOCLOSE; 957 | public const uint UDM_SETACCEL; 958 | public const uint EM_CONVPOSITION; 959 | public const uint PSM_QUERYSIBLINGS; 960 | public const uint UDM_GETACCEL; 961 | public const uint MCIWNDM_GETZOOM; 962 | public const uint PSM_UNCHANGED; 963 | public const uint UDM_SETBASE; 964 | public const uint PSM_APPLY; 965 | public const uint UDM_GETBASE; 966 | public const uint PSM_SETTITLEA; 967 | public const uint UDM_SETRANGE32; 968 | public const uint PSM_SETWIZBUTTONS; 969 | public const uint UDM_GETRANGE32; 970 | public const uint WM_CAP_DRIVER_GET_NAMEW; 971 | public const uint PSM_PRESSBUTTON; 972 | public const uint UDM_SETPOS32; 973 | public const uint WM_CAP_DRIVER_GET_VERSIONW; 974 | public const uint PSM_SETCURSELID; 975 | public const uint UDM_GETPOS32; 976 | public const uint PSM_SETFINISHTEXTA; 977 | public const uint PSM_GETTABCONTROL; 978 | public const uint PSM_ISDIALOGMESSAGE; 979 | public const uint MCIWNDM_REALIZE; 980 | public const uint PSM_GETCURRENTPAGEHWND; 981 | public const uint MCIWNDM_SETTIMEFORMATA; 982 | public const uint PSM_INSERTPAGE; 983 | public const uint EM_SETLANGOPTIONS; 984 | public const uint MCIWNDM_GETTIMEFORMATA; 985 | public const uint PSM_SETTITLEW; 986 | public const uint WM_CAP_FILE_SET_CAPTURE_FILEW; 987 | public const uint EM_GETLANGOPTIONS; 988 | public const uint MCIWNDM_VALIDATEMEDIA; 989 | public const uint PSM_SETFINISHTEXTW; 990 | public const uint WM_CAP_FILE_GET_CAPTURE_FILEW; 991 | public const uint EM_GETIMECOMPMODE; 992 | public const uint EM_FINDTEXTW; 993 | public const uint MCIWNDM_PLAYTO; 994 | public const uint WM_CAP_FILE_SAVEASW; 995 | public const uint EM_FINDTEXTEXW; 996 | public const uint MCIWNDM_GETFILENAMEA; 997 | public const uint EM_RECONVERSION; 998 | public const uint MCIWNDM_GETDEVICEA; 999 | public const uint PSM_SETHEADERTITLEA; 1000 | public const uint WM_CAP_FILE_SAVEDIBW; 1001 | public const uint EM_SETIMEMODEBIAS; 1002 | public const uint MCIWNDM_GETPALETTE; 1003 | public const uint PSM_SETHEADERTITLEW; 1004 | public const uint EM_GETIMEMODEBIAS; 1005 | public const uint MCIWNDM_SETPALETTE; 1006 | public const uint PSM_SETHEADERSUBTITLEA; 1007 | public const uint MCIWNDM_GETERRORA; 1008 | public const uint PSM_SETHEADERSUBTITLEW; 1009 | public const uint PSM_HWNDTOINDEX; 1010 | public const uint PSM_INDEXTOHWND; 1011 | public const uint MCIWNDM_SETINACTIVETIMER; 1012 | public const uint PSM_PAGETOINDEX; 1013 | public const uint PSM_INDEXTOPAGE; 1014 | public const uint DL_BEGINDRAG; 1015 | public const uint MCIWNDM_GETINACTIVETIMER; 1016 | public const uint PSM_IDTOINDEX; 1017 | public const uint DL_DRAGGING; 1018 | public const uint PSM_INDEXTOID; 1019 | public const uint DL_DROPPED; 1020 | public const uint PSM_GETRESULT; 1021 | public const uint DL_CANCELDRAG; 1022 | public const uint PSM_RECALCPAGESIZES; 1023 | public const uint MCIWNDM_GET_SOURCE; 1024 | public const uint MCIWNDM_PUT_SOURCE; 1025 | public const uint MCIWNDM_GET_DEST; 1026 | public const uint MCIWNDM_PUT_DEST; 1027 | public const uint MCIWNDM_CAN_PLAY; 1028 | public const uint MCIWNDM_CAN_WINDOW; 1029 | public const uint MCIWNDM_CAN_RECORD; 1030 | public const uint MCIWNDM_CAN_SAVE; 1031 | public const uint MCIWNDM_CAN_EJECT; 1032 | public const uint MCIWNDM_CAN_CONFIG; 1033 | public const uint IE_GETINK; 1034 | public const uint IE_MSGFIRST; 1035 | public const uint MCIWNDM_PALETTEKICK; 1036 | public const uint IE_SETINK; 1037 | public const uint IE_GETPENTIP; 1038 | public const uint IE_SETPENTIP; 1039 | public const uint IE_GETERASERTIP; 1040 | public const uint IE_SETERASERTIP; 1041 | public const uint IE_GETBKGND; 1042 | public const uint IE_SETBKGND; 1043 | public const uint IE_GETGRIDORIGIN; 1044 | public const uint IE_SETGRIDORIGIN; 1045 | public const uint IE_GETGRIDPEN; 1046 | public const uint IE_SETGRIDPEN; 1047 | public const uint IE_GETGRIDSIZE; 1048 | public const uint IE_SETGRIDSIZE; 1049 | public const uint IE_GETMODE; 1050 | public const uint IE_SETMODE; 1051 | public const uint IE_GETINKRECT; 1052 | public const uint WM_CAP_SET_MCI_DEVICEW; 1053 | public const uint WM_CAP_GET_MCI_DEVICEW; 1054 | public const uint WM_CAP_PAL_OPENW; 1055 | public const uint WM_CAP_PAL_SAVEW; 1056 | public const uint IE_GETAPPDATA; 1057 | public const uint IE_SETAPPDATA; 1058 | public const uint IE_GETDRAWOPTS; 1059 | public const uint IE_SETDRAWOPTS; 1060 | public const uint IE_GETFORMAT; 1061 | public const uint IE_SETFORMAT; 1062 | public const uint IE_GETINKINPUT; 1063 | public const uint IE_SETINKINPUT; 1064 | public const uint IE_GETNOTIFY; 1065 | public const uint IE_SETNOTIFY; 1066 | public const uint IE_GETRECOG; 1067 | public const uint IE_SETRECOG; 1068 | public const uint IE_GETSECURITY; 1069 | public const uint IE_SETSECURITY; 1070 | public const uint IE_GETSEL; 1071 | public const uint IE_SETSEL; 1072 | public const uint CDM_LAST; 1073 | public const uint EM_SETBIDIOPTIONS; 1074 | public const uint IE_DOCOMMAND; 1075 | public const uint MCIWNDM_NOTIFYMODE; 1076 | public const uint EM_GETBIDIOPTIONS; 1077 | public const uint IE_GETCOMMAND; 1078 | public const uint EM_SETTYPOGRAPHYOPTIONS; 1079 | public const uint IE_GETCOUNT; 1080 | public const uint EM_GETTYPOGRAPHYOPTIONS; 1081 | public const uint IE_GETGESTURE; 1082 | public const uint MCIWNDM_NOTIFYMEDIA; 1083 | public const uint EM_SETEDITSTYLE; 1084 | public const uint IE_GETMENU; 1085 | public const uint EM_GETEDITSTYLE; 1086 | public const uint IE_GETPAINTDC; 1087 | public const uint MCIWNDM_NOTIFYERROR; 1088 | public const uint IE_GETPDEVENT; 1089 | public const uint IE_GETSELCOUNT; 1090 | public const uint IE_GETSELITEMS; 1091 | public const uint IE_GETSTYLE; 1092 | public const uint MCIWNDM_SETTIMEFORMATW; 1093 | public const uint EM_OUTLINE; 1094 | public const uint MCIWNDM_GETTIMEFORMATW; 1095 | public const uint EM_GETSCROLLPOS; 1096 | public const uint EM_SETSCROLLPOS; 1097 | public const uint EM_SETFONTSIZE; 1098 | public const uint EM_GETZOOM; 1099 | public const uint MCIWNDM_GETFILENAMEW; 1100 | public const uint EM_SETZOOM; 1101 | public const uint MCIWNDM_GETDEVICEW; 1102 | public const uint EM_GETVIEWKIND; 1103 | public const uint EM_SETVIEWKIND; 1104 | public const uint EM_GETPAGE; 1105 | public const uint MCIWNDM_GETERRORW; 1106 | public const uint EM_SETPAGE; 1107 | public const uint EM_GETHYPHENATEINFO; 1108 | public const uint EM_SETHYPHENATEINFO; 1109 | public const uint EM_GETPAGEROTATE; 1110 | public const uint EM_SETPAGEROTATE; 1111 | public const uint EM_GETCTFMODEBIAS; 1112 | public const uint EM_SETCTFMODEBIAS; 1113 | public const uint EM_GETCTFOPENSTATUS; 1114 | public const uint EM_SETCTFOPENSTATUS; 1115 | public const uint EM_GETIMECOMPTEXT; 1116 | public const uint EM_ISIME; 1117 | public const uint EM_GETIMEPROPERTY; 1118 | public const uint EM_GETQUERYRTFOBJ; 1119 | public const uint EM_SETQUERYRTFOBJ; 1120 | public const uint FM_GETFOCUS; 1121 | public const uint FM_GETDRIVEINFOA; 1122 | public const uint FM_GETSELCOUNT; 1123 | public const uint FM_GETSELCOUNTLFN; 1124 | public const uint FM_GETFILESELA; 1125 | public const uint FM_GETFILESELLFNA; 1126 | public const uint FM_REFRESH_WINDOWS; 1127 | public const uint FM_RELOAD_EXTENSIONS; 1128 | public const uint FM_GETDRIVEINFOW; 1129 | public const uint FM_GETFILESELW; 1130 | public const uint FM_GETFILESELLFNW; 1131 | public const uint WLX_WM_SAS; 1132 | public const uint SM_GETSELCOUNT; 1133 | public const uint UM_GETSELCOUNT; 1134 | public const uint WM_CPL_LAUNCH; 1135 | public const uint SM_GETSERVERSELA; 1136 | public const uint UM_GETUSERSELA; 1137 | public const uint WM_CPL_LAUNCHED; 1138 | public const uint SM_GETSERVERSELW; 1139 | public const uint UM_GETUSERSELW; 1140 | public const uint SM_GETCURFOCUSA; 1141 | public const uint UM_GETGROUPSELA; 1142 | public const uint SM_GETCURFOCUSW; 1143 | public const uint UM_GETGROUPSELW; 1144 | public const uint SM_GETOPTIONS; 1145 | public const uint UM_GETCURFOCUSA; 1146 | public const uint UM_GETCURFOCUSW; 1147 | public const uint UM_GETOPTIONS; 1148 | public const uint UM_GETOPTIONS2; 1149 | public const uint LVM_FIRST; 1150 | public const uint LVM_GETBKCOLOR; 1151 | public const uint LVM_SETBKCOLOR; 1152 | public const uint LVM_GETIMAGELIST; 1153 | public const uint LVM_SETIMAGELIST; 1154 | public const uint LVM_GETITEMCOUNT; 1155 | public const uint LVM_GETITEMA; 1156 | public const uint LVM_SETITEMA; 1157 | public const uint LVM_INSERTITEMA; 1158 | public const uint LVM_DELETEITEM; 1159 | public const uint LVM_DELETEALLITEMS; 1160 | public const uint LVM_GETCALLBACKMASK; 1161 | public const uint LVM_SETCALLBACKMASK; 1162 | public const uint LVM_GETNEXTITEM; 1163 | public const uint LVM_FINDITEMA; 1164 | public const uint LVM_GETITEMRECT; 1165 | public const uint LVM_SETITEMPOSITION; 1166 | public const uint LVM_GETITEMPOSITION; 1167 | public const uint LVM_GETSTRINGWIDTHA; 1168 | public const uint LVM_HITTEST; 1169 | public const uint LVM_ENSUREVISIBLE; 1170 | public const uint LVM_SCROLL; 1171 | public const uint LVM_REDRAWITEMS; 1172 | public const uint LVM_ARRANGE; 1173 | public const uint LVM_EDITLABELA; 1174 | public const uint LVM_GETEDITCONTROL; 1175 | public const uint LVM_GETCOLUMNA; 1176 | public const uint LVM_SETCOLUMNA; 1177 | public const uint LVM_INSERTCOLUMNA; 1178 | public const uint LVM_DELETECOLUMN; 1179 | public const uint LVM_GETCOLUMNWIDTH; 1180 | public const uint LVM_SETCOLUMNWIDTH; 1181 | public const uint LVM_GETHEADER; 1182 | public const uint LVM_CREATEDRAGIMAGE; 1183 | public const uint LVM_GETVIEWRECT; 1184 | public const uint LVM_GETTEXTCOLOR; 1185 | public const uint LVM_SETTEXTCOLOR; 1186 | public const uint LVM_GETTEXTBKCOLOR; 1187 | public const uint LVM_SETTEXTBKCOLOR; 1188 | public const uint LVM_GETTOPINDEX; 1189 | public const uint LVM_GETCOUNTPERPAGE; 1190 | public const uint LVM_GETORIGIN; 1191 | public const uint LVM_UPDATE; 1192 | public const uint LVM_SETITEMSTATE; 1193 | public const uint LVM_GETITEMSTATE; 1194 | public const uint LVM_GETITEMTEXTA; 1195 | public const uint LVM_SETITEMTEXTA; 1196 | public const uint LVM_SETITEMCOUNT; 1197 | public const uint LVM_SORTITEMS; 1198 | public const uint LVM_SETITEMPOSITION32; 1199 | public const uint LVM_GETSELECTEDCOUNT; 1200 | public const uint LVM_GETITEMSPACING; 1201 | public const uint LVM_GETISEARCHSTRINGA; 1202 | public const uint LVM_SETICONSPACING; 1203 | public const uint LVM_SETEXTENDEDLISTVIEWSTYLE; 1204 | public const uint LVM_GETEXTENDEDLISTVIEWSTYLE; 1205 | public const uint LVM_GETSUBITEMRECT; 1206 | public const uint LVM_SUBITEMHITTEST; 1207 | public const uint LVM_SETCOLUMNORDERARRAY; 1208 | public const uint LVM_GETCOLUMNORDERARRAY; 1209 | public const uint LVM_SETHOTITEM; 1210 | public const uint LVM_GETHOTITEM; 1211 | public const uint LVM_SETHOTCURSOR; 1212 | public const uint LVM_GETHOTCURSOR; 1213 | public const uint LVM_APPROXIMATEVIEWRECT; 1214 | public const uint LVM_SETWORKAREAS; 1215 | public const uint LVM_GETSELECTIONMARK; 1216 | public const uint LVM_SETSELECTIONMARK; 1217 | public const uint LVM_SETBKIMAGEA; 1218 | public const uint LVM_GETBKIMAGEA; 1219 | public const uint LVM_GETWORKAREAS; 1220 | public const uint LVM_SETHOVERTIME; 1221 | public const uint LVM_GETHOVERTIME; 1222 | public const uint LVM_GETNUMBEROFWORKAREAS; 1223 | public const uint LVM_SETTOOLTIPS; 1224 | public const uint LVM_GETITEMW; 1225 | public const uint LVM_SETITEMW; 1226 | public const uint LVM_INSERTITEMW; 1227 | public const uint LVM_GETTOOLTIPS; 1228 | public const uint LVM_FINDITEMW; 1229 | public const uint LVM_GETSTRINGWIDTHW; 1230 | public const uint LVM_GETCOLUMNW; 1231 | public const uint LVM_SETCOLUMNW; 1232 | public const uint LVM_INSERTCOLUMNW; 1233 | public const uint LVM_GETITEMTEXTW; 1234 | public const uint LVM_SETITEMTEXTW; 1235 | public const uint LVM_GETISEARCHSTRINGW; 1236 | public const uint LVM_EDITLABELW; 1237 | public const uint LVM_GETBKIMAGEW; 1238 | public const uint LVM_SETSELECTEDCOLUMN; 1239 | public const uint LVM_SETTILEWIDTH; 1240 | public const uint LVM_SETVIEW; 1241 | public const uint LVM_GETVIEW; 1242 | public const uint LVM_INSERTGROUP; 1243 | public const uint LVM_SETGROUPINFO; 1244 | public const uint LVM_GETGROUPINFO; 1245 | public const uint LVM_REMOVEGROUP; 1246 | public const uint LVM_MOVEGROUP; 1247 | public const uint LVM_MOVEITEMTOGROUP; 1248 | public const uint LVM_SETGROUPMETRICS; 1249 | public const uint LVM_GETGROUPMETRICS; 1250 | public const uint LVM_ENABLEGROUPVIEW; 1251 | public const uint LVM_SORTGROUPS; 1252 | public const uint LVM_INSERTGROUPSORTED; 1253 | public const uint LVM_REMOVEALLGROUPS; 1254 | public const uint LVM_HASGROUP; 1255 | public const uint LVM_SETTILEVIEWINFO; 1256 | public const uint LVM_GETTILEVIEWINFO; 1257 | public const uint LVM_SETTILEINFO; 1258 | public const uint LVM_GETTILEINFO; 1259 | public const uint LVM_SETINSERTMARK; 1260 | public const uint LVM_GETINSERTMARK; 1261 | public const uint LVM_INSERTMARKHITTEST; 1262 | public const uint LVM_GETINSERTMARKRECT; 1263 | public const uint LVM_SETINSERTMARKCOLOR; 1264 | public const uint LVM_GETINSERTMARKCOLOR; 1265 | public const uint LVM_SETINFOTIP; 1266 | public const uint LVM_GETSELECTEDCOLUMN; 1267 | public const uint LVM_ISGROUPVIEWENABLED; 1268 | public const uint LVM_GETOUTLINECOLOR; 1269 | public const uint LVM_SETOUTLINECOLOR; 1270 | public const uint LVM_CANCELEDITLABEL; 1271 | public const uint LVM_MAPINDEXTOID; 1272 | public const uint LVM_MAPIDTOINDEX; 1273 | public const uint LVM_ISITEMVISIBLE; 1274 | public const uint LVM_GETEMPTYTEXT; 1275 | public const uint LVM_GETFOOTERRECT; 1276 | public const uint LVM_GETFOOTERINFO; 1277 | public const uint LVM_GETFOOTERITEMRECT; 1278 | public const uint LVM_GETFOOTERITEM; 1279 | public const uint LVM_GETITEMINDEXRECT; 1280 | public const uint LVM_SETITEMINDEXSTATE; 1281 | public const uint LVM_GETNEXTITEMINDEX; 1282 | public const uint OCM__BASE; 1283 | public const uint LVM_SETUNICODEFORMAT; 1284 | public const uint LVM_GETUNICODEFORMAT; 1285 | public const uint OCM_CTLCOLOR; 1286 | public const uint OCM_DRAWITEM; 1287 | public const uint OCM_MEASUREITEM; 1288 | public const uint OCM_DELETEITEM; 1289 | public const uint OCM_VKEYTOITEM; 1290 | public const uint OCM_CHARTOITEM; 1291 | public const uint OCM_COMPAREITEM; 1292 | public const uint OCM_NOTIFY; 1293 | public const uint OCM_COMMAND; 1294 | public const uint OCM_HSCROLL; 1295 | public const uint OCM_VSCROLL; 1296 | public const uint OCM_CTLCOLORMSGBOX; 1297 | public const uint OCM_CTLCOLOREDIT; 1298 | public const uint OCM_CTLCOLORLISTBOX; 1299 | public const uint OCM_CTLCOLORBTN; 1300 | public const uint OCM_CTLCOLORDLG; 1301 | public const uint OCM_CTLCOLORSCROLLBAR; 1302 | public const uint OCM_CTLCOLORSTATIC; 1303 | public const uint OCM_PARENTNOTIFY; 1304 | public const uint WM_APP; 1305 | public const uint WM_RASDIALEVENT; 1306 | public const uint WM_CLIPBOARDUPDATE; 1307 | --------------------------------------------------------------------------------