Skip to content

Commit d49978d

Browse files
authored
Build instructions
1 parent c7b2ab1 commit d49978d

File tree

1 file changed

+98
-27
lines changed

1 file changed

+98
-27
lines changed

README.md

Lines changed: 98 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,41 @@
11
# HComponentLibrary
2-
HComponenLibrary is a lightweight UI component library for C++ which is highly inspired by Java Swing. <br>
3-
Project aims to make it easy to convert __minimal__ Java Swing projects to native Windows application.
2+
HComponenLibrary is a lightweight UI component library for C++ which is highly inspired by Java Swing's syntax.
3+
## Why Should I Use HCl
4+
* HCl directly uses Win32 API, so it has minimal dependencies and maximum performance
5+
* Its syntax is similar to Java Swing so it can be learned easily
6+
* It can be used to convert __minimal__ Java Swing projects to native Windows applications
7+
* It has minimal classes which are necessary to create a GUI application
8+
* Size of the DLL file is so small (Around 230KiB)
9+
* LGPL licensed so it can also be used in dynamically linked proprietary applications
10+
## Classes
11+
HComponentLibrary consist of classes below:
12+
|Classes|Explanation|
13+
|-------|-----------|
14+
|ActionEvent|Contains an action event for action listeners|
15+
|ButtonGroup|Groups radio buttons to be sure only one button selected simultaneously|
16+
|Component|Parent class of UI components|
17+
|Dimension|Contains width and height values|
18+
|HButton|Creates a clickable button|
19+
|HCheckBox|Creates a checkbox|
20+
|HComboBox|Creates a dropdown list|
21+
|HFrame|Creates an application window which can be main window|
22+
|HInternalFrame|Creates a window which can be displayed inside panels|
23+
|HLabel|Displays a text|
24+
|HPanel|Can contain UI elements|
25+
|HRadioButton|Creates a radio button|
26+
|HTextArea|Displays an editable multiple line text|
27+
|HTextField|Displays an editable one line text|
28+
|KeyEvent|Stores data for key listeners|
29+
|Point|Contains x and y axis|
30+
|String|Performs cast operations|
31+
432
## Sample Applications
5-
A java swing developer can easily understand how to use HComponentLibrary with these examples.
33+
A Java Swing developer can easily understand how to use HComponentLibrary with these examples.
634
### "Hello World" Application
735
Here is an example of how to use library, its syntax hugely inspired by Swing.
836
```cpp
937
#include "windows.h"
10-
#include "HCl.h";
38+
#include "HCl.h"
1139

1240
// Starting point of application
1341
int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE, PWSTR pCmdLine, int nCmdShow) {
@@ -39,7 +67,7 @@ int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE, PWSTR pCmdLine, int nCmdShow
3967
### An Example With Combo Box
4068
Slightly more complex application with combo box and text field.
4169
```cpp
42-
#include "HCl.h";
70+
#include "HCl.h"
4371
#include "windows.h"
4472
4573
HComboBox combo;
@@ -100,27 +128,6 @@ int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE, PWSTR pCmdLine, int nCmdShow
100128
return WaitAll();
101129
}
102130
```
103-
## Classes
104-
HComponentLibrary consist of classes below:
105-
```
106-
- ActionEvent
107-
- ButtonGroup
108-
- Component
109-
- Dimension
110-
- HButton
111-
- HCheckBox
112-
- HComboBox
113-
- HFrame
114-
- HInternalFrame
115-
- HLabel
116-
- HPanel
117-
- HRadioButton
118-
- HTextArea
119-
- HTextField
120-
- KeyEvent
121-
- Point
122-
- String
123-
```
124131
## How to Install
125132
To use HCl library do this steps after copying HCl Component Library folder to C:\
126133

@@ -136,4 +143,68 @@ To use HCl library do this steps after copying HCl Component Library folder to C
136143

137144
That's all, you can use H Component Library in your C++ project by using; #include "HCl.h";
138145
## Build From Source
139-
Just open HCl.sln file with Visual Studio, change source code and compile.
146+
### Windows
147+
Just open HCl.sln file with Visual Studio, change source code and compile.<br>
148+
You can also compile the project with CMake with similar steps in Linux section.
149+
### Linux
150+
HCl uses Windows api and cannot be natively compiled on Linux distros. But it can be cross compiled and run with MinGW and Wine projects.<br>
151+
These steps for RHEL based distros can also be applied other Linux based operating systems easily.
152+
### RHEL Based Distros
153+
#### Compiling With CMake
154+
Install necessary packages by
155+
```bash
156+
sudo dnf install mingw64-gcc mingw64-gcc-c++ mingw64-headers mingw64-filesystem
157+
```
158+
or to compile for 32 bit architecture use
159+
```bash
160+
sudo dnf install mingw32-gcc mingw32-gcc-c++ mingw32-headers mingw32-filesystem
161+
```
162+
Then open project root directory and
163+
```bash
164+
mkdir build
165+
mingw64-cmake ..
166+
mingw64-make
167+
```
168+
for 32 bit
169+
```bash
170+
mkdir build
171+
mingw32-cmake ..
172+
mingw32-make
173+
```
174+
Then libHCL.dll and libHCL.dll.a files can be found at build/HCL directory. libHCL.dll.a can be renamed to HCL.lib.
175+
#### Testing With Wine
176+
Be sure Wine64 is installed properly.<br>
177+
Copy any of the examples above and paste it to Test.cpp file.<br>
178+
Copy libHCL.dll and HCl.h files to the same directory with Test.cpp<br>
179+
Copy HCL.lib to /home/$USER/HCl (Any directory can be used)<br>
180+
Run following code to compile application with HCl
181+
```bash
182+
x86_64-w64-mingw64-g++ Test.cpp -lHCl -L/home/$USER/HCl -municode -o Test.exe
183+
```
184+
For 32 bit
185+
```bash
186+
x86_64-w64-mingw64-g++ Test.cpp -lHCl -L/home/$USER/HCl -municode -o Test.exe
187+
```
188+
Before run the compiled application all necessary dll files of MinGW should either be copied to same directory with appliction or included to WINEPATH environment variable properly.
189+
|DLL Files|Can Be Found At (x64)|Can Be Found At (x32)|
190+
|---------|---------------------|---------------------|
191+
|libgcc_s_seh-1.dll|/usr/x86_64-w64-mingw32/sys-root/mingw/bin|-|
192+
|libstdc++-6.dll|/usr/x86_64-w64-mingw32/sys-root/mingw/bin|/usr/i686-w64-mingw32/sys-root/mingw/bin|
193+
194+
WINEPATH environment variable can be initialized by
195+
```bash
196+
export WINEPATH="/usr/x86_64-w64-mingw32/sys-root/mingw/bin"
197+
```
198+
For 32 bit
199+
```bash
200+
export WINEPATH="/usr/i686-w64-mingw32/sys-root/mingw/bin"
201+
```
202+
_Note: In every individual terminal session this export command should be run._<br><br>
203+
Finally compiled application can be run by following command
204+
```bash
205+
wine64 Test.exe
206+
```
207+
For 32 bit
208+
```bash
209+
wine Test.exe
210+
```

0 commit comments

Comments
 (0)