├── LICENSE ├── README.md ├── gemgui ├── AtariST8x16SystemFont.ttf ├── build_sharedlib.sh ├── gemactive.bmp ├── gembutton.cpp ├── gembutton.h ├── gembuttons.bmp ├── gemcombox.cpp ├── gemcombox.h ├── gemcommon.h ├── gemdialog.cpp ├── gemdialog.h ├── gemform.cpp ├── gemform.h ├── gemlabel.cpp ├── gemlabel.h ├── gemmenu.cpp ├── gemmenu.h ├── gemmenubaritem.cpp ├── gemmenubaritem.h ├── gemtextbox.cpp └── gemtextbox.h ├── gemguilib.png ├── main.cpp └── makefile /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc., 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Lesser General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | 282 | How to Apply These Terms to Your New Programs 283 | 284 | If you develop a new program, and you want it to be of the greatest 285 | possible use to the public, the best way to achieve this is to make it 286 | free software which everyone can redistribute and change under these terms. 287 | 288 | To do so, attach the following notices to the program. It is safest 289 | to attach them to the start of each source file to most effectively 290 | convey the exclusion of warranty; and each file should have at least 291 | the "copyright" line and a pointer to where the full notice is found. 292 | 293 | 294 | Copyright (C) 295 | 296 | This program is free software; you can redistribute it and/or modify 297 | it under the terms of the GNU General Public License as published by 298 | the Free Software Foundation; either version 2 of the License, or 299 | (at your option) any later version. 300 | 301 | This program is distributed in the hope that it will be useful, 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 | GNU General Public License for more details. 305 | 306 | You should have received a copy of the GNU General Public License along 307 | with this program; if not, write to the Free Software Foundation, Inc., 308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 309 | 310 | Also add information on how to contact you by electronic and paper mail. 311 | 312 | If the program is interactive, make it output a short notice like this 313 | when it starts in an interactive mode: 314 | 315 | Gnomovision version 69, Copyright (C) year name of author 316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 317 | This is free software, and you are welcome to redistribute it 318 | under certain conditions; type `show c' for details. 319 | 320 | The hypothetical commands `show w' and `show c' should show the appropriate 321 | parts of the General Public License. Of course, the commands you use may 322 | be called something other than `show w' and `show c'; they could even be 323 | mouse-clicks or menu items--whatever suits your program. 324 | 325 | You should also get your employer (if you work as a programmer) or your 326 | school, if any, to sign a "copyright disclaimer" for the program, if 327 | necessary. Here is a sample; alter the names: 328 | 329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 330 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 331 | 332 | , 1 April 1989 333 | Ty Coon, President of Vice 334 | 335 | This General Public License does not permit incorporating your program into 336 | proprietary programs. If your program is a subroutine library, you may 337 | consider it more useful to permit linking proprietary applications with the 338 | library. If this is what you want to do, use the GNU Lesser General 339 | Public License instead of this License. 340 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # GEMGUILib 2 | Atari GEM GUI library using Nana C++ Library 3 | 4 | 5 | ``` bash 6 | # On Linux only 7 | # to create libgemgui.so 8 | cd gemgui 9 | ./build_sharedlib.sh 10 | 11 | # to build sample 12 | cd .. 13 | make clean && make 14 | ./gemGuiSample 15 | 16 | ''' 17 | 18 | 19 | -------------------------------------------------------------------------------- /gemgui/AtariST8x16SystemFont.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emartisoft/GEMGUILib/833445aa4ae293bdf4462bc2daca080201b42a18/gemgui/AtariST8x16SystemFont.ttf -------------------------------------------------------------------------------- /gemgui/build_sharedlib.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | g++ -Wall -fexceptions -O2 -c gemform.cpp -o gemform.o -I/include/ -fPIC 3 | g++ -Wall -fexceptions -O2 -c gemlabel.cpp -o gemlabel.o -I/include/ -fPIC 4 | g++ -Wall -fexceptions -O2 -c gembutton.cpp -o gembutton.o -I/include/ -fPIC 5 | g++ -Wall -fexceptions -O2 -c gemcombox.cpp -o gemcombox.o -I/include/ -fPIC 6 | g++ -Wall -fexceptions -O2 -c gemmenu.cpp -o gemmenu.o -I/include/ -fPIC 7 | g++ -Wall -fexceptions -O2 -c gemmenubaritem.cpp -o gemmenubaritem.o -I/include/ -fPIC 8 | g++ -Wall -fexceptions -O2 -c gemtextbox.cpp -o gemtextbox.o -I/include/ -fPIC 9 | g++ -Wall -fexceptions -O2 -c gemdialog.cpp -o gemdialog.o -I/include/ -fPIC 10 | g++ -shared *.o -o ../libgemgui.so -s 11 | rm -f *.o 12 | sudo cp ../libgemgui.so /lib/ 13 | sudo mkdir -p /usr/share/gem/ 14 | sudo cp AtariST8x16SystemFont.ttf /usr/share/gem/ 15 | sudo cp gembuttons.bmp /usr/share/gem/ 16 | sudo cp gemactive.bmp /usr/share/gem/ 17 | 18 | -------------------------------------------------------------------------------- /gemgui/gemactive.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emartisoft/GEMGUILib/833445aa4ae293bdf4462bc2daca080201b42a18/gemgui/gemactive.bmp -------------------------------------------------------------------------------- /gemgui/gembutton.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * GEMGUILib 3 | * 4 | * Copyright (C) 2020 emartisoft. All rights reserved. 5 | * Author: emarti, Murat Ozdemir 6 | * 7 | * This file is distributed under the GNU General Public License, version 2 8 | * or at your option any later version. See . 9 | * 10 | */ 11 | 12 | #include "gembutton.h" 13 | 14 | GEMButton::GEMButton(GEMForm& af, string text, const rectangle& r) : button(af, r), f{12, FONT} 15 | { 16 | caption(text); 17 | Set(); 18 | } 19 | 20 | GEMButton::GEMButton(GEMDialog& af, string text, const rectangle& r) : button(af, r), f{12, FONT} 21 | { 22 | caption(text); 23 | Set(); 24 | } 25 | 26 | void GEMButton::Set() 27 | { 28 | typeface(f); 29 | enable_focus_color(false); 30 | edge_effects(false); 31 | OnPaint(); 32 | events().mouse_down([&](const arg_mouse& mp) {GEMButton::OnMouseDown(mp); }); 33 | events().mouse_up([&](const arg_mouse& mp) {GEMButton::OnMouseUp(mp); }); 34 | pressed = false; 35 | } 36 | 37 | void GEMButton::OnPaint() 38 | { 39 | drawing dw(*this); 40 | dw.clear(); 41 | dw.draw([this](paint::graphics& g) 42 | { 43 | unsigned int w = g.size().width; 44 | unsigned int h = g.size().height; 45 | unsigned int p = (pressed) ? 1 : 0; 46 | nana::size captionSize = g.bidi_extent_size(caption()); 47 | 48 | g.rectangle(rectangle{ 0, 0, w, h }, true, BLACK); 49 | g.rectangle(rectangle{ 2, 2, w-4, h-4 }, true, HIGHLIGHT); 50 | g.rectangle(rectangle{ 2, 2, w-5, h-5 }, true, (pressed)?BLACK:WHITE); 51 | g.rectangle(rectangle{ 3, 3, w-5, h-5 }, true, (pressed)?WHITE:LIGHT); 52 | g.rectangle(rectangle{ 3, 3, w-6, h-6 }, true, HIGHLIGHT); 53 | g.string({static_cast ((w - captionSize.width)/2+p), static_cast ((h - captionSize.height)/2+p)}, caption(), BLACK); 54 | 55 | }); 56 | dw.update(); 57 | } 58 | 59 | void GEMButton::OnMouseDown(const arg_mouse& e) 60 | { 61 | pressed = true; 62 | OnPaint(); 63 | } 64 | 65 | void GEMButton::OnMouseUp(const arg_mouse& e) 66 | { 67 | pressed = false; 68 | OnPaint(); 69 | } 70 | 71 | -------------------------------------------------------------------------------- /gemgui/gembutton.h: -------------------------------------------------------------------------------- 1 | /* 2 | * GEMGUILib 3 | * 4 | * Copyright (C) 2020 emartisoft. All rights reserved. 5 | * Author: emarti, Murat Ozdemir 6 | * 7 | * This file is distributed under the GNU General Public License, version 2 8 | * or at your option any later version. See . 9 | * 10 | */ 11 | 12 | #ifndef GEMBUTTON_H 13 | #define GEMBUTTON_H 14 | 15 | #include 16 | #include 17 | #include "gemcommon.h" 18 | #include "gemform.h" 19 | #include "gemdialog.h" 20 | 21 | using namespace nana; 22 | using namespace std; 23 | 24 | class GEMButton : public button 25 | { 26 | public: 27 | GEMButton(GEMForm&, string, const rectangle&); 28 | GEMButton(GEMDialog&, string, const rectangle&); 29 | void setFont(paint::font &ft){ f = ft; } 30 | private: 31 | paint::font f; 32 | bool pressed; 33 | void OnMouseDown(const arg_mouse& e); 34 | void OnMouseUp(const arg_mouse& e); 35 | void OnPaint(); 36 | void Set(); 37 | }; 38 | #endif // GEMBUTTON_H 39 | -------------------------------------------------------------------------------- /gemgui/gembuttons.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emartisoft/GEMGUILib/833445aa4ae293bdf4462bc2daca080201b42a18/gemgui/gembuttons.bmp -------------------------------------------------------------------------------- /gemgui/gemcombox.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * GEMGUILib 3 | * 4 | * Copyright (C) 2020 emartisoft. All rights reserved. 5 | * Author: emarti, Murat Ozdemir 6 | * 7 | * This file is distributed under the GNU General Public License, version 2 8 | * or at your option any later version. See . 9 | * 10 | */ 11 | 12 | #include "gemcombox.h" 13 | 14 | GEMCombox::GEMCombox(GEMForm& af, const rectangle& r) : combox(af, r),f{12, FONT} 15 | { 16 | Set(); 17 | } 18 | 19 | GEMCombox::GEMCombox(GEMDialog& af, const rectangle& r) : combox(af, r),f{12, FONT} 20 | { 21 | Set(); 22 | } 23 | 24 | void GEMCombox::Set() 25 | { 26 | bgcolor(WHITE); 27 | typeface(f); 28 | OnPaint(); 29 | rend.setFont(f); 30 | renderer(&rend); 31 | events().selected ( [this](const arg_combox &){ OnPaint(); }); 32 | } 33 | 34 | void GEMCombox::OnPaint() 35 | { 36 | drawing dw(*this); 37 | dw.clear(); 38 | dw.draw([this](paint::graphics& g) 39 | { 40 | unsigned int w = g.size().width; 41 | unsigned int h = g.size().height; 42 | nana::size captionSize = g.bidi_extent_size(caption()); 43 | 44 | g.rectangle(rectangle{ 0, 0, w, h }, true, BLACK); 45 | g.rectangle(rectangle{ 2, 2, w-4, h-4 }, true, WHITE); 46 | g.string({static_cast ((w - captionSize.width)/2), static_cast ((h - captionSize.height)/2)}, caption(), BLACK); 47 | 48 | }); 49 | dw.update(); 50 | } 51 | 52 | -------------------------------------------------------------------------------- /gemgui/gemcombox.h: -------------------------------------------------------------------------------- 1 | /* 2 | * GEMGUILib 3 | * 4 | * Copyright (C) 2020 emartisoft. All rights reserved. 5 | * Author: emarti, Murat Ozdemir 6 | * 7 | * This file is distributed under the GNU General Public License, version 2 8 | * or at your option any later version. See . 9 | * 10 | */ 11 | 12 | #ifndef GEMCOMBOX_H 13 | #define GEMCOMBOX_H 14 | 15 | #include "gemcommon.h" 16 | #include "gemform.h" 17 | #include "gemdialog.h" 18 | #include 19 | #include 20 | #include 21 | 22 | using namespace nana; 23 | 24 | class GEMComboxRenderer : public combox::item_renderer 25 | { 26 | public: 27 | void setFont(paint::font &ft){ f = ft; } 28 | private: 29 | void image(bool enb, unsigned px){} 30 | paint::font f ; 31 | void render(widget_reference, graph_reference graph, const rectangle& r, const item_interface* item, state_t state) 32 | { 33 | graph.rectangle(r, true, (state == StateHighlighted) ? BLACK : WHITE); 34 | graph.typeface(f); 35 | graph.string({r.x + 2, r.y + 2}, item->text(), (state == StateHighlighted) ? WHITE : BLACK ); 36 | } 37 | 38 | unsigned item_pixels(graph_reference graph) const 39 | { 40 | unsigned ascent, descent, ileading; 41 | graph.typeface(f); 42 | graph.text_metrics(ascent, descent, ileading); 43 | return ascent + descent + 4; 44 | } 45 | }; 46 | 47 | class GEMCombox : public combox 48 | { 49 | public: 50 | GEMCombox(GEMForm&, const rectangle&); 51 | GEMCombox(GEMDialog&, const rectangle&); 52 | void setFont(paint::font &ft){ f = ft; } 53 | private: 54 | paint::font f; 55 | void OnPaint(); 56 | GEMComboxRenderer rend; 57 | void Set(); 58 | }; 59 | 60 | #endif // GEMCOMBOX_H 61 | -------------------------------------------------------------------------------- /gemgui/gemcommon.h: -------------------------------------------------------------------------------- 1 | /* 2 | * GEMGUILib 3 | * 4 | * Copyright (C) 2020 emartisoft. All rights reserved. 5 | * Author: emarti, Murat Ozdemir 6 | * 7 | * This file is distributed under the GNU General Public License, version 2 8 | * or at your option any later version. See . 9 | * 10 | */ 11 | 12 | #ifndef GEMCOMMON_H 13 | #define GEMCOMMON_H 14 | 15 | // color palette 16 | #define LIGHT nana::color(138, 138, 138) 17 | #define WHITE nana::color(255, 255, 255) 18 | #define BLACK nana::color(0, 0, 0) 19 | #define HIGHLIGHT nana::color(186, 186, 186) 20 | // font 21 | #define FONT "/usr/share/gem/AtariST8x16SystemFont.ttf" 22 | // button image 23 | #define GEMBUTTON "/usr/share/gem/gembuttons.bmp" 24 | // active bar 25 | #define GEMACTIVE "/usr/share/gem/gemactive.bmp" 26 | 27 | #endif // GEMCOMMON_H 28 | -------------------------------------------------------------------------------- /gemgui/gemdialog.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * GEMGUILib 3 | * 4 | * Copyright (C) 2020 emartisoft. All rights reserved. 5 | * Author: emarti, Murat Ozdemir 6 | * 7 | * This file is distributed under the GNU General Public License, version 2 8 | * or at your option any later version. See . 9 | * 10 | */ 11 | 12 | #include "gemdialog.h" 13 | 14 | GEMDialog::GEMDialog(GEMForm& owner) : form(owner, {300, 200}, appear::optional()), f{12, FONT} 15 | { 16 | bgcolor(HIGHLIGHT); 17 | typeface(f); 18 | OnPaint(); 19 | result=0; 20 | ownersize=owner.size(); 21 | events().resized([this]() {GEMDialog::OnResized(); }); 22 | } 23 | 24 | void GEMDialog::OnPaint() 25 | { 26 | drawing dw(*this); 27 | dw.clear(); 28 | dw.draw([&](paint::graphics& g) 29 | { 30 | int w = (int)g.size().width; 31 | int h = (int)g.size().height; 32 | 33 | g.rectangle(rectangle( 1, 1, (unsigned int)w-2, (unsigned int)h-2 ), false, WHITE); 34 | g.rectangle(rectangle( 2, 2, (unsigned int)w-4, (unsigned int)h-4 ), false, WHITE); 35 | g.rectangle(rectangle{ 3, 3, (unsigned int)w-6, (unsigned int)h-6 }, false, BLACK); 36 | g.rectangle(rectangle{ 4, 4, (unsigned int)w-8, (unsigned int)h-8 }, false, BLACK); 37 | g.line({1,h-1}, {w,h-1}, LIGHT); 38 | g.line({2,h-2}, {w,h-2}, LIGHT); 39 | g.line({3,h-3}, {w,h-3}, LIGHT); 40 | g.line({w-1,1}, {w-1,h}, LIGHT); 41 | g.line({w-2,2}, {w-2,h}, LIGHT); 42 | g.line({w-3,3}, {w-3,h}, LIGHT); 43 | 44 | }); 45 | dw.update(); 46 | 47 | } 48 | 49 | void GEMDialog::OnResized() 50 | { 51 | move((ownersize.width-size().width)/2, (ownersize.height-size().height)/2); 52 | } 53 | 54 | 55 | -------------------------------------------------------------------------------- /gemgui/gemdialog.h: -------------------------------------------------------------------------------- 1 | /* 2 | * GEMGUILib 3 | * 4 | * Copyright (C) 2020 emartisoft. All rights reserved. 5 | * Author: emarti, Murat Ozdemir 6 | * 7 | * This file is distributed under the GNU General Public License, version 2 8 | * or at your option any later version. See . 9 | * 10 | */ 11 | 12 | #ifndef GEMDIALOG_H 13 | #define GEMDIALOG_H 14 | 15 | #include "gemcommon.h" 16 | #include 17 | #include "gemform.h" 18 | #include 19 | 20 | using namespace nana; 21 | 22 | class GEMDialog : public form 23 | { 24 | public: 25 | GEMDialog(GEMForm&); 26 | void setFont(paint::font &ft){ f = ft; } 27 | int result; 28 | private: 29 | paint::font f; 30 | nana::size ownersize; 31 | void OnPaint(); 32 | void OnResized(); 33 | }; 34 | #endif // GEMDIALOG_H 35 | -------------------------------------------------------------------------------- /gemgui/gemform.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * GEMGUILib 3 | * 4 | * Copyright (C) 2020 emartisoft. All rights reserved. 5 | * Author: emarti, Murat Ozdemir 6 | * 7 | * This file is distributed under the GNU General Public License, version 2 8 | * or at your option any later version. See . 9 | * 10 | */ 11 | 12 | #include "gemform.h" 13 | 14 | GEMForm::GEMForm() : form(API::make_center(640, 480), appear::optional() ), 15 | f{ 12, FONT} 16 | { 17 | bgcolor(BLACK); 18 | typeface(f); 19 | 20 | w = this->size().width; 21 | h = this->size().height; 22 | 23 | if (!img.open(GEMACTIVE)) 24 | throw std::runtime_error("File not found [gemactive.bmp]"); 25 | 26 | // dragBar 27 | dragBar.create(*this, rectangle(BUTTON_EDGE + 2, 1, w - 2*BUTTON_EDGE - 6 ,20)); 28 | dragBar.bgcolor(WHITE); 29 | dragBar.typeface(f); 30 | dragBar.text_align(align::center, align_v::center); 31 | dragBar.events().mouse_enter([&](const arg_mouse& mp) {GEMForm::OnMouseEnter(mp); }); 32 | dragBar.events().mouse_leave([&](const arg_mouse& mp) {GEMForm::OnMouseLeave(mp); }); 33 | 34 | // sizingGadget 35 | sizingGadget.create(*this, rectangle(w - BUTTON_EDGE - 2, h - BUTTON_EDGE - 2, BUTTON_EDGE, BUTTON_EDGE)); 36 | sizingGadget.set_bground(getBground(6)); 37 | sizingGadget.enable_focus_color(false); 38 | sizingGadget.cursor(cursor::size_bottom_right); 39 | sizingGadget.edge_effects(false); 40 | 41 | sizingGadget.events().mouse_move([&](const arg_mouse& mp) {GEMForm::sizingGadgetOnMouseMove(mp); }); 42 | sizingGadget.events().mouse_enter([&](const arg_mouse& mp) {GEMForm::OnMouseEnter(mp); }); 43 | sizingGadget.events().mouse_leave([&](const arg_mouse& mp) {GEMForm::OnMouseLeave(mp); }); 44 | 45 | // closeGadget 46 | closeGadget.create(*this, rectangle(1, 1, BUTTON_EDGE, BUTTON_EDGE)); 47 | closeGadget.set_bground(getBground(0)); 48 | closeGadget.enable_focus_color(false); 49 | closeGadget.edge_effects(false); 50 | 51 | closeGadget.events().click([this]() {GEMForm::closeGadgetOnClicked(); }); 52 | closeGadget.events().mouse_enter([&](const arg_mouse& mp) {GEMForm::OnMouseEnter(mp); }); 53 | closeGadget.events().mouse_leave([&](const arg_mouse& mp) {GEMForm::OnMouseLeave(mp); }); 54 | 55 | // zoomGadget 56 | zoomGadget.create(*this, rectangle(w - BUTTON_EDGE - 2, 1, BUTTON_EDGE, BUTTON_EDGE)); 57 | zoomGadget.set_bground(getBground(1)); 58 | zoomGadget.enable_focus_color(false); 59 | zoomGadget.edge_effects(false); 60 | 61 | zoomGadget.events().click([this]() {GEMForm::zoomGadgetOnClicked(); }); 62 | zoomGadget.events().mouse_enter([&](const arg_mouse& mp) {GEMForm::OnMouseEnter(mp); }); 63 | zoomGadget.events().mouse_leave([&](const arg_mouse& mp) {GEMForm::OnMouseLeave(mp); }); 64 | 65 | // upGadget 66 | upGadget.create(*this, rectangle(w - BUTTON_EDGE - 2, 43, BUTTON_EDGE, BUTTON_EDGE)); 67 | upGadget.set_bground(getBground(2)); 68 | upGadget.enable_focus_color(false); 69 | upGadget.edge_effects(false); 70 | 71 | upGadget.events().click([this]() {GEMForm::upGadgetOnClicked(); }); 72 | upGadget.events().mouse_enter([&](const arg_mouse& mp) {GEMForm::OnMouseEnter(mp); }); 73 | upGadget.events().mouse_leave([&](const arg_mouse& mp) {GEMForm::OnMouseLeave(mp); }); 74 | 75 | // downGadget 76 | downGadget.create(*this, rectangle(w-BUTTON_EDGE-2, h - 2*BUTTON_EDGE - 3, BUTTON_EDGE, BUTTON_EDGE)); 77 | downGadget.set_bground(getBground(3)); 78 | downGadget.enable_focus_color(false); 79 | downGadget.edge_effects(false); 80 | 81 | downGadget.events().click([this]() {GEMForm::downGadgetOnClicked(); }); 82 | downGadget.events().mouse_enter([&](const arg_mouse& mp) {GEMForm::OnMouseEnter(mp); }); 83 | downGadget.events().mouse_leave([&](const arg_mouse& mp) {GEMForm::OnMouseLeave(mp); }); 84 | 85 | // leftGadget 86 | leftGadget.create(*this, rectangle(1, h-2-BUTTON_EDGE, BUTTON_EDGE, BUTTON_EDGE)); 87 | leftGadget.set_bground(getBground(5)); 88 | leftGadget.enable_focus_color(false); 89 | leftGadget.edge_effects(false); 90 | 91 | leftGadget.events().click([this]() {GEMForm::leftGadgetOnClicked(); }); 92 | leftGadget.events().mouse_enter([&](const arg_mouse& mp) {GEMForm::OnMouseEnter(mp); }); 93 | leftGadget.events().mouse_leave([&](const arg_mouse& mp) {GEMForm::OnMouseLeave(mp); }); 94 | 95 | // rightGadget 96 | rightGadget.create(*this, rectangle(w - 2*BUTTON_EDGE - 3, h-2-BUTTON_EDGE, BUTTON_EDGE, BUTTON_EDGE)); 97 | rightGadget.set_bground(getBground(4)); 98 | rightGadget.enable_focus_color(false); 99 | rightGadget.edge_effects(false); 100 | 101 | rightGadget.events().click([this]() {GEMForm::rightGadgetOnClicked(); }); 102 | rightGadget.events().mouse_enter([&](const arg_mouse& mp) {GEMForm::OnMouseEnter(mp); }); 103 | rightGadget.events().mouse_leave([&](const arg_mouse& mp) {GEMForm::OnMouseLeave(mp); }); 104 | 105 | // form events 106 | events().resized([this]() {GEMForm::OnResized(); }); 107 | events().mouse_enter([&](const arg_mouse& mp) {GEMForm::OnMouseEnter(mp); }); 108 | events().mouse_leave([&](const arg_mouse& mp) {GEMForm::OnMouseLeave(mp); }); 109 | 110 | // paint 111 | OnPaint(); 112 | active=true; 113 | is_zoomed=false; 114 | } 115 | 116 | void GEMForm::setTitle(string title) 117 | { 118 | dragBar.caption(title); 119 | drawing dw(dragBar); 120 | dw.clear(); 121 | dw.draw([&](paint::graphics& g) 122 | { 123 | w = g.size().width; 124 | h = g.size().height; 125 | 126 | if (active) 127 | { 128 | for(int unsigned i=0;i<((unsigned int)(w/img.size().width) + 1);i++) img.paste(g, {static_cast (1+img.size().width*i),2}); 129 | nana::size captionSize = g.bidi_extent_size(dragBar.caption()); 130 | g.rectangle(rectangle{ {static_cast ((w - captionSize.width)/2), 2}, captionSize }, true, WHITE); 131 | g.string({static_cast ((w - captionSize.width)/2), static_cast ((h - captionSize.height)/2)}, dragBar.caption(), BLACK); 132 | } 133 | }); 134 | dw.update(); 135 | } 136 | 137 | void GEMForm::setActive() 138 | { 139 | active=true; 140 | setTitle(dragBar.caption()); 141 | } 142 | 143 | void GEMForm::setPreventResize() 144 | { 145 | sizingGadget.enabled(false); 146 | } 147 | 148 | void GEMForm::setPreventZoom() 149 | { 150 | zoomGadget.enabled(false); 151 | } 152 | 153 | void GEMForm::OnResized() 154 | { 155 | w = this->size().width; 156 | h = this->size().height; 157 | sizingGadget.move(rectangle( w - BUTTON_EDGE - 2, h - BUTTON_EDGE - 2, BUTTON_EDGE, BUTTON_EDGE)); 158 | zoomGadget.move(rectangle(w - BUTTON_EDGE - 2, 1, BUTTON_EDGE, BUTTON_EDGE)); 159 | upGadget.move(rectangle(w - BUTTON_EDGE - 2, 43, BUTTON_EDGE, BUTTON_EDGE)); 160 | downGadget.move(rectangle(w - BUTTON_EDGE - 2, h - 2*BUTTON_EDGE - 3, BUTTON_EDGE, BUTTON_EDGE)); 161 | rightGadget.move(rectangle(w - 2*BUTTON_EDGE - 3, h-2-BUTTON_EDGE, BUTTON_EDGE, BUTTON_EDGE)); 162 | leftGadget.move(rectangle(1, h-2-BUTTON_EDGE, BUTTON_EDGE, BUTTON_EDGE)); 163 | dragBar.size(nana::size(w - 2*BUTTON_EDGE - 6, 20)); 164 | OnPaint(); 165 | } 166 | 167 | void GEMForm::OnMouseEnter(const arg_mouse& e) 168 | { 169 | active=true; 170 | setTitle(dragBar.caption()); 171 | } 172 | 173 | void GEMForm::OnMouseLeave(const arg_mouse& e) 174 | { 175 | active=false; 176 | setTitle(dragBar.caption()); 177 | } 178 | 179 | void GEMForm::OnPaint() 180 | { 181 | drawing dw(*this); 182 | dw.clear(); 183 | dw.draw([&](paint::graphics& g) 184 | { 185 | w = g.size().width; 186 | h = g.size().height; 187 | 188 | // under dragBar 189 | g.line(point(BUTTON_EDGE+2, 21), point(w-BUTTON_EDGE-5, 21), LIGHT); 190 | // top info rect 191 | g.rectangle(rectangle{ 1, 24, w-4, 17 }, true, WHITE); 192 | // client rect 193 | g.rectangle(rectangle{ 1, 42, w-BUTTON_EDGE-4, h- 3*BUTTON_EDGE - 1 }, true, WHITE); 194 | // right scroll bar 195 | g.rectangle(rectangle{static_cast (w-BUTTON_EDGE-2), BUTTON_EDGE*3, BUTTON_EDGE-1, h- 5*BUTTON_EDGE - 5}, true, WHITE); 196 | g.line(point(w-4, BUTTON_EDGE*3+1), point(w-4, h- 2*BUTTON_EDGE - 6), LIGHT); 197 | g.line(point(w-4, h- 2*BUTTON_EDGE - 6), point(w-1-BUTTON_EDGE, h- 2*BUTTON_EDGE - 6), LIGHT); 198 | // bottom scroll bar 199 | g.rectangle(rectangle{ BUTTON_EDGE+2, static_cast (h-2-BUTTON_EDGE), w-3*BUTTON_EDGE-7, BUTTON_EDGE-1}, true, WHITE); 200 | g.line(point(BUTTON_EDGE+3, h-4), point(w-2*BUTTON_EDGE-6, h-4), LIGHT); 201 | g.line(point(w-2*BUTTON_EDGE-6, h- BUTTON_EDGE - 1), point(w-2*BUTTON_EDGE-6, h-4), LIGHT); 202 | }); 203 | dw.update(); 204 | } 205 | 206 | void GEMForm::sizingGadgetOnMouseMove(const arg_mouse& e) 207 | { 208 | if (e.is_left_button()) 209 | { 210 | int nw, nh; 211 | nw = this->size().width + e.pos.x - sizingGadget.size().width; 212 | nh = this->size().height + e.pos.y - sizingGadget.size().height; 213 | if((nw>320)&&(nh>240)) 214 | this->size(nana::size(nw,nh)); 215 | } 216 | } 217 | 218 | void GEMForm::closeGadgetOnClicked() 219 | { 220 | close(); 221 | } 222 | 223 | void GEMForm::zoomGadgetOnClicked() 224 | { 225 | is_zoomed = !is_zoomed; 226 | 227 | if(is_zoomed) 228 | { 229 | pre_w = this->size().width; 230 | pre_h = this->size().height; 231 | pre_x = this->pos().x; 232 | pre_y = this->pos().y; 233 | auto workarea = screen().get_primary().workarea(); 234 | move(0, 0); 235 | outline_size({workarea.width, workarea.height}); 236 | } 237 | else 238 | { 239 | move(pre_x, pre_y); 240 | outline_size({pre_w, pre_h}); 241 | } 242 | } 243 | 244 | void GEMForm::rightGadgetOnClicked() 245 | { 246 | // not implemented 247 | } 248 | 249 | void GEMForm::leftGadgetOnClicked() 250 | { 251 | // not implemented 252 | } 253 | 254 | void GEMForm::upGadgetOnClicked() 255 | { 256 | // not implemented 257 | } 258 | 259 | void GEMForm::downGadgetOnClicked() 260 | { 261 | // not implemented 262 | } 263 | 264 | // GEMBUTTON image 265 | // index:value 266 | // ----------- 267 | // 0:close 268 | // 1:maximize 269 | // 2:uparrow 270 | // 3:downarrow 271 | // 4:rightarrow 272 | // 5:leftarrow 273 | // 6:sizing 274 | 275 | element::bground GEMForm::getBground(unsigned char index) 276 | { 277 | element::bground bg; 278 | bg.states({element_state::normal, element_state::pressed}); 279 | bg.join(element_state::normal, element_state::hovered); 280 | bg.join(element_state::normal, element_state::focus_normal); 281 | bg.join(element_state::normal, element_state::focus_hovered); 282 | bg.join(element_state::normal, element_state::disabled); 283 | bg.image(paint::image(GEMBUTTON), true, rectangle{index*BUTTON_EDGE,0,BUTTON_EDGE,44}); 284 | return bg; 285 | } 286 | 287 | -------------------------------------------------------------------------------- /gemgui/gemform.h: -------------------------------------------------------------------------------- 1 | /* 2 | * GEMGUILib 3 | * 4 | * Copyright (C) 2020 emartisoft. All rights reserved. 5 | * Author: emarti, Murat Ozdemir 6 | * 7 | * This file is distributed under the GNU General Public License, version 2 8 | * or at your option any later version. See . 9 | * 10 | */ 11 | 12 | #ifndef GEMFORM_H 13 | #define GEMFORM_H 14 | 15 | #include "gemcommon.h" 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | 23 | #define BUTTON_EDGE 22 24 | 25 | using namespace nana; 26 | using namespace std; 27 | 28 | class GEMForm : public form 29 | { 30 | public: 31 | GEMForm(); 32 | void setTitle(string title); 33 | bool active; 34 | void setActive(); 35 | void setPreventResize(); 36 | void setPreventZoom(); 37 | label dragBar; 38 | void setFont(paint::font &ft){ f = ft; } 39 | private: 40 | paint::font f; 41 | paint::image img; 42 | 43 | button sizingGadget; 44 | button closeGadget; 45 | button zoomGadget; 46 | button leftGadget; 47 | button rightGadget; 48 | button upGadget; 49 | button downGadget; 50 | 51 | void OnResized(); 52 | void OnPaint(); 53 | void OnMouseEnter(const arg_mouse& e); 54 | void OnMouseLeave(const arg_mouse& e); 55 | void sizingGadgetOnMouseMove(const arg_mouse& e); 56 | 57 | void closeGadgetOnClicked(); 58 | void zoomGadgetOnClicked(); 59 | void rightGadgetOnClicked(); 60 | void leftGadgetOnClicked(); 61 | void upGadgetOnClicked(); 62 | void downGadgetOnClicked(); 63 | 64 | element::bground getBground(unsigned char index); 65 | bool is_zoomed; 66 | unsigned int w, h, pre_w, pre_h, pre_x, pre_y; 67 | }; 68 | #endif // GEMFORM_H 69 | -------------------------------------------------------------------------------- /gemgui/gemlabel.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * GEMGUILib 3 | * 4 | * Copyright (C) 2020 emartisoft. All rights reserved. 5 | * Author: emarti, Murat Ozdemir 6 | * 7 | * This file is distributed under the GNU General Public License, version 2 8 | * or at your option any later version. See . 9 | * 10 | */ 11 | 12 | #include "gemlabel.h" 13 | 14 | GEMLabel::GEMLabel(GEMForm& af, const rectangle& r) : label(af, r, true), f {12, FONT} 15 | { 16 | Set(); 17 | } 18 | 19 | GEMLabel::GEMLabel(GEMDialog& af, const rectangle& r) : label(af, r, true), f {12, FONT} 20 | { 21 | Set(); 22 | } 23 | 24 | void GEMLabel::Set() 25 | { 26 | bgcolor(WHITE); 27 | typeface(f); 28 | transparent(true); 29 | } 30 | -------------------------------------------------------------------------------- /gemgui/gemlabel.h: -------------------------------------------------------------------------------- 1 | /* 2 | * GEMGUILib 3 | * 4 | * Copyright (C) 2020 emartisoft. All rights reserved. 5 | * Author: emarti, Murat Ozdemir 6 | * 7 | * This file is distributed under the GNU General Public License, version 2 8 | * or at your option any later version. See . 9 | * 10 | */ 11 | 12 | #ifndef GEMLABEL_H 13 | #define GEMLABEL_H 14 | 15 | #include "gemcommon.h" 16 | #include "gemform.h" 17 | #include "gemdialog.h" 18 | #include 19 | #include 20 | 21 | using namespace nana; 22 | 23 | class GEMLabel : public label 24 | { 25 | public: 26 | GEMLabel(GEMForm&, const rectangle&); 27 | GEMLabel(GEMDialog&, const rectangle&); 28 | void setFont(paint::font &ft){ f = ft; } 29 | private: 30 | paint::font f; 31 | void Set(); 32 | 33 | }; 34 | #endif // GEMLABEL_H 35 | -------------------------------------------------------------------------------- /gemgui/gemmenu.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * GEMGUILib 3 | * 4 | * Copyright (C) 2020 emartisoft. All rights reserved. 5 | * Author: emarti, Murat Ozdemir 6 | * 7 | * This file is distributed under the GNU General Public License, version 2 8 | * or at your option any later version. See . 9 | * 10 | */ 11 | 12 | #include "gemmenu.h" 13 | 14 | using namespace nana; 15 | 16 | GEMMenu::GEMMenu() 17 | { 18 | renderer(GEMMenuRenderer{renderer()}); 19 | } 20 | 21 | void GEMMenu::setFont(paint::font &ft) 22 | { 23 | renderer(GEMMenuRenderer{renderer(), ft}); 24 | } 25 | 26 | void GEMMenu::append_separator() 27 | { 28 | append("---"); 29 | } 30 | -------------------------------------------------------------------------------- /gemgui/gemmenu.h: -------------------------------------------------------------------------------- 1 | /* 2 | * GEMGUILib 3 | * 4 | * Copyright (C) 2020 emartisoft. All rights reserved. 5 | * Author: emarti, Murat Ozdemir 6 | * 7 | * This file is distributed under the GNU General Public License, version 2 8 | * or at your option any later version. See . 9 | * 10 | */ 11 | 12 | #ifndef GEMMENU_H 13 | #define GEMMENU_H 14 | 15 | #include "gemcommon.h" 16 | #include 17 | #include 18 | 19 | using namespace nana; 20 | using namespace std; 21 | 22 | class GEMMenuRenderer : public menu::renderer_interface 23 | { 24 | public: 25 | GEMMenuRenderer(const pat::cloneable& rd, paint::font font = {12, FONT}) 26 | { 27 | font_ = font; 28 | reuse_= rd; 29 | } 30 | 31 | private: 32 | void background(graph_reference graph, window wd) override 33 | { 34 | if(graph.typeface() != font_) graph.typeface(font_); 35 | graph.rectangle(true, WHITE); 36 | graph.rectangle(false, BLACK); 37 | } 38 | 39 | void item(graph_reference graph, const rectangle& r, const attr & atr) override 40 | { 41 | if ((state::active == atr.item_state)&(atr.enabled)) 42 | { 43 | graph.rectangle(r, true, BLACK); 44 | } 45 | rect_ = r; 46 | } 47 | 48 | void item_image(graph_reference graph, const point& pos, unsigned image_px, const paint::image& img) override 49 | { 50 | reuse_->item_image(graph, pos, image_px, img); 51 | } 52 | 53 | void item_text(graph_reference graph, const point& pos, const string& text, unsigned pixels, const attr& atr) override 54 | { 55 | nana::size splitCharSize = graph.bidi_extent_size("-"); 56 | string splitCharArray = ""; 57 | splitCharArray.append( static_cast (rect_.width/splitCharSize.width) , '-'); 58 | 59 | point p0{4,pos.y+static_cast (splitCharSize.height/2)}; 60 | point p1{4+static_cast (splitCharSize.width/2),static_cast (splitCharSize.height)+pos.y}; 61 | point p2{4+static_cast (splitCharSize.width),pos.y}; 62 | 63 | if (state::active == atr.item_state) 64 | { 65 | if(text=="---") 66 | { 67 | graph.rectangle(rect_, true, WHITE); 68 | graph.string({4,pos.y}, splitCharArray, LIGHT); 69 | } 70 | else 71 | { 72 | if(atr.checked) 73 | { 74 | graph.line(p0, p1, WHITE); 75 | graph.line({p0.x+1, p0.y+1}, {p1.x+1, p1.y+1}, WHITE); 76 | 77 | graph.line(p1, p2, WHITE); 78 | graph.line({p1.x+1, p1.y+1}, {p2.x+1, p2.y+1}, WHITE); 79 | } 80 | graph.string({static_cast (splitCharSize.width*3),pos.y}, text, atr.enabled ? WHITE : HIGHLIGHT); 81 | } 82 | } 83 | else 84 | { 85 | if(text=="---") 86 | { 87 | graph.string({4,pos.y}, splitCharArray, LIGHT); 88 | } 89 | else 90 | { 91 | if(atr.checked) 92 | { 93 | graph.line(p0, p1, BLACK); 94 | graph.line({p0.x+1, p0.y+1}, {p1.x+1, p1.y+1}, BLACK); 95 | 96 | graph.line(p1, p2, BLACK); 97 | graph.line({p1.x+1, p1.y+1}, {p2.x+1, p2.y+1}, BLACK); 98 | } 99 | graph.string({static_cast (splitCharSize.width*3),pos.y}, text, atr.enabled ? BLACK : HIGHLIGHT); 100 | } 101 | } 102 | } 103 | 104 | void sub_arrow(graph_reference graph, const point& pos, unsigned pixels, const attr & atr) override 105 | { 106 | reuse_->sub_arrow(graph, pos, pixels, atr); 107 | } 108 | private: 109 | pat::cloneable reuse_; 110 | paint::font font_; 111 | rectangle rect_; 112 | }; 113 | 114 | class GEMMenu : public menu 115 | { 116 | public: 117 | GEMMenu(); 118 | void setFont(paint::font &ft); 119 | void append_separator(); 120 | 121 | 122 | }; 123 | #endif // GEMMENU_H 124 | -------------------------------------------------------------------------------- /gemgui/gemmenubaritem.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * GEMGUILib 3 | * 4 | * Copyright (C) 2020 emartisoft. All rights reserved. 5 | * Author: emarti, Murat Ozdemir 6 | * 7 | * This file is distributed under the GNU General Public License, version 2 8 | * or at your option any later version. See . 9 | * 10 | */ 11 | 12 | #include "gemmenubaritem.h" 13 | 14 | GEMMenubarItem::GEMMenubarItem(GEMForm& af, const rectangle& r) : label(af, r, true), f{12, FONT} 15 | { 16 | bgcolor(WHITE); 17 | fgcolor(BLACK); 18 | typeface(f); 19 | entered = false; 20 | events().mouse_enter([&](const arg_mouse& mp) {GEMMenubarItem::OnMouseEnter(mp); }); 21 | events().mouse_leave([&](const arg_mouse& mp) {GEMMenubarItem::OnMouseLeave(mp); }); 22 | OnPaint(); 23 | } 24 | 25 | void GEMMenubarItem::OnPaint() 26 | { 27 | drawing dw(*this); 28 | dw.clear(); 29 | dw.draw([this](paint::graphics& g) 30 | { 31 | unsigned int w = g.size().width; 32 | unsigned int h = g.size().height; 33 | nana::size captionSize = g.bidi_extent_size(caption()); 34 | 35 | g.rectangle(rectangle{ 0, 0, w, h }, true, (entered)? BLACK : WHITE); 36 | g.string({ static_cast ((w - captionSize.width)/2), static_cast ((h - captionSize.height)/2)}, caption(), (entered)? WHITE : BLACK); 37 | 38 | }); 39 | dw.update(); 40 | } 41 | 42 | void GEMMenubarItem::OnMouseEnter(const arg_mouse& e) 43 | { 44 | entered = true; 45 | OnPaint(); 46 | } 47 | 48 | void GEMMenubarItem::OnMouseLeave(const arg_mouse& e) 49 | { 50 | entered = false; 51 | OnPaint(); 52 | } 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /gemgui/gemmenubaritem.h: -------------------------------------------------------------------------------- 1 | /* 2 | * GEMGUILib 3 | * 4 | * Copyright (C) 2020 emartisoft. All rights reserved. 5 | * Author: emarti, Murat Ozdemir 6 | * 7 | * This file is distributed under the GNU General Public License, version 2 8 | * or at your option any later version. See . 9 | * 10 | */ 11 | 12 | #ifndef GEMMENUBARITEM_H 13 | #define GEMMENUBARITEM_H 14 | 15 | #include "gemcommon.h" 16 | #include "gemform.h" 17 | #include 18 | #include 19 | 20 | using namespace nana; 21 | 22 | class GEMMenubarItem : public label 23 | { 24 | public: 25 | GEMMenubarItem(GEMForm&, const rectangle&); 26 | void setFont(paint::font &ft){ f = ft; } 27 | private: 28 | paint::font f; 29 | bool entered; 30 | void OnPaint(); 31 | void OnMouseEnter(const arg_mouse& e); 32 | void OnMouseLeave(const arg_mouse& e); 33 | 34 | }; 35 | #endif // GEMMENUBARITEM_H 36 | -------------------------------------------------------------------------------- /gemgui/gemtextbox.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * GEMGUILib 3 | * 4 | * Copyright (C) 2020 emartisoft. All rights reserved. 5 | * Author: emarti, Murat Ozdemir 6 | * 7 | * This file is distributed under the GNU General Public License, version 2 8 | * or at your option any later version. See . 9 | * 10 | */ 11 | 12 | #include "gemtextbox.h" 13 | 14 | GEMTextbox::GEMTextbox(GEMForm& af, const rectangle& r) : panel(af, r), f {12, FONT} 15 | { 16 | Set(); 17 | } 18 | 19 | GEMTextbox::GEMTextbox(GEMDialog& af, const rectangle& r) : panel(af, r), f {12, FONT} 20 | { 21 | Set(); 22 | } 23 | 24 | void GEMTextbox::Set() 25 | { 26 | tbox.create(*this, rectangle(2,2,size().width-4, size().height-4), true); 27 | tbox.typeface(f); 28 | tbox.multi_lines(false); 29 | tbox.borderless(true); 30 | tbox.bgcolor(WHITE); 31 | OnPaint(); 32 | } 33 | 34 | std::string GEMTextbox::caption() 35 | { 36 | return tbox.caption(); 37 | } 38 | 39 | void GEMTextbox::caption(string text) 40 | { 41 | tbox.caption(text); 42 | } 43 | 44 | void GEMTextbox::tip_string(string text) 45 | { 46 | tbox.tip_string(text); 47 | } 48 | 49 | void GEMTextbox::OnPaint() 50 | { 51 | drawing dw(*this); 52 | dw.clear(); 53 | dw.draw([this](paint::graphics& g) 54 | { 55 | unsigned int w = g.size().width; 56 | unsigned int h = g.size().height; 57 | 58 | g.rectangle(rectangle{ 0, 0, w, h }, true, BLACK); 59 | g.rectangle(rectangle{ 2, 2, w-4, h-4 }, true, WHITE); 60 | 61 | }); 62 | dw.update(); 63 | } 64 | 65 | -------------------------------------------------------------------------------- /gemgui/gemtextbox.h: -------------------------------------------------------------------------------- 1 | /* 2 | * GEMGUILib 3 | * 4 | * Copyright (C) 2020 emartisoft. All rights reserved. 5 | * Author: emarti, Murat Ozdemir 6 | * 7 | * This file is distributed under the GNU General Public License, version 2 8 | * or at your option any later version. See . 9 | * 10 | */ 11 | 12 | #ifndef GEMTEXTBOX_H 13 | #define GEMTEXTBOX_H 14 | 15 | #include "gemcommon.h" 16 | #include "gemform.h" 17 | #include "gemdialog.h" 18 | #include 19 | #include 20 | #include 21 | 22 | using namespace nana; 23 | using namespace std; 24 | 25 | class GEMTextbox : public panel 26 | { 27 | public: 28 | GEMTextbox(GEMForm&, const rectangle&); 29 | GEMTextbox(GEMDialog&, const rectangle&); 30 | void setFont(paint::font &ft){ f = ft; } 31 | string caption(); 32 | void caption(string); 33 | void tip_string(string); 34 | private: 35 | paint::font f; 36 | textbox tbox; 37 | void OnPaint(); 38 | void Set(); 39 | 40 | }; 41 | #endif // GEMTEXTBOX_H 42 | -------------------------------------------------------------------------------- /gemguilib.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emartisoft/GEMGUILib/833445aa4ae293bdf4462bc2daca080201b42a18/gemguilib.png -------------------------------------------------------------------------------- /main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * GEMGUILib Sample 3 | * 4 | * Copyright (C) 2020 emartisoft. All rights reserved. 5 | * Author: emarti, Murat Ozdemir 6 | * 7 | * This file is distributed under the GNU General Public License, version 2 8 | * or at your option any later version. See . 9 | * 10 | */ 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | 23 | using namespace nana; 24 | using namespace std; 25 | 26 | void on_menuitem_click(menu::item_proxy& itemproxy) 27 | { 28 | switch (itemproxy.index()) 29 | { 30 | case 7: API::exit_all(); break; 31 | } 32 | } 33 | 34 | int main() 35 | { 36 | //window 37 | GEMForm af; 38 | af.size(nana::size(640,480)); 39 | af.setTitle("GEM Skin Demo - Nana C++ GUI Project"); 40 | af.events().unload([&](const nana::arg_unload& ei) 41 | { 42 | GEMDialog m(af); 43 | m.size(nana::size(240,140)); 44 | GEMButton bNo(m, "No", rectangle(140, 105, 90, 25)); 45 | bNo.events().click([&m](){ m.close(); }); 46 | 47 | GEMButton bYes(m, "Yes", rectangle(40, 105, 90, 25)); 48 | bYes.events().click([&m](){ m.result=1; m.close(); }); 49 | 50 | GEMLabel lInfo(m, rectangle(20,20,200,50)); 51 | lInfo.caption("Are you sure you wanna exit?"); 52 | m.show(); 53 | m.modality(); 54 | ei.cancel = {m.result==0}; 55 | } 56 | ); 57 | //af.setPreventResize(); 58 | //af.setPreventZoom(); 59 | 60 | //label 61 | GEMLabel lmerhaba(af, rectangle(20, 80, 350, 24)); 62 | lmerhaba.caption("Hi, I am ATARI GUI App."); 63 | lmerhaba.events().mouse_enter([&]() {af.setActive();}); 64 | 65 | //button 66 | GEMButton bAbout(af, "About", rectangle(20, 110, 90, 24)); 67 | bAbout.events().mouse_enter([&]() {af.setActive();}); 68 | bAbout.events().click([&](){ 69 | 70 | //dialog 71 | GEMDialog d(af); 72 | d.size(nana::size(240,240)); 73 | GEMButton bClose(d, "Close", rectangle(140, 205, 90, 25)); 74 | bClose.events().click([&d](){ d.close(); }); 75 | GEMLabel lInfo(d, rectangle(20,20,200,24)); 76 | lInfo.caption("This is about dialog"); 77 | d.show(); 78 | d.modality(); 79 | }); 80 | 81 | //combox 82 | GEMCombox child ( af, nana::rectangle ( 20, 150, 180, 24) ); 83 | child.push_back("Item 1"); 84 | child.push_back("Item 2"); 85 | child.push_back("Item 3"); 86 | child.push_back("Item 4"); 87 | child.push_back("Item 5"); 88 | child.option(2); 89 | child.events().mouse_enter([&]() {af.setActive();}); 90 | 91 | //menu 92 | GEMMenu mobj; 93 | //nana::paint::font mf{14, FONT}; 94 | //mobj.setFont(mf); 95 | mobj.item_pixels(16); 96 | 97 | mobj.append ( "Open", &on_menuitem_click); 98 | mobj.append_separator(); 99 | mobj.append ( "Save", &on_menuitem_click); 100 | mobj.append ( "Save as", &on_menuitem_click); 101 | mobj.append_separator(); 102 | mobj.append ( "Atari GEM Style", &on_menuitem_click); 103 | mobj.append_separator(); 104 | mobj.append ( "Exit", &on_menuitem_click); 105 | 106 | mobj.checked(5, true); 107 | mobj.enabled(3, false); 108 | 109 | //menubaritem 110 | GEMMenubarItem mb(af, rectangle(2, 42, 70, 24)); 111 | mb.caption("Desk"); 112 | mb.events().mouse_down( menu_popuper( mobj, mb, nana::point(0, 24), mouse::left_button )); 113 | mb.events().mouse_enter([&]() {af.setActive();}); 114 | 115 | GEMMenubarItem mb2(af, rectangle(72, 42, 70, 24)); 116 | mb2.caption("File"); 117 | mb2.events().mouse_down( menu_popuper( mobj, mb2, nana::point(0, 24), mouse::left_button )); 118 | mb2.events().mouse_enter([&]() {af.setActive();}); 119 | 120 | //textbox 121 | GEMTextbox tb(af, rectangle(20, 200, 180, 24)); 122 | //tb.caption("test"); 123 | tb.tip_string("enter type your name"); 124 | tb.events().mouse_enter([&]() {af.setActive();}); 125 | 126 | //show 127 | af.show(); 128 | 129 | //drag 130 | dragger dg; 131 | dg.trigger(af.dragBar); 132 | dg.target(af); 133 | 134 | exec(); 135 | } 136 | 137 | -------------------------------------------------------------------------------- /makefile: -------------------------------------------------------------------------------- 1 | #------------------------------------------------------ 2 | # gcc compiler, nana lib c++ 3 | CXX=g++ 4 | CXXFLAGS=-I. -I./gemgui/ -I/include/ -std=c++11 5 | EXTFLAGS=-s -Os -ffunction-sections -fdata-sections 6 | LIBS=-lnana -lX11 -lpthread -lrt -ldl -lfreetype\ 7 | -lXft -lfontconfig -lasound -lpng -lstdc++fs\ 8 | -lgemgui 9 | 10 | #------------------------------------------------------ 11 | # app name 12 | TARGET= gemGuiSample 13 | # headers 14 | DEPS = 15 | # objects 16 | OBJ = main.o 17 | #------------------------------------------------------ 18 | COM_COLOR = \033[0;34m 19 | OBJ_COLOR = \033[0;36m 20 | LINK_COLOR = \033[0;32m 21 | WARN_COLOR = \033[0;33m 22 | NO_COLOR = \033[m 23 | COM_STRING = "Compiling" 24 | #------------------------------------------------------ 25 | 26 | %.o: %.cpp $(DEPS) 27 | @printf "%b" "$(COM_COLOR)$(COM_STRING) $(OBJ_COLOR)$(<)$(NO_COLOR)\n"; 28 | $(CXX) -c -o $@ $< $(CXXFLAGS) 29 | 30 | $(TARGET): $(OBJ) 31 | @printf "%b" "$(LINK_COLOR)Linking...$(NO_COLOR)\n"; 32 | $(CXX) -o $@ $^ $(CXXFLAGS) $(EXTFLAGS) $(LIBS) 33 | #upx --best $(TARGET) 34 | 35 | #------------------------------------------------------ 36 | .PHONY: clean install uninstall 37 | 38 | clean: 39 | @printf "%b" "$(WARN_COLOR)Cleaning...$(NO_COLOR)\n"; 40 | rm -f $(TARGET) *.o 41 | 42 | install: $(TARGET) 43 | @printf "%b" "$(WARN_COLOR)Installing...$(NO_COLOR)\n"; 44 | cp $(TARGET) /usr/bin 45 | 46 | uninstall: $(TARGET) 47 | @printf "%b" "$(WARN_COLOR)Uninstalling...$(NO_COLOR)\n"; 48 | rm -f /usr/bin/$(TARGET) 49 | 50 | #------------------------------------------------------ 51 | --------------------------------------------------------------------------------