├── examples ├── ReBars │ ├── resource.h │ └── ReBars.rc ├── resource.h ├── Vaca.ico ├── Images │ ├── resource.h │ ├── Vaca.bmp │ └── Images.rc ├── Trees │ ├── resource.h │ ├── images.bmp │ └── Trees.rc ├── Bixes │ ├── Bixes.bmp │ ├── Bixes.rc │ └── resource.h ├── Sudoku │ ├── Sudoku.ico │ ├── resource.h │ └── Sudoku.rc ├── ToolBars │ ├── resource.h │ ├── ToolBar.bmp │ └── ToolBars.rc ├── EyeDropper │ ├── resource.h │ ├── EyeDropper.cur │ └── EyeDropper.rc ├── Commands │ ├── Commands.bmp │ ├── Commands.rc │ └── resource.h ├── TextEditor │ ├── VacaDoc.ico │ ├── TextEditor.rc │ └── resource.h ├── DialogResource │ ├── resource.h │ ├── DialogResource.cpp │ └── DialogResource.rc ├── MenuResource │ ├── resource.h │ └── MenuResource.rc ├── Example.rc ├── SplitBars │ ├── resource.h │ └── SplitBars.rc ├── Example.manifest ├── Minimal │ └── Minimal.cpp ├── Console.h ├── Undo │ └── Document.h ├── Hashing │ └── md5.h ├── Edits │ └── Edits.cpp ├── Spinners │ └── Spinners.cpp └── ComboBoxes │ └── ComboBoxes.cpp ├── .gitignore ├── doc ├── images │ ├── Button.png │ ├── MESS.png │ ├── Vaca.png │ ├── CheckBox.png │ ├── ToolBar.png │ ├── ToolSet.png │ ├── RadioButton.png │ ├── AnchorLayout.png │ ├── DeleteInEvent.png │ └── CreateDestroyWindows.png ├── Doxyfile_chm ├── pages │ ├── tn014.h │ ├── tn003.h │ ├── page_debug.h │ ├── tn013.h │ ├── constants.h │ ├── tn010.h │ ├── tn.h │ ├── functions.h │ ├── platforms.h │ ├── index.h │ ├── tn009.h │ ├── tn008.h │ ├── tn006.h │ ├── tn005.h │ ├── license.h │ ├── tn012.h │ ├── hacking.h │ ├── tn007.h │ ├── tn004.h │ ├── tn011.h │ └── devel.h ├── Doxyfile_pri ├── Makefile ├── footer.html └── header.html ├── scintilla └── SciLexer.dll ├── tests ├── test_handle.cpp ├── test_thread.cpp ├── test_sharedptr.cpp ├── test_tab.cpp ├── test_menu.cpp ├── test_point.cpp ├── test_size.cpp ├── CMakeLists.txt ├── test_widget.cpp └── test_image.cpp ├── vaca ├── Constraint.cpp ├── DataGrid.h ├── vaca.cpp ├── CheckBox.cpp ├── ToggleButton.cpp ├── std │ └── MainArgs.h ├── MainArgs.h ├── MenuItemEvent.cpp ├── CommandEvent.cpp ├── Keys.cpp ├── ResizeEvent.cpp ├── WidgetList.h ├── Property.cpp ├── BoxConstraint.cpp ├── CloseEvent.cpp ├── Property.h ├── MenuItemEvent.h ├── TimePoint.h ├── ResizeEvent.h ├── PaintEvent.cpp ├── CommandEvent.h ├── CommonDialog.cpp ├── FocusEvent.cpp ├── CancelableEvent.cpp ├── Clipboard.h ├── TreeViewEvent.cpp ├── ConsumableEvent.cpp ├── LayoutEvent.h ├── DropFilesEvent.h ├── FocusEvent.h ├── ResourceException.h ├── SetCursorEvent.h ├── win32 │ ├── MainArgs.h │ ├── MutexImpl.h │ ├── WidgetsMovementImpl.h │ ├── BrushImpl.h │ └── win32.cpp ├── PaintEvent.h ├── ResourceId.cpp ├── ConsumableEvent.h ├── SetCursorEvent.cpp ├── Event.h ├── CommonDialog.h ├── Event.cpp ├── unix │ └── MutexImpl.h ├── FindFiles.h ├── ColorDialog.h ├── DropFilesEvent.cpp ├── ScrollEvent.cpp ├── ResourceId.h ├── CloseEvent.h ├── Separator.h ├── Separator.cpp ├── FontDialog.h ├── TreeViewEvent.h ├── Referenceable.h ├── CustomLabel.cpp ├── CancelableEvent.h ├── StatusBar.h ├── ToggleButton.h ├── CheckBox.h ├── Brush.cpp ├── PreferredSizeEvent.h ├── Anchor.h ├── ClientLayout.h ├── Exception.h ├── LayoutEvent.cpp ├── Layout.cpp ├── KeyEvent.cpp ├── ScrollInfo.h ├── ScrollInfo.cpp ├── BoxConstraint.h ├── Button.cpp ├── Constraint.h ├── ButtonBase.h ├── KeyEvent.h ├── Mutex.h ├── NonCopyable.h ├── StatusBar.cpp ├── AnchorLayout.h ├── Button.h ├── Component.h ├── win32.h ├── GroupBox.h ├── Brush.h ├── FindFiles.cpp ├── BoxLayout.h ├── ColorDialog.cpp ├── TimePoint.cpp ├── ListColumn.h ├── BasicDockArea.h ├── CustomLabel.h ├── ListItem.h ├── Point.h ├── Size.h ├── ClientLayout.cpp ├── Message.h ├── MsgBox.h ├── Command.cpp ├── Debug.cpp ├── System.h ├── Debug.h ├── FontDialog.cpp ├── ProgressBar.h ├── Layout.h ├── Color.h ├── FindTextDialog.h ├── Icon.h ├── PreferredSizeEvent.cpp ├── Timer.h ├── Component.cpp ├── ScopedLock.h ├── ScrollableWidget.h ├── Slider.h ├── ConditionVariable.h ├── Mutex.cpp ├── ScrollEvent.h ├── Enum.h └── ImageList.h ├── cmake └── FindVaca.cmake ├── README.md ├── BUGS.txt ├── LICENSE.txt ├── AUTHORS.txt └── TODO.txt /examples/ReBars/resource.h: -------------------------------------------------------------------------------- 1 | #include "../resource.h" 2 | -------------------------------------------------------------------------------- /examples/resource.h: -------------------------------------------------------------------------------- 1 | #define APP_MANIFEST 1 2 | #define IDI_VACA 1 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .vscode 2 | browse.VC.db 3 | doc/*.chm 4 | doc/*.tmp 5 | doc/html/ 6 | -------------------------------------------------------------------------------- /examples/Vaca.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dacap/vaca/HEAD/examples/Vaca.ico -------------------------------------------------------------------------------- /doc/images/Button.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dacap/vaca/HEAD/doc/images/Button.png -------------------------------------------------------------------------------- /doc/images/MESS.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dacap/vaca/HEAD/doc/images/MESS.png -------------------------------------------------------------------------------- /doc/images/Vaca.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dacap/vaca/HEAD/doc/images/Vaca.png -------------------------------------------------------------------------------- /doc/images/CheckBox.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dacap/vaca/HEAD/doc/images/CheckBox.png -------------------------------------------------------------------------------- /doc/images/ToolBar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dacap/vaca/HEAD/doc/images/ToolBar.png -------------------------------------------------------------------------------- /doc/images/ToolSet.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dacap/vaca/HEAD/doc/images/ToolSet.png -------------------------------------------------------------------------------- /examples/Images/resource.h: -------------------------------------------------------------------------------- 1 | #include "../resource.h" 2 | 3 | #define IDB_VACA 1000 4 | -------------------------------------------------------------------------------- /examples/Trees/resource.h: -------------------------------------------------------------------------------- 1 | #include "../resource.h" 2 | 3 | #define IDB_IMAGES 1000 4 | -------------------------------------------------------------------------------- /scintilla/SciLexer.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dacap/vaca/HEAD/scintilla/SciLexer.dll -------------------------------------------------------------------------------- /doc/images/RadioButton.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dacap/vaca/HEAD/doc/images/RadioButton.png -------------------------------------------------------------------------------- /examples/Bixes/Bixes.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dacap/vaca/HEAD/examples/Bixes/Bixes.bmp -------------------------------------------------------------------------------- /examples/Images/Vaca.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dacap/vaca/HEAD/examples/Images/Vaca.bmp -------------------------------------------------------------------------------- /examples/Sudoku/Sudoku.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dacap/vaca/HEAD/examples/Sudoku/Sudoku.ico -------------------------------------------------------------------------------- /examples/Sudoku/resource.h: -------------------------------------------------------------------------------- 1 | #include "../resource.h" 2 | 3 | #define IDI_SUDOKU 1 4 | 5 | -------------------------------------------------------------------------------- /examples/ToolBars/resource.h: -------------------------------------------------------------------------------- 1 | #include "../resource.h" 2 | 3 | #define IDB_TOOLBAR 1000 4 | -------------------------------------------------------------------------------- /examples/Trees/images.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dacap/vaca/HEAD/examples/Trees/images.bmp -------------------------------------------------------------------------------- /doc/images/AnchorLayout.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dacap/vaca/HEAD/doc/images/AnchorLayout.png -------------------------------------------------------------------------------- /doc/images/DeleteInEvent.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dacap/vaca/HEAD/doc/images/DeleteInEvent.png -------------------------------------------------------------------------------- /examples/EyeDropper/resource.h: -------------------------------------------------------------------------------- 1 | #include "../resource.h" 2 | 3 | #define IDC_EYEDROPPER 1000 4 | -------------------------------------------------------------------------------- /examples/Commands/Commands.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dacap/vaca/HEAD/examples/Commands/Commands.bmp -------------------------------------------------------------------------------- /examples/TextEditor/VacaDoc.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dacap/vaca/HEAD/examples/TextEditor/VacaDoc.ico -------------------------------------------------------------------------------- /examples/ToolBars/ToolBar.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dacap/vaca/HEAD/examples/ToolBars/ToolBar.bmp -------------------------------------------------------------------------------- /doc/images/CreateDestroyWindows.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dacap/vaca/HEAD/doc/images/CreateDestroyWindows.png -------------------------------------------------------------------------------- /examples/EyeDropper/EyeDropper.cur: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dacap/vaca/HEAD/examples/EyeDropper/EyeDropper.cur -------------------------------------------------------------------------------- /doc/Doxyfile_chm: -------------------------------------------------------------------------------- 1 | # Doxyfile 1.7.4 2 | 3 | @INCLUDE = Doxyfile 4 | 5 | GENERATE_HTMLHELP = YES 6 | CHM_FILE = ..\Vaca.chm 7 | -------------------------------------------------------------------------------- /doc/pages/tn014.h: -------------------------------------------------------------------------------- 1 | namespace vaca { 2 | 3 | /** 4 | 5 | @page page_tn_014 TN014: Temporary objects 6 | 7 | @todo 8 | 9 | */ 10 | 11 | } 12 | -------------------------------------------------------------------------------- /examples/DialogResource/resource.h: -------------------------------------------------------------------------------- 1 | #include "../resource.h" 2 | 3 | #define IDD_MAIN 1000 4 | #define IDC_MAIN_ABOUT_BUTTON 1001 5 | #define IDD_ABOUT 1002 6 | -------------------------------------------------------------------------------- /examples/MenuResource/resource.h: -------------------------------------------------------------------------------- 1 | #include "../resource.h" 2 | 3 | #define IDM_MENUBAR 1000 4 | #define IDM_ITEM1 1001 5 | #define IDM_ITEM2 1002 6 | #define IDM_ITEM3 1003 7 | #define IDM_ITEM4 1004 8 | -------------------------------------------------------------------------------- /examples/Example.rc: -------------------------------------------------------------------------------- 1 | #include "resource.h" 2 | #include "windows.h" 3 | 4 | #ifdef EXAMPLE_RC_WITH_MANIFEST 5 | APP_MANIFEST RT_MANIFEST "Example.manifest" 6 | #endif 7 | 8 | IDI_VACA ICON "Vaca.ico" 9 | -------------------------------------------------------------------------------- /doc/Doxyfile_pri: -------------------------------------------------------------------------------- 1 | # Doxyfile 1.7.4 2 | 3 | @INCLUDE = Doxyfile 4 | 5 | EXTRACT_PRIVATE = YES 6 | INTERNAL_DOCS = YES 7 | GENERATE_HTMLHELP = YES 8 | CHM_FILE = ..\Vaca-private.chm 9 | -------------------------------------------------------------------------------- /examples/ReBars/ReBars.rc: -------------------------------------------------------------------------------- 1 | #include "resource.h" 2 | #include "windows.h" 3 | 4 | #ifdef EXAMPLE_RC_WITH_MANIFEST 5 | APP_MANIFEST RT_MANIFEST "Example.manifest" 6 | #endif 7 | 8 | IDI_VACA ICON "../Vaca.ico" 9 | -------------------------------------------------------------------------------- /examples/Sudoku/Sudoku.rc: -------------------------------------------------------------------------------- 1 | #include "resource.h" 2 | #include "windows.h" 3 | 4 | #ifdef EXAMPLE_RC_WITH_MANIFEST 5 | APP_MANIFEST RT_MANIFEST "Example.manifest" 6 | #endif 7 | 8 | IDI_SUDOKU ICON "Sudoku.ico" 9 | -------------------------------------------------------------------------------- /examples/Images/Images.rc: -------------------------------------------------------------------------------- 1 | #include "resource.h" 2 | #include "windows.h" 3 | 4 | #ifdef EXAMPLE_RC_WITH_MANIFEST 5 | APP_MANIFEST RT_MANIFEST "Example.manifest" 6 | #endif 7 | 8 | IDI_VACA ICON "../Vaca.ico" 9 | IDB_VACA BITMAP "Vaca.bmp" 10 | -------------------------------------------------------------------------------- /examples/Bixes/Bixes.rc: -------------------------------------------------------------------------------- 1 | #include "resource.h" 2 | #include "windows.h" 3 | 4 | #ifdef EXAMPLE_RC_WITH_MANIFEST 5 | APP_MANIFEST RT_MANIFEST "Example.manifest" 6 | #endif 7 | 8 | IDI_VACA ICON "../Vaca.ico" 9 | IDB_TOOLBAR BITMAP "Bixes.bmp" 10 | -------------------------------------------------------------------------------- /examples/Trees/Trees.rc: -------------------------------------------------------------------------------- 1 | #include "resource.h" 2 | #include "windows.h" 3 | 4 | #ifdef EXAMPLE_RC_WITH_MANIFEST 5 | APP_MANIFEST RT_MANIFEST "Example.manifest" 6 | #endif 7 | 8 | IDI_VACA ICON "../Vaca.ico" 9 | IDB_IMAGES BITMAP "images.bmp" 10 | -------------------------------------------------------------------------------- /examples/Commands/Commands.rc: -------------------------------------------------------------------------------- 1 | #include "resource.h" 2 | #include "windows.h" 3 | 4 | #ifdef EXAMPLE_RC_WITH_MANIFEST 5 | APP_MANIFEST RT_MANIFEST "Example.manifest" 6 | #endif 7 | 8 | IDI_VACA ICON "../Vaca.ico" 9 | IDB_TOOLBAR BITMAP "Commands.bmp" 10 | -------------------------------------------------------------------------------- /examples/ToolBars/ToolBars.rc: -------------------------------------------------------------------------------- 1 | #include "resource.h" 2 | #include "windows.h" 3 | 4 | #ifdef EXAMPLE_RC_WITH_MANIFEST 5 | APP_MANIFEST RT_MANIFEST "Example.manifest" 6 | #endif 7 | 8 | IDI_VACA ICON "../Vaca.ico" 9 | IDB_TOOLBAR BITMAP "ToolBar.bmp" 10 | -------------------------------------------------------------------------------- /examples/TextEditor/TextEditor.rc: -------------------------------------------------------------------------------- 1 | #include "resource.h" 2 | #include "windows.h" 3 | 4 | #ifdef EXAMPLE_RC_WITH_MANIFEST 5 | APP_MANIFEST RT_MANIFEST "Example.manifest" 6 | #endif 7 | 8 | IDI_VACA ICON "../Vaca.ico" 9 | IDI_VACADOC ICON "VacaDoc.ico" 10 | -------------------------------------------------------------------------------- /examples/EyeDropper/EyeDropper.rc: -------------------------------------------------------------------------------- 1 | #include "resource.h" 2 | #include "windows.h" 3 | 4 | #ifdef EXAMPLE_RC_WITH_MANIFEST 5 | APP_MANIFEST RT_MANIFEST "Example.manifest" 6 | #endif 7 | 8 | IDI_VACA ICON "../Vaca.ico" 9 | IDC_EYEDROPPER CURSOR "EyeDropper.cur" 10 | -------------------------------------------------------------------------------- /examples/Bixes/resource.h: -------------------------------------------------------------------------------- 1 | #include "../resource.h" 2 | 3 | #define IDB_TOOLBAR 1000 4 | 5 | #define IDM_ADD_COLUMN 1001 6 | #define IDM_ADD_ROW 1002 7 | #define IDM_ADD_MATRIX 1003 8 | #define IDM_ADD_WIDGET 1004 9 | #define IDM_REMOVE 1005 10 | #define IDM_PROPERTIES 1006 11 | -------------------------------------------------------------------------------- /doc/pages/tn003.h: -------------------------------------------------------------------------------- 1 | namespace vaca { 2 | 3 | /** 4 | 5 | @page page_tn_003 TN003: Using dynamic_cast 6 | 7 | @details Vaca uses standard C++ Run-Time Type Information. It is 8 | supported by default with MinGW. But when you compile with MSVC 9 | you have to use the @msdn{/GR} flag (Enable Run-Time Type Information). 10 | 11 | */ 12 | 13 | } 14 | -------------------------------------------------------------------------------- /doc/pages/page_debug.h: -------------------------------------------------------------------------------- 1 | namespace vaca { 2 | 3 | /** 4 | 5 | @page page_debug Debugging 6 | 7 | @li @ref page_debug_log 8 | 9 | 10 | @section page_debug_log Log file 11 | 12 | A log file called "vaca.log" is created when you use the debug version 13 | of Vaca library. It contains all the output create with 14 | the @ref VACA_TRACE macro. 15 | 16 | */ 17 | 18 | } 19 | -------------------------------------------------------------------------------- /tests/test_handle.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "vaca/vaca.h" 4 | 5 | using namespace vaca; 6 | 7 | TEST(Handle, DoubleWrapperFail) 8 | { 9 | Application app; 10 | 11 | // First wrapper 12 | Frame a(L"Title"); 13 | 14 | // Second wrapper 15 | EXPECT_THROW(Widget b(a.getHandle()), 16 | CreateWidgetException); 17 | } 18 | -------------------------------------------------------------------------------- /examples/Commands/resource.h: -------------------------------------------------------------------------------- 1 | #include "../resource.h" 2 | 3 | #define IDB_TOOLBAR 1000 4 | 5 | #define ID_FILE_NEW 1001 6 | #define ID_FILE_OPEN 1002 7 | #define ID_FILE_SAVE 1003 8 | #define ID_FILE_CLOSE 1004 9 | #define ID_FILE_EXIT 1005 10 | #define ID_EDIT_CUT 1006 11 | #define ID_EDIT_COPY 1007 12 | #define ID_EDIT_PASTE 1008 13 | #define ID_VIEW_TOOLBAR 1009 14 | -------------------------------------------------------------------------------- /examples/SplitBars/resource.h: -------------------------------------------------------------------------------- 1 | #include "../resource.h" 2 | 3 | #define IDR_MAINMENU 101 4 | #define ID_FILE_EXIT 40001 5 | #define ID_HELP_ABOUT 40002 6 | #define ID_EDIT_DELETE 40003 7 | #define ID_VIEW_S_SP1 40004 8 | #define ID_VIEW_S_SP2 40005 9 | #define ID_FULLDRAG 40006 10 | -------------------------------------------------------------------------------- /vaca/Constraint.cpp: -------------------------------------------------------------------------------- 1 | // Vaca - Visual Application Components Abstraction 2 | // Copyright (c) 2005-2010 David Capello 3 | // 4 | // This file is distributed under the terms of the MIT license, 5 | // please read LICENSE.txt for more information. 6 | 7 | #include "vaca/Constraint.h" 8 | 9 | using namespace vaca; 10 | 11 | Constraint::Constraint() 12 | { 13 | } 14 | 15 | Constraint::~Constraint() 16 | { 17 | } 18 | -------------------------------------------------------------------------------- /vaca/DataGrid.h: -------------------------------------------------------------------------------- 1 | // Vaca - Visual Application Components Abstraction 2 | // Copyright (c) 2005-2010 David Capello 3 | // 4 | // This file is distributed under the terms of the MIT license, 5 | // please read LICENSE.txt for more information. 6 | 7 | #ifndef VACA_DATAGRID_H 8 | #define VACA_DATAGRID_H 9 | 10 | #include "vaca/base.h" 11 | 12 | namespace vaca { 13 | 14 | // TODO 15 | 16 | } // namespace vaca 17 | 18 | #endif // VACA_DATAGRID_H 19 | -------------------------------------------------------------------------------- /vaca/vaca.cpp: -------------------------------------------------------------------------------- 1 | // Vaca - Visual Application Components Abstraction 2 | // Copyright (c) 2005-2010 David Capello 3 | // 4 | // This file is distributed under the terms of the MIT license, 5 | // please read LICENSE.txt for more information. 6 | 7 | #include "vaca/MainArgs.h" 8 | #include "vaca/Application.h" 9 | 10 | using namespace vaca; 11 | 12 | #if defined(VACA_WINDOWS) 13 | #include "win32/MainArgs.h" 14 | #else 15 | #include "std/MainArgs.h" 16 | #endif 17 | -------------------------------------------------------------------------------- /doc/pages/tn013.h: -------------------------------------------------------------------------------- 1 | namespace vaca { 2 | 3 | /** 4 | 5 | @page page_tn_013 TN013: All MenuItems must have their own ID 6 | 7 | Every @ref MenuItem that you create must have 8 | its own @ref CommandId. See the @c Undo example 9 | to see how to create a @ref Menu where its items change 10 | over time. 11 | 12 | This also is true if you don't use commands. For example, if you 13 | override the @ref MenuItem#onAction to control the actions, the items 14 | need a unique ID anyway. 15 | 16 | */ 17 | 18 | } 19 | -------------------------------------------------------------------------------- /vaca/CheckBox.cpp: -------------------------------------------------------------------------------- 1 | // Vaca - Visual Application Components Abstraction 2 | // Copyright (c) 2005-2010 David Capello 3 | // 4 | // This file is distributed under the terms of the MIT license, 5 | // please read LICENSE.txt for more information. 6 | 7 | #include "vaca/CheckBox.h" 8 | 9 | using namespace vaca; 10 | 11 | CheckBox::CheckBox(const String& text, Widget* parent, Style style) 12 | : ButtonBase(parent, style) 13 | { 14 | setText(text); 15 | } 16 | 17 | CheckBox::~CheckBox() 18 | { 19 | } 20 | -------------------------------------------------------------------------------- /vaca/ToggleButton.cpp: -------------------------------------------------------------------------------- 1 | // Vaca - Visual Application Components Abstraction 2 | // Copyright (c) 2005-2010 David Capello 3 | // 4 | // This file is distributed under the terms of the MIT license, 5 | // please read LICENSE.txt for more information. 6 | 7 | #include "vaca/ToggleButton.h" 8 | 9 | using namespace vaca; 10 | 11 | ToggleButton::ToggleButton(const String& text, Widget* parent, Style style) 12 | : ButtonBase(parent, style) 13 | { 14 | setText(text); 15 | } 16 | 17 | ToggleButton::~ToggleButton() 18 | { 19 | } 20 | -------------------------------------------------------------------------------- /examples/MenuResource/MenuResource.rc: -------------------------------------------------------------------------------- 1 | #include "resource.h" 2 | #include "windows.h" 3 | 4 | #ifdef EXAMPLE_RC_WITH_MANIFEST 5 | APP_MANIFEST RT_MANIFEST "Example.manifest" 6 | #endif 7 | 8 | IDI_VACA ICON "../Vaca.ico" 9 | 10 | IDM_MENUBAR MENU 11 | { 12 | MENUITEM "&Item1", IDM_ITEM1 13 | POPUP "&Popup1" { 14 | MENUITEM "&Item2", IDM_ITEM2 15 | POPUP "&Popup2" { 16 | MENUITEM "&Item3", IDM_ITEM3, CHECKED 17 | MENUITEM SEPARATOR 18 | MENUITEM "&Item4", IDM_ITEM4 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /doc/pages/constants.h: -------------------------------------------------------------------------------- 1 | namespace vaca { 2 | 3 | /** 4 | 5 | @page page_constants Constants 6 | 7 | @beginOverviewTable 8 | @titleRow{Alignment} 9 | @itemRow{Orientation} 10 | @itemRow{TextAlign} 11 | @itemRow{VerticalAlign} 12 | @titleRow{Positions} 13 | @itemRow{CardinalDirection} 14 | @itemRow{Side} 15 | @itemRow{Sides} 16 | @itemRow{WidgetHit} 17 | @titleRow{Keyboard} 18 | @itemRow{Keys} 19 | @titleRow{Graphics} 20 | @itemRow{PenEndCap} 21 | @itemRow{PenJoin} 22 | @itemRow{PenStyle} 23 | @endTable 24 | 25 | */ 26 | 27 | } 28 | -------------------------------------------------------------------------------- /vaca/std/MainArgs.h: -------------------------------------------------------------------------------- 1 | // Vaca - Visual Application Components Abstraction 2 | // Copyright (c) 2005-2010 David Capello 3 | // 4 | // This file is distributed under the terms of the MIT license, 5 | // please read LICENSE.txt for more information. 6 | 7 | #include "vaca/String.h" 8 | 9 | void vaca::details::MainArgs::setArgs(int argc, char* argv[]) 10 | { 11 | std::vector args; 12 | args.reserve(argc); 13 | for (int i=0; i(argv[i])); 15 | 16 | Application::setArgs(args); 17 | } 18 | -------------------------------------------------------------------------------- /vaca/MainArgs.h: -------------------------------------------------------------------------------- 1 | // Vaca - Visual Application Components Abstraction 2 | // Copyright (c) 2005-2010 David Capello 3 | // 4 | // This file is distributed under the terms of the MIT license, 5 | // please read LICENSE.txt for more information. 6 | 7 | #ifndef VACA_MAINARGS_H 8 | #define VACA_MAINARGS_H 9 | 10 | #include "vaca/base.h" 11 | 12 | namespace vaca { 13 | 14 | namespace details { 15 | class VACA_DLL MainArgs 16 | { 17 | public: 18 | static void setArgs(int, char**); 19 | }; 20 | } 21 | 22 | } // namespace vaca 23 | 24 | #endif // VACA_MAINARGS_H 25 | -------------------------------------------------------------------------------- /doc/Makefile: -------------------------------------------------------------------------------- 1 | DOXYGEN = "$(PROGRAMFILES)/doxygen/bin/doxygen.exe" 2 | 3 | default: all 4 | 5 | all: html chm private 6 | 7 | _norule: 8 | 9 | html: _norule 10 | -mkdir html 11 | $(DOXYGEN) Doxyfile 12 | 13 | chm: 14 | -mkdir html 15 | $(DOXYGEN) Doxyfile_chm 16 | 17 | private: 18 | -mkdir html 19 | $(DOXYGEN) Doxyfile_pri 20 | 21 | web: 22 | -mkdir html 23 | $(DOXYGEN) Doxyfile_web 24 | 25 | gen1: 26 | $(DOXYGEN) -g new_Doxyfile 27 | 28 | gen2: 29 | $(DOXYGEN) -w html new_header.html new_footer.html new_style.css new_Doxyfile 30 | 31 | clean: 32 | -$(RM) -r html 33 | -------------------------------------------------------------------------------- /vaca/MenuItemEvent.cpp: -------------------------------------------------------------------------------- 1 | // Vaca - Visual Application Components Abstraction 2 | // Copyright (c) 2005-2010 David Capello 3 | // 4 | // This file is distributed under the terms of the MIT license, 5 | // please read LICENSE.txt for more information. 6 | 7 | #include "vaca/MenuItemEvent.h" 8 | #include "vaca/Menu.h" 9 | 10 | using namespace vaca; 11 | 12 | MenuItemEvent::MenuItemEvent(MenuItem* source) 13 | : Event(source) 14 | { 15 | } 16 | 17 | MenuItemEvent::~MenuItemEvent() 18 | { 19 | } 20 | 21 | MenuItem* MenuItemEvent::getMenuItem() 22 | { 23 | return dynamic_cast(getSource()); 24 | } 25 | -------------------------------------------------------------------------------- /cmake/FindVaca.cmake: -------------------------------------------------------------------------------- 1 | # - Find the Vaca library 2 | # 3 | # This module defines 4 | # VACA_INCLUDE_DIR, where to find Vaca/Vaca.h, etc. 5 | # VACA_LIBRARY, the library to link against to use Vaca. 6 | # VACA_FOUND, If false, do not try to use Vaca. 7 | 8 | FIND_PATH(VACA_INCLUDE_DIR Vaca/Vaca.h) 9 | 10 | FIND_LIBRARY(VACA_LIBRARY NAMES Vaca) 11 | 12 | IF(VACA_INCLUDE_DIR AND VACA_LIBRARY) 13 | SET(VACA_FOUND TRUE) 14 | ENDIF(VACA_INCLUDE_DIR AND VACA_LIBRARY) 15 | 16 | FIND_PACKAGE_HANDLE_STANDARD_ARGS(VACA DEFAULT_MSG VACA_LIBRARY VACA_INCLUDE_DIR) 17 | 18 | MARK_AS_ADVANCED(VACA_INCLUDE_DIR VACA_LIBRARY) 19 | -------------------------------------------------------------------------------- /vaca/CommandEvent.cpp: -------------------------------------------------------------------------------- 1 | // Vaca - Visual Application Components Abstraction 2 | // Copyright (c) 2005-2010 David Capello 3 | // 4 | // This file is distributed under the terms of the MIT license, 5 | // please read LICENSE.txt for more information. 6 | 7 | #include "vaca/CommandEvent.h" 8 | 9 | using namespace vaca; 10 | 11 | CommandEvent::CommandEvent(Component* source, CommandId commandId) 12 | : ConsumableEvent(source) 13 | , m_commandId(commandId) 14 | { 15 | } 16 | 17 | CommandEvent::~CommandEvent() 18 | { 19 | } 20 | 21 | CommandId CommandEvent::getCommandId() const 22 | { 23 | return m_commandId; 24 | } 25 | -------------------------------------------------------------------------------- /vaca/Keys.cpp: -------------------------------------------------------------------------------- 1 | // Vaca - Visual Application Components Abstraction 2 | // Copyright (c) 2005-2010 David Capello 3 | // 4 | // This file is distributed under the terms of the MIT license, 5 | // please read LICENSE.txt for more information. 6 | 7 | #include "vaca/Keys.h" 8 | 9 | using namespace vaca; 10 | 11 | Keys::Type Keys::fromMessageParams(WPARAM wParam, LPARAM lParam) 12 | { 13 | return static_cast(wParam) 14 | | (GetKeyState(VK_SHIFT ) & 0x8000 ? Keys::Shift : 0) 15 | | (GetKeyState(VK_CONTROL) & 0x8000 ? Keys::Control: 0) 16 | | (GetKeyState(VK_MENU ) & 0x8000 ? Keys::Alt : 0); 17 | } 18 | -------------------------------------------------------------------------------- /vaca/ResizeEvent.cpp: -------------------------------------------------------------------------------- 1 | // Vaca - Visual Application Components Abstraction 2 | // Copyright (c) 2005-2010 David Capello 3 | // 4 | // This file is distributed under the terms of the MIT license, 5 | // please read LICENSE.txt for more information. 6 | 7 | #include "vaca/ResizeEvent.h" 8 | 9 | using namespace vaca; 10 | 11 | ResizeEvent::ResizeEvent(Component* source, const Size& size) 12 | : Event(source) 13 | , m_size(size) 14 | { 15 | } 16 | 17 | /** 18 | Destroys the ResizeEvent. 19 | */ 20 | ResizeEvent::~ResizeEvent() 21 | { 22 | } 23 | 24 | Size ResizeEvent::getSize() const 25 | { 26 | return m_size; 27 | } 28 | -------------------------------------------------------------------------------- /vaca/WidgetList.h: -------------------------------------------------------------------------------- 1 | // Vaca - Visual Application Components Abstraction 2 | // Copyright (c) 2005-2010 David Capello 3 | // 4 | // This file is distributed under the terms of the MIT license, 5 | // please read LICENSE.txt for more information. 6 | 7 | #ifndef VACA_WIDGETLIST_H 8 | #define VACA_WIDGETLIST_H 9 | 10 | #include "vaca/base.h" 11 | 12 | #include 13 | 14 | namespace vaca { 15 | 16 | /** 17 | Collection of widgets. 18 | 19 | Used to handle the list of children of each widget. 20 | */ 21 | typedef std::vector WidgetList; 22 | 23 | } // namespace vaca 24 | 25 | #endif // VACA_WIDGETLIST_H 26 | -------------------------------------------------------------------------------- /doc/footer.html: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /vaca/Property.cpp: -------------------------------------------------------------------------------- 1 | // Vaca - Visual Application Components Abstraction 2 | // Copyright (c) 2005-2010 David Capello 3 | // 4 | // This file is distributed under the terms of the MIT license, 5 | // please read LICENSE.txt for more information. 6 | 7 | #include "vaca/Property.h" 8 | #include "vaca/Debug.h" 9 | 10 | using namespace vaca; 11 | 12 | /** 13 | Creates a new named property. 14 | */ 15 | Property::Property(const String& name) 16 | : m_name(name) 17 | { 18 | } 19 | 20 | /** 21 | Destroys the property. 22 | */ 23 | Property::~Property() 24 | { 25 | } 26 | 27 | String Property::getName() const 28 | { 29 | return m_name; 30 | } 31 | -------------------------------------------------------------------------------- /doc/pages/tn010.h: -------------------------------------------------------------------------------- 1 | namespace vaca { 2 | 3 | /** 4 | 5 | @page page_tn_010 TN010: Auto-deleted objects 6 | 7 | Vaca deletes some objects automatically that you create. This means 8 | that there are cases where you create the object using the @c new 9 | operator, but you never deletes it because Vaca does that job for you. 10 | 11 | Here is a list of some classes/methods with this behavior: 12 | 13 | - Frame#setMenuBar 14 | - Menu#add(MenuItem*) 15 | - CommandsClient#addCommand 16 | - Frame#addDockArea 17 | - MdiClient#setMdiClient 18 | 19 | Automatically handled with SmartPtr: 20 | 21 | - Widget#setLayout 22 | - Widget#setConstraint 23 | 24 | */ 25 | 26 | } 27 | -------------------------------------------------------------------------------- /vaca/BoxConstraint.cpp: -------------------------------------------------------------------------------- 1 | // Vaca - Visual Application Components Abstraction 2 | // Copyright (c) 2005-2010 David Capello 3 | // 4 | // This file is distributed under the terms of the MIT license, 5 | // please read LICENSE.txt for more information. 6 | 7 | #include "vaca/BoxConstraint.h" 8 | 9 | using namespace vaca; 10 | 11 | BoxConstraint::BoxConstraint(bool expansive) 12 | : m_expansive(expansive) 13 | { 14 | } 15 | 16 | BoxConstraint::~BoxConstraint() 17 | { 18 | } 19 | 20 | bool BoxConstraint::isExpansive() 21 | { 22 | return m_expansive; 23 | } 24 | 25 | void BoxConstraint::setExpansive(bool expansive) 26 | { 27 | m_expansive = expansive; 28 | } 29 | -------------------------------------------------------------------------------- /vaca/CloseEvent.cpp: -------------------------------------------------------------------------------- 1 | // Vaca - Visual Application Components Abstraction 2 | // Copyright (c) 2005-2010 David Capello 3 | // 4 | // This file is distributed under the terms of the MIT license, 5 | // please read LICENSE.txt for more information. 6 | 7 | #include "vaca/CloseEvent.h" 8 | #include "vaca/Frame.h" 9 | 10 | using namespace vaca; 11 | 12 | /** 13 | Creates a new CloseEvent for the specified Frame. 14 | 15 | @param source 16 | Frame that is being closed. 17 | */ 18 | CloseEvent::CloseEvent(Frame* source) 19 | : CancelableEvent(source) 20 | { 21 | } 22 | 23 | /** 24 | Destroys the CloseEvent. 25 | */ 26 | CloseEvent::~CloseEvent() 27 | { 28 | } 29 | -------------------------------------------------------------------------------- /vaca/Property.h: -------------------------------------------------------------------------------- 1 | // Vaca - Visual Application Components Abstraction 2 | // Copyright (c) 2005-2010 David Capello 3 | // 4 | // This file is distributed under the terms of the MIT license, 5 | // please read LICENSE.txt for more information. 6 | 7 | #ifndef VACA_PROPERTY_H 8 | #define VACA_PROPERTY_H 9 | 10 | #include "vaca/base.h" 11 | #include "vaca/Referenceable.h" 12 | 13 | namespace vaca { 14 | 15 | class VACA_DLL Property : public Referenceable 16 | { 17 | String m_name; 18 | 19 | public: 20 | Property(const String& name); 21 | virtual ~Property(); 22 | 23 | String getName() const; 24 | }; 25 | 26 | } // namespace vaca 27 | 28 | #endif // VACA_PROPERTY_H 29 | -------------------------------------------------------------------------------- /vaca/MenuItemEvent.h: -------------------------------------------------------------------------------- 1 | // Vaca - Visual Application Components Abstraction 2 | // Copyright (c) 2005-2010 David Capello 3 | // 4 | // This file is distributed under the terms of the MIT license, 5 | // please read LICENSE.txt for more information. 6 | 7 | #ifndef VACA_MENUITEMEVENT_H 8 | #define VACA_MENUITEMEVENT_H 9 | 10 | #include "vaca/base.h" 11 | #include "vaca/Event.h" 12 | 13 | namespace vaca { 14 | 15 | class VACA_DLL MenuItemEvent : public Event 16 | { 17 | 18 | public: 19 | 20 | MenuItemEvent(MenuItem* source); 21 | virtual ~MenuItemEvent(); 22 | 23 | MenuItem* getMenuItem(); 24 | 25 | }; 26 | 27 | } // namespace vaca 28 | 29 | #endif // VACA_MENUITEMEVENT_H 30 | -------------------------------------------------------------------------------- /examples/Example.manifest: -------------------------------------------------------------------------------- 1 | 2 | 3 | 9 | 10 | 11 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /doc/pages/tn.h: -------------------------------------------------------------------------------- 1 | namespace vaca { 2 | 3 | /** 4 | 5 | @page page_tn Technical Notes 6 | 7 | This is a list of some technical notes about how some problems where 8 | solved in Vaca, and some implications about this implementation. 9 | 10 | @li @subpage page_tn_001 11 | @li @subpage page_tn_002 12 | @li @subpage page_tn_003 13 | @li @subpage page_tn_004 14 | @li @subpage page_tn_005 15 | @li @subpage page_tn_006 16 | @li @subpage page_tn_007 17 | @li @subpage page_tn_008 18 | @li @subpage page_tn_009 19 | @li @subpage page_tn_010 20 | @li @subpage page_tn_011 21 | @li @subpage page_tn_012 22 | @li @subpage page_tn_013 23 | @li @subpage page_tn_014 24 | @li @subpage page_tn_015 25 | 26 | */ 27 | 28 | } 29 | -------------------------------------------------------------------------------- /examples/TextEditor/resource.h: -------------------------------------------------------------------------------- 1 | #include "../resource.h" 2 | 3 | #define IDI_VACADOC 1000 4 | 5 | #define ID_FILE_NEW 1001 6 | #define ID_FILE_OPEN 1002 7 | #define ID_FILE_SAVE 1003 8 | #define ID_FILE_SAVE_AS 1004 9 | #define ID_FILE_EXIT 1005 10 | #define ID_EDIT_UNDO 1006 11 | #define ID_EDIT_REDO 1007 12 | #define ID_EDIT_CUT 1008 13 | #define ID_EDIT_COPY 1009 14 | #define ID_EDIT_PASTE 1010 15 | #define ID_EDIT_CLEAR 1011 16 | #define ID_EDIT_FIND 1012 17 | #define ID_EDIT_REPLACE 1013 18 | #define ID_OPTIONS_CHANGE_FONT 1014 19 | #define ID_OPTIONS_VIEW_EOL 1015 20 | #define ID_WINDOWS_CLOSE 1016 21 | #define ID_WINDOWS_DUPLICATE 1017 22 | #define ID_WINDOWS_CASCADE 1018 23 | -------------------------------------------------------------------------------- /vaca/TimePoint.h: -------------------------------------------------------------------------------- 1 | // Vaca - Visual Application Components Abstraction 2 | // Copyright (c) 2005-2010 David Capello 3 | // 4 | // This file is distributed under the terms of the MIT license, 5 | // please read LICENSE.txt for more information. 6 | 7 | #ifndef VACA_TIMEPOINT_H 8 | #define VACA_TIMEPOINT_H 9 | 10 | #include "vaca/base.h" 11 | 12 | namespace vaca { 13 | 14 | /** 15 | Class to measure elapsed time, like a chronometer. 16 | */ 17 | class VACA_DLL TimePoint 18 | { 19 | LARGE_INTEGER m_point; 20 | LARGE_INTEGER m_freq; 21 | 22 | public: 23 | TimePoint(); 24 | ~TimePoint(); 25 | 26 | void reset(); 27 | 28 | double elapsed() const; 29 | }; 30 | 31 | } // namespace vaca 32 | 33 | #endif // VACA_TIMEPOINT_H 34 | -------------------------------------------------------------------------------- /vaca/ResizeEvent.h: -------------------------------------------------------------------------------- 1 | // Vaca - Visual Application Components Abstraction 2 | // Copyright (c) 2005-2010 David Capello 3 | // 4 | // This file is distributed under the terms of the MIT license, 5 | // please read LICENSE.txt for more information. 6 | 7 | #ifndef VACA_RESIZEEVENT_H 8 | #define VACA_RESIZEEVENT_H 9 | 10 | #include "vaca/base.h" 11 | #include "vaca/Event.h" 12 | #include "vaca/Size.h" 13 | 14 | namespace vaca { 15 | 16 | class VACA_DLL ResizeEvent : public Event 17 | { 18 | Size m_size; 19 | 20 | public: 21 | 22 | ResizeEvent(Component* source, const Size& size); 23 | virtual ~ResizeEvent(); 24 | 25 | Size getSize() const; 26 | 27 | }; 28 | 29 | } // namespace vaca 30 | 31 | #endif // VACA_RESIZEEVENT_H 32 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Vaca 2 | ## Visual Application Components Abstraction 3 | *Copyright (c) 2005-2022 David Capello* 4 | 5 | [![build](https://github.com/dacap/vaca/workflows/build/badge.svg)](https://github.com/dacap/vaca/actions?query=workflow%3Abuild) 6 | [![MIT Licensed](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE.txt) 7 | 8 | Vaca is a library to develop GUI applications with C++. It uses 9 | templates and STL, and has some special features like dockable tool 10 | bars and layout managers. 11 | 12 | This library is released under the terms of the MIT License. See 13 | [LICENSE.txt](LICENSE.txt) for more information. 14 | 15 | * [Wiki](https://github.com/dacap/vaca/wiki) 16 | * [Examples](https://github.com/dacap/vaca/wiki/Examples) 17 | -------------------------------------------------------------------------------- /vaca/PaintEvent.cpp: -------------------------------------------------------------------------------- 1 | // Vaca - Visual Application Components Abstraction 2 | // Copyright (c) 2005-2010 David Capello 3 | // 4 | // This file is distributed under the terms of the MIT license, 5 | // please read LICENSE.txt for more information. 6 | 7 | #include "vaca/PaintEvent.h" 8 | #include "vaca/Widget.h" 9 | 10 | using namespace vaca; 11 | 12 | PaintEvent::PaintEvent(Widget* source, Graphics& graphics) 13 | : Event(source) 14 | , m_graphics(graphics) 15 | , m_painted(false) 16 | { 17 | } 18 | 19 | PaintEvent::~PaintEvent() 20 | { 21 | } 22 | 23 | Graphics& PaintEvent::getGraphics() 24 | { 25 | m_painted = true; 26 | return m_graphics; 27 | } 28 | 29 | bool PaintEvent::isPainted() const 30 | { 31 | return m_painted; 32 | } 33 | -------------------------------------------------------------------------------- /vaca/CommandEvent.h: -------------------------------------------------------------------------------- 1 | // Vaca - Visual Application Components Abstraction 2 | // Copyright (c) 2005-2010 David Capello 3 | // 4 | // This file is distributed under the terms of the MIT license, 5 | // please read LICENSE.txt for more information. 6 | 7 | #ifndef VACA_COMMANDEVENT_H 8 | #define VACA_COMMANDEVENT_H 9 | 10 | #include "vaca/base.h" 11 | #include "vaca/ConsumableEvent.h" 12 | 13 | namespace vaca { 14 | 15 | class VACA_DLL CommandEvent : public ConsumableEvent 16 | { 17 | CommandId m_commandId; 18 | 19 | public: 20 | 21 | CommandEvent(Component* source, CommandId commandId); 22 | virtual ~CommandEvent(); 23 | 24 | CommandId getCommandId() const; 25 | 26 | }; 27 | 28 | } // namespace vaca 29 | 30 | #endif // VACA_COMMANDEVENT_H 31 | -------------------------------------------------------------------------------- /vaca/CommonDialog.cpp: -------------------------------------------------------------------------------- 1 | // Vaca - Visual Application Components Abstraction 2 | // Copyright (c) 2005-2010 David Capello 3 | // 4 | // This file is distributed under the terms of the MIT license, 5 | // please read LICENSE.txt for more information. 6 | 7 | #include "vaca/CommonDialog.h" 8 | #include "vaca/Widget.h" 9 | #include "vaca/Debug.h" 10 | #include "vaca/Application.h" 11 | 12 | using namespace vaca; 13 | 14 | CommonDialog::CommonDialog(Widget* parent) 15 | { 16 | m_parent = parent; 17 | } 18 | 19 | CommonDialog::~CommonDialog() 20 | { 21 | } 22 | 23 | Widget* CommonDialog::getParent() 24 | { 25 | return m_parent; 26 | } 27 | 28 | HWND CommonDialog::getParentHandle() 29 | { 30 | return m_parent != NULL ? m_parent->getHandle(): NULL; 31 | } 32 | -------------------------------------------------------------------------------- /vaca/FocusEvent.cpp: -------------------------------------------------------------------------------- 1 | // Vaca - Visual Application Components Abstraction 2 | // Copyright (c) 2005-2010 David Capello 3 | // 4 | // This file is distributed under the terms of the MIT license, 5 | // please read LICENSE.txt for more information. 6 | 7 | #include "vaca/FocusEvent.h" 8 | #include "vaca/Widget.h" 9 | 10 | using namespace vaca; 11 | 12 | FocusEvent::FocusEvent(Widget* source, Widget* oldFocus, Widget* newFocus) 13 | : Event(source) 14 | , m_oldFocus(oldFocus) 15 | , m_newFocus(newFocus) 16 | { 17 | } 18 | 19 | FocusEvent::~FocusEvent() 20 | { 21 | } 22 | 23 | Widget* FocusEvent::getOldFocus() const 24 | { 25 | return m_oldFocus; 26 | } 27 | 28 | Widget* FocusEvent::getNewFocus() const 29 | { 30 | return m_newFocus; 31 | } 32 | 33 | -------------------------------------------------------------------------------- /vaca/CancelableEvent.cpp: -------------------------------------------------------------------------------- 1 | // Vaca - Visual Application Components Abstraction 2 | // Copyright (c) 2005-2010 David Capello 3 | // 4 | // This file is distributed under the terms of the MIT license, 5 | // please read LICENSE.txt for more information. 6 | 7 | #include "vaca/CancelableEvent.h" 8 | 9 | using namespace vaca; 10 | 11 | CancelableEvent::CancelableEvent(Component* source) 12 | : Event(source) 13 | , m_canceled(false) 14 | { 15 | } 16 | 17 | CancelableEvent::~CancelableEvent() 18 | { 19 | } 20 | 21 | /** 22 | Cancels the event. 23 | */ 24 | void CancelableEvent::cancel() 25 | { 26 | m_canceled = true; 27 | } 28 | 29 | /** 30 | The event was canceled. 31 | */ 32 | bool CancelableEvent::isCanceled() const 33 | { 34 | return m_canceled; 35 | } 36 | -------------------------------------------------------------------------------- /vaca/Clipboard.h: -------------------------------------------------------------------------------- 1 | // Vaca - Visual Application Components Abstraction 2 | // Copyright (c) 2005-2010 David Capello 3 | // 4 | // This file is distributed under the terms of the MIT license, 5 | // please read LICENSE.txt for more information. 6 | 7 | #ifndef VACA_CLIPBOARD_H 8 | #define VACA_CLIPBOARD_H 9 | 10 | #include "vaca/base.h" 11 | 12 | namespace vaca { 13 | 14 | /** 15 | Handles the global clipboard. 16 | */ 17 | class VACA_DLL Clipboard 18 | { 19 | Widget* m_owner; 20 | 21 | public: 22 | 23 | Clipboard(Widget* owner = NULL); 24 | virtual ~Clipboard(); 25 | 26 | bool isText() const; 27 | 28 | String getString() const; 29 | void setString(const String& str); 30 | 31 | }; 32 | 33 | } // namespace vaca 34 | 35 | #endif // VACA_CLIPBOARD_H 36 | -------------------------------------------------------------------------------- /vaca/TreeViewEvent.cpp: -------------------------------------------------------------------------------- 1 | // Vaca - Visual Application Components Abstraction 2 | // Copyright (c) 2005-2010 David Capello 3 | // 4 | // This file is distributed under the terms of the MIT license, 5 | // please read LICENSE.txt for more information. 6 | 7 | #include "vaca/TreeViewEvent.h" 8 | #include "vaca/TreeView.h" 9 | 10 | using namespace vaca; 11 | 12 | TreeViewEvent::TreeViewEvent(TreeView* treeView, TreeNode* treeNode, String label) 13 | : CancelableEvent(treeView) 14 | , m_treeNode(treeNode) 15 | , m_label(label) 16 | { 17 | } 18 | 19 | TreeViewEvent::~TreeViewEvent() 20 | { 21 | } 22 | 23 | TreeNode* TreeViewEvent::getTreeNode() 24 | { 25 | return m_treeNode; 26 | } 27 | 28 | String TreeViewEvent::getLabel() 29 | { 30 | return m_label; 31 | } 32 | 33 | -------------------------------------------------------------------------------- /vaca/ConsumableEvent.cpp: -------------------------------------------------------------------------------- 1 | // Vaca - Visual Application Components Abstraction 2 | // Copyright (c) 2005-2010 David Capello 3 | // 4 | // This file is distributed under the terms of the MIT license, 5 | // please read LICENSE.txt for more information. 6 | 7 | #include "vaca/ConsumableEvent.h" 8 | 9 | using namespace vaca; 10 | 11 | ConsumableEvent::ConsumableEvent(Component* source) 12 | : Event(source) 13 | , m_consumed(false) 14 | { 15 | } 16 | 17 | ConsumableEvent::~ConsumableEvent() 18 | { 19 | } 20 | 21 | /** 22 | Consumes the event. 23 | */ 24 | void ConsumableEvent::consume() 25 | { 26 | m_consumed = true; 27 | } 28 | 29 | /** 30 | The event was consumed. 31 | */ 32 | bool ConsumableEvent::isConsumed() const 33 | { 34 | return m_consumed; 35 | } 36 | -------------------------------------------------------------------------------- /vaca/LayoutEvent.h: -------------------------------------------------------------------------------- 1 | // Vaca - Visual Application Components Abstraction 2 | // Copyright (c) 2005-2010 David Capello 3 | // 4 | // This file is distributed under the terms of the MIT license, 5 | // please read LICENSE.txt for more information. 6 | 7 | #ifndef VACA_LAYOUTEVENT_H 8 | #define VACA_LAYOUTEVENT_H 9 | 10 | #include "vaca/base.h" 11 | #include "vaca/Event.h" 12 | #include "vaca/Rect.h" 13 | 14 | namespace vaca { 15 | 16 | class VACA_DLL LayoutEvent : public Event 17 | { 18 | Rect m_bounds; 19 | 20 | public: 21 | 22 | LayoutEvent(Widget* source, const Rect& bounds); 23 | virtual ~LayoutEvent(); 24 | 25 | Rect getBounds() const; 26 | void setBounds(const Rect& rc); 27 | 28 | }; 29 | 30 | } // namespace vaca 31 | 32 | #endif // VACA_LAYOUTEVENT_H 33 | -------------------------------------------------------------------------------- /doc/pages/functions.h: -------------------------------------------------------------------------------- 1 | namespace vaca { 2 | 3 | /** 4 | 5 | @page page_functions Functions 6 | 7 | @beginOverviewTable 8 | @titleRow{Macros} 9 | @itemRow{VACA_MAIN} 10 | @itemRow{VACA_TRACE} 11 | @titleRow{Base} 12 | @itemRow{clamp_value} 13 | @itemRow{max_value} 14 | @itemRow{min_value} 15 | @titleRow{Containers} 16 | @itemRow{remove_from_container} 17 | @titleRow{Memory} 18 | @itemRow{delete_widget} 19 | @titleRow{Strings} 20 | @itemRow{format_string} 21 | @itemRow{trim_string} 22 | @itemRow{convert_to} 23 | @itemRow{copy_string_to} 24 | @titleRow{Filenames} 25 | @itemRow{file_extension} 26 | @itemRow{file_name} 27 | @itemRow{file_path} 28 | @itemRow{file_title} 29 | @titleRow{URL} 30 | @itemRow{decode_url} 31 | @itemRow{encode_url} 32 | @endTable 33 | 34 | */ 35 | 36 | } 37 | -------------------------------------------------------------------------------- /examples/SplitBars/SplitBars.rc: -------------------------------------------------------------------------------- 1 | #include "resource.h" 2 | #include "windows.h" 3 | 4 | #ifdef EXAMPLE_RC_WITH_MANIFEST 5 | APP_MANIFEST RT_MANIFEST "Example.manifest" 6 | #endif 7 | 8 | IDI_VACA ICON "../Vaca.ico" 9 | 10 | IDR_MAINMENU MENU 11 | BEGIN 12 | POPUP "&File" 13 | BEGIN 14 | MENUITEM "E&xit", ID_FILE_EXIT 15 | END 16 | POPUP "&View" 17 | BEGIN 18 | MENUITEM "Vertical SplitBar1", ID_VIEW_S_SP1, CHECKED 19 | MENUITEM "Vertical SplitBar2", ID_VIEW_S_SP2, CHECKED 20 | MENUITEM SEPARATOR 21 | MENUITEM "Full Drag", ID_FULLDRAG 22 | END 23 | POPUP "&Help" 24 | BEGIN 25 | MENUITEM "&About...", ID_HELP_ABOUT 26 | END 27 | END 28 | -------------------------------------------------------------------------------- /vaca/DropFilesEvent.h: -------------------------------------------------------------------------------- 1 | // Vaca - Visual Application Components Abstraction 2 | // Copyright (c) 2005-2010 David Capello 3 | // 4 | // This file is distributed under the terms of the MIT license, 5 | // please read LICENSE.txt for more information. 6 | 7 | #ifndef VACA_DROPFILESEVENT_H 8 | #define VACA_DROPFILESEVENT_H 9 | 10 | #include "vaca/base.h" 11 | #include "vaca/Event.h" 12 | 13 | #include 14 | 15 | namespace vaca { 16 | 17 | class VACA_DLL DropFilesEvent : public Event 18 | { 19 | std::vector& m_files; 20 | 21 | public: 22 | 23 | DropFilesEvent(Widget* source, std::vector& files); 24 | virtual ~DropFilesEvent(); 25 | 26 | std::vector getFiles(); 27 | 28 | }; 29 | 30 | } // namespace vaca 31 | 32 | #endif // VACA_DROPFILESEVENT_H 33 | -------------------------------------------------------------------------------- /vaca/FocusEvent.h: -------------------------------------------------------------------------------- 1 | // Vaca - Visual Application Components Abstraction 2 | // Copyright (c) 2005-2010 David Capello 3 | // 4 | // This file is distributed under the terms of the MIT license, 5 | // please read LICENSE.txt for more information. 6 | 7 | #ifndef VACA_FOCUSEVENT_H 8 | #define VACA_FOCUSEVENT_H 9 | 10 | #include "vaca/base.h" 11 | #include "vaca/Event.h" 12 | 13 | namespace vaca { 14 | 15 | class VACA_DLL FocusEvent : public Event 16 | { 17 | Widget* m_oldFocus; 18 | Widget* m_newFocus; 19 | 20 | public: 21 | 22 | FocusEvent(Widget* source, Widget* oldFocus, Widget* newFocus); 23 | virtual ~FocusEvent(); 24 | 25 | Widget* getOldFocus() const; 26 | Widget* getNewFocus() const; 27 | 28 | }; 29 | 30 | } // namespace vaca 31 | 32 | #endif // VACA_FOCUSEVENT_H 33 | -------------------------------------------------------------------------------- /tests/test_thread.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "vaca/Thread.h" 5 | #include "vaca/Mutex.h" 6 | #include "vaca/ScopedLock.h" 7 | 8 | using namespace std; 9 | using namespace vaca; 10 | 11 | namespace test1 { 12 | 13 | Mutex mutex; 14 | int counter = 0; 15 | int times = 0; 16 | 17 | void do_it() 18 | { 19 | { 20 | ScopedLock hold(mutex); 21 | ++counter; 22 | } 23 | ::Sleep(100); 24 | } 25 | 26 | TEST(Thread, Highload) 27 | { 28 | const int n = 100; 29 | vector threads; 30 | for (int c=0; cjoin(); 32 | for (int c=0; c 2 | 3 | #include "vaca/SharedPtr.h" 4 | #include "vaca/Referenceable.h" 5 | 6 | using namespace vaca; 7 | 8 | class Int : public Referenceable 9 | { 10 | public: 11 | int value_; 12 | Int(int value) : value_(value) { } 13 | }; 14 | 15 | TEST(SharedPtr, Equal) 16 | { 17 | SharedPtr a(new Int(5)); 18 | SharedPtr b(new Int(0)); 19 | SharedPtr c; 20 | 21 | EXPECT_EQ(5, a->value_); 22 | EXPECT_EQ(0, b->value_); 23 | 24 | b->value_ = a->value_; // Same values 25 | 26 | EXPECT_TRUE(a != b); // References are different 27 | EXPECT_TRUE(b != c); 28 | 29 | b = a; // Same reference 30 | 31 | EXPECT_TRUE(a == b); 32 | EXPECT_TRUE(b != c); 33 | EXPECT_TRUE(&a->value_ == &b->value_); // Same address 34 | } 35 | -------------------------------------------------------------------------------- /vaca/ResourceException.h: -------------------------------------------------------------------------------- 1 | // Vaca - Visual Application Components Abstraction 2 | // Copyright (c) 2005-2010 David Capello 3 | // 4 | // This file is distributed under the terms of the MIT license, 5 | // please read LICENSE.txt for more information. 6 | 7 | #ifndef VACA_RESOURCEEXCEPTION_H 8 | #define VACA_RESOURCEEXCEPTION_H 9 | 10 | #include "vaca/Exception.h" 11 | 12 | namespace vaca { 13 | 14 | /** 15 | A resource (from exe or from an external file) can't be loaded. 16 | */ 17 | class ResourceException : public Exception 18 | { 19 | public: 20 | 21 | ResourceException() : Exception() { } 22 | ResourceException(const String& message) : Exception(message) { } 23 | virtual ~ResourceException() throw() { } 24 | 25 | }; 26 | 27 | } // namespace vaca 28 | 29 | #endif // VACA_RESOURCEEXCEPTION_H 30 | -------------------------------------------------------------------------------- /vaca/SetCursorEvent.h: -------------------------------------------------------------------------------- 1 | // Vaca - Visual Application Components Abstraction 2 | // Copyright (c) 2005-2010 David Capello 3 | // 4 | // This file is distributed under the terms of the MIT license, 5 | // please read LICENSE.txt for more information. 6 | 7 | #ifndef VACA_SETCURSOREVENT_H 8 | #define VACA_SETCURSOREVENT_H 9 | 10 | #include "vaca/base.h" 11 | #include "vaca/MouseEvent.h" 12 | #include "vaca/WidgetHit.h" 13 | 14 | namespace vaca { 15 | 16 | class VACA_DLL SetCursorEvent : public MouseEvent 17 | { 18 | WidgetHit m_hit; 19 | 20 | public: 21 | 22 | SetCursorEvent(Widget* source, Point point, WidgetHit hit); 23 | virtual ~SetCursorEvent(); 24 | 25 | void setCursor(const Cursor& cursor); 26 | 27 | WidgetHit getWidgetHit() const; 28 | 29 | }; 30 | 31 | } // namespace vaca 32 | 33 | #endif // VACA_SETCURSOREVENT_H 34 | -------------------------------------------------------------------------------- /vaca/win32/MainArgs.h: -------------------------------------------------------------------------------- 1 | // Vaca - Visual Application Components Abstraction 2 | // Copyright (c) 2005-2010 David Capello 3 | // 4 | // This file is distributed under the terms of the MIT license, 5 | // please read LICENSE.txt for more information. 6 | 7 | #include 8 | #include 9 | 10 | void vaca::details::MainArgs::setArgs(int, char**) 11 | { 12 | // Convert the command-line to a vector of arguments using Win32 API 13 | std::vector args; 14 | LPWSTR* arglist; 15 | int argc; 16 | 17 | arglist = ::CommandLineToArgvW(::GetCommandLineW(), &argc); 18 | if (arglist != NULL) { 19 | args.reserve(argc); 20 | for (int i=0; i(m_id); 34 | } 35 | 36 | LPTSTR ResourceId::toLPTSTR() 37 | { 38 | return MAKEINTRESOURCE(m_id); 39 | } 40 | -------------------------------------------------------------------------------- /vaca/ConsumableEvent.h: -------------------------------------------------------------------------------- 1 | // Vaca - Visual Application Components Abstraction 2 | // Copyright (c) 2005-2010 David Capello 3 | // 4 | // This file is distributed under the terms of the MIT license, 5 | // please read LICENSE.txt for more information. 6 | 7 | #ifndef VACA_CONSUMABLEEVENT_H 8 | #define VACA_CONSUMABLEEVENT_H 9 | 10 | #include "vaca/Event.h" 11 | 12 | namespace vaca { 13 | 14 | /** 15 | Event that can be consumed. 16 | */ 17 | class VACA_DLL ConsumableEvent : public Event 18 | { 19 | /** 20 | The event was consumed. 21 | */ 22 | bool m_consumed; 23 | 24 | public: 25 | 26 | ConsumableEvent(Component* source); 27 | virtual ~ConsumableEvent(); 28 | 29 | void consume(); 30 | bool isConsumed() const; 31 | 32 | }; 33 | 34 | } // namespace vaca 35 | 36 | #endif // VACA_CONSUMABLEEVENT_H 37 | -------------------------------------------------------------------------------- /vaca/SetCursorEvent.cpp: -------------------------------------------------------------------------------- 1 | // Vaca - Visual Application Components Abstraction 2 | // Copyright (c) 2005-2010 David Capello 3 | // 4 | // This file is distributed under the terms of the MIT license, 5 | // please read LICENSE.txt for more information. 6 | 7 | #include "vaca/SetCursorEvent.h" 8 | #include "vaca/Widget.h" 9 | #include "vaca/Cursor.h" 10 | 11 | using namespace vaca; 12 | 13 | SetCursorEvent::SetCursorEvent(Widget* source, Point point, WidgetHit hit) 14 | : MouseEvent(source, point, 0, 0, MouseButton::None) 15 | , m_hit(hit) 16 | { 17 | } 18 | 19 | SetCursorEvent::~SetCursorEvent() 20 | { 21 | } 22 | 23 | void SetCursorEvent::setCursor(const Cursor& cursor) 24 | { 25 | ::SetCursor(const_cast(&cursor)->getHandle()); 26 | consume(); 27 | } 28 | 29 | WidgetHit SetCursorEvent::getWidgetHit() const 30 | { 31 | return m_hit; 32 | } 33 | -------------------------------------------------------------------------------- /vaca/Event.h: -------------------------------------------------------------------------------- 1 | // Vaca - Visual Application Components Abstraction 2 | // Copyright (c) 2005-2010 David Capello 3 | // 4 | // This file is distributed under the terms of the MIT license, 5 | // please read LICENSE.txt for more information. 6 | 7 | #ifndef VACA_EVENT_H 8 | #define VACA_EVENT_H 9 | 10 | #include "vaca/base.h" 11 | 12 | namespace vaca { 13 | 14 | /** 15 | Base class for every kind of event. 16 | */ 17 | class VACA_DLL Event 18 | { 19 | /** 20 | The component which generates the event. It's specified in the 21 | @link Event#Event(Component*) Event's constructor@endlink 22 | */ 23 | Component* m_source; 24 | 25 | public: 26 | 27 | Event(Component* source); 28 | virtual ~Event(); 29 | 30 | Component* getSource(); 31 | 32 | }; 33 | 34 | } // namespace vaca 35 | 36 | #endif // VACA_EVENT_H 37 | -------------------------------------------------------------------------------- /vaca/CommonDialog.h: -------------------------------------------------------------------------------- 1 | // Vaca - Visual Application Components Abstraction 2 | // Copyright (c) 2005-2010 David Capello 3 | // 4 | // This file is distributed under the terms of the MIT license, 5 | // please read LICENSE.txt for more information. 6 | 7 | #ifndef VACA_COMMONDIALOG_H 8 | #define VACA_COMMONDIALOG_H 9 | 10 | #include "vaca/base.h" 11 | #include "vaca/Component.h" 12 | 13 | #include 14 | 15 | namespace vaca { 16 | 17 | /** 18 | Base class for common dialogs. 19 | */ 20 | class VACA_DLL CommonDialog : public Component 21 | { 22 | Widget* m_parent; 23 | 24 | public: 25 | 26 | CommonDialog(Widget* parent); 27 | virtual ~CommonDialog(); 28 | 29 | Widget* getParent(); 30 | HWND getParentHandle(); 31 | 32 | virtual bool doModal() = 0; 33 | 34 | }; 35 | 36 | } // namespace vaca 37 | 38 | #endif // VACA_COMMONDIALOG_H 39 | -------------------------------------------------------------------------------- /vaca/Event.cpp: -------------------------------------------------------------------------------- 1 | // Vaca - Visual Application Components Abstraction 2 | // Copyright (c) 2005-2010 David Capello 3 | // 4 | // This file is distributed under the terms of the MIT license, 5 | // please read LICENSE.txt for more information. 6 | 7 | #include "vaca/Event.h" 8 | 9 | using namespace vaca; 10 | 11 | /** 12 | Creates a new event specifying that it was generated 13 | from the @a source component. 14 | 15 | @param source 16 | The component which generates the event. 17 | */ 18 | Event::Event(Component* source) 19 | : m_source(source) 20 | { 21 | } 22 | 23 | /** 24 | Destroys the event. 25 | */ 26 | Event::~Event() 27 | { 28 | } 29 | 30 | /** 31 | Returns the event's source. 32 | 33 | @return 34 | The component which generates the event. 35 | */ 36 | Component* Event::getSource() 37 | { 38 | return m_source; 39 | } 40 | -------------------------------------------------------------------------------- /vaca/unix/MutexImpl.h: -------------------------------------------------------------------------------- 1 | // Vaca - Visual Application Components Abstraction 2 | // Copyright (c) 2005-2010 David Capello 3 | // 4 | // This file is distributed under the terms of the MIT license, 5 | // please read LICENSE.txt for more information. 6 | 7 | #include 8 | #include 9 | 10 | class vaca::Mutex::MutexImpl 11 | { 12 | pthread_mutex_t m_handle; 13 | 14 | public: 15 | 16 | MutexImpl() 17 | { 18 | pthread_mutex_init(&m_handle, NULL); 19 | } 20 | 21 | ~MutexImpl() 22 | { 23 | pthread_mutex_destroy(&m_handle); 24 | } 25 | 26 | void lock() 27 | { 28 | pthread_mutex_lock(&m_handle); 29 | } 30 | 31 | bool tryLock() 32 | { 33 | return pthread_mutex_trylock(&m_handle) != EBUSY; 34 | } 35 | 36 | void unlock() 37 | { 38 | pthread_mutex_unlock(&m_handle); 39 | } 40 | 41 | }; 42 | 43 | -------------------------------------------------------------------------------- /vaca/FindFiles.h: -------------------------------------------------------------------------------- 1 | // Vaca - Visual Application Components Abstraction 2 | // Copyright (c) 2005-2010 David Capello 3 | // 4 | // This file is distributed under the terms of the MIT license, 5 | // please read LICENSE.txt for more information. 6 | 7 | #ifndef VACA_FINDFILES_H 8 | #define VACA_FINDFILES_H 9 | 10 | #include "vaca/base.h" 11 | #include "vaca/NonCopyable.h" 12 | 13 | namespace vaca { 14 | 15 | class VACA_DLL FindFiles : public NonCopyable 16 | { 17 | String m_pattern; 18 | HANDLE m_handle; 19 | WIN32_FIND_DATA m_data; 20 | 21 | public: 22 | 23 | FindFiles(const String& pattern); 24 | ~FindFiles(); 25 | 26 | bool next(); 27 | 28 | String getFileName() const; 29 | String getFullFileName() const; 30 | bool isFile() const; 31 | bool isDirectory() const; 32 | 33 | }; 34 | 35 | } // namespace vaca 36 | 37 | #endif // VACA_FINDFILES_H 38 | -------------------------------------------------------------------------------- /examples/DialogResource/DialogResource.cpp: -------------------------------------------------------------------------------- 1 | // Vaca - Visual Application Components Abstraction 2 | // Copyright (c) 2005-2009 David Capello 3 | // 4 | // This file is distributed under the terms of the MIT license, 5 | // please read LICENSE.txt for more information. 6 | 7 | #include 8 | #include "resource.h" 9 | 10 | using namespace vaca; 11 | 12 | void show_about(Widget* parent) 13 | { 14 | Dialog dlg(ResourceId(IDD_ABOUT), parent); 15 | 16 | dlg.center(); 17 | dlg.doModal(); 18 | } 19 | 20 | int VACA_MAIN() 21 | { 22 | Application app; 23 | Dialog dlg(ResourceId(IDD_MAIN)); 24 | // Button but(dlg.getItemHandle(ResourceId(IDC_MAIN_ABOUT_BUTTON))); 25 | Button button(::GetDlgItem(dlg.getHandle(), IDC_MAIN_ABOUT_BUTTON)); 26 | button.Click.connect([&dlg]{ show_about(&dlg); }); 27 | 28 | dlg.center(); 29 | dlg.doModal(); 30 | return 0; 31 | } 32 | -------------------------------------------------------------------------------- /examples/Minimal/Minimal.cpp: -------------------------------------------------------------------------------- 1 | // Vaca - Visual Application Components Abstraction 2 | // Copyright (c) 2005-2009 David Capello 3 | // 4 | // This file is distributed under the terms of the MIT license, 5 | // please read LICENSE.txt for more information. 6 | 7 | #include 8 | #include "../resource.h" 9 | 10 | using namespace vaca; 11 | 12 | class MainFrame : public Frame 13 | { 14 | Label label; 15 | public: 16 | MainFrame() : Frame(L"Minimal") 17 | , label(L"This is the minimal program using Vaca\r\n" 18 | L"so you can copy && paste this code.", this) 19 | { 20 | setLayout(new ClientLayout); 21 | setSize(getPreferredSize()); 22 | } 23 | }; 24 | 25 | int VACA_MAIN() 26 | { 27 | Application app; 28 | MainFrame frm; 29 | frm.setIcon(ResourceId(IDI_VACA)); 30 | frm.setVisible(true); 31 | app.run(); 32 | return 0; 33 | } 34 | -------------------------------------------------------------------------------- /vaca/ColorDialog.h: -------------------------------------------------------------------------------- 1 | // Vaca - Visual Application Components Abstraction 2 | // Copyright (c) 2005-2010 David Capello 3 | // 4 | // This file is distributed under the terms of the MIT license, 5 | // please read LICENSE.txt for more information. 6 | 7 | #ifndef VACA_COLORDIALOG_H 8 | #define VACA_COLORDIALOG_H 9 | 10 | #include "vaca/base.h" 11 | #include "vaca/CommonDialog.h" 12 | #include "vaca/Color.h" 13 | 14 | namespace vaca { 15 | 16 | /** 17 | A common dialog box to select colors. 18 | */ 19 | class VACA_DLL ColorDialog : public CommonDialog 20 | { 21 | Color m_color; 22 | COLORREF m_customColors[16]; 23 | 24 | public: 25 | 26 | ColorDialog(const Color& color, Widget* parent); 27 | virtual ~ColorDialog(); 28 | 29 | virtual bool doModal(); 30 | 31 | Color getColor() const; 32 | 33 | }; 34 | 35 | } // namespace vaca 36 | 37 | #endif // VACA_COLORDIALOG_H 38 | -------------------------------------------------------------------------------- /vaca/DropFilesEvent.cpp: -------------------------------------------------------------------------------- 1 | // Vaca - Visual Application Components Abstraction 2 | // Copyright (c) 2005-2010 David Capello 3 | // 4 | // This file is distributed under the terms of the MIT license, 5 | // please read LICENSE.txt for more information. 6 | 7 | #include "vaca/DropFilesEvent.h" 8 | #include "vaca/Widget.h" 9 | 10 | using namespace vaca; 11 | 12 | /** 13 | Creates the event. 14 | 15 | @param widget Source of the event. 16 | @param files The list of dropped files. 17 | */ 18 | DropFilesEvent::DropFilesEvent(Widget* widget, std::vector &files) 19 | : Event(widget) 20 | , m_files(files) 21 | { 22 | } 23 | 24 | /** 25 | Destroys the event. 26 | */ 27 | DropFilesEvent::~DropFilesEvent() 28 | { 29 | } 30 | 31 | /** 32 | @return The list of dropped files. 33 | */ 34 | std::vector DropFilesEvent::getFiles() 35 | { 36 | return m_files; 37 | } 38 | -------------------------------------------------------------------------------- /vaca/ScrollEvent.cpp: -------------------------------------------------------------------------------- 1 | // Vaca - Visual Application Components Abstraction 2 | // Copyright (c) 2005-2010 David Capello 3 | // 4 | // This file is distributed under the terms of the MIT license, 5 | // please read LICENSE.txt for more information. 6 | 7 | #include "vaca/ScrollEvent.h" 8 | #include "vaca/Widget.h" 9 | 10 | using namespace vaca; 11 | 12 | ScrollEvent::ScrollEvent(Widget* source, Orientation orien, ScrollRequest req, int pos) 13 | : Event(source) 14 | , m_orientation(orien) 15 | , m_request(req) 16 | , m_position(pos) 17 | { 18 | } 19 | 20 | ScrollEvent::~ScrollEvent() 21 | { 22 | } 23 | 24 | Orientation ScrollEvent::getOrientation() const 25 | { 26 | return m_orientation; 27 | } 28 | 29 | ScrollRequest ScrollEvent::getRequest() const 30 | { 31 | return m_request; 32 | } 33 | 34 | int ScrollEvent::getPosition() const 35 | { 36 | return m_position; 37 | } 38 | -------------------------------------------------------------------------------- /vaca/ResourceId.h: -------------------------------------------------------------------------------- 1 | // Vaca - Visual Application Components Abstraction 2 | // Copyright (c) 2005-2010 David Capello 3 | // 4 | // This file is distributed under the terms of the MIT license, 5 | // please read LICENSE.txt for more information. 6 | 7 | #ifndef VACA_RESOURCEID_H 8 | #define VACA_RESOURCEID_H 9 | 10 | #include "vaca/base.h" 11 | 12 | namespace vaca { 13 | 14 | /** 15 | Class to wrap an ID of an object in the resource file (.rc). 16 | 17 | @win32 18 | Look for @msdn{About Resource Files}. 19 | @endwin32 20 | */ 21 | class VACA_DLL ResourceId 22 | { 23 | int m_id; 24 | 25 | public: 26 | 27 | explicit ResourceId(int id); 28 | ResourceId(const ResourceId& rc); 29 | virtual ~ResourceId(); 30 | 31 | int getId() const; 32 | 33 | String toString(); 34 | LPTSTR toLPTSTR(); 35 | 36 | }; 37 | 38 | } // namespace vaca 39 | 40 | #endif // VACA_RESOURCEID_H 41 | -------------------------------------------------------------------------------- /vaca/CloseEvent.h: -------------------------------------------------------------------------------- 1 | // Vaca - Visual Application Components Abstraction 2 | // Copyright (c) 2005-2010 David Capello 3 | // 4 | // This file is distributed under the terms of the MIT license, 5 | // please read LICENSE.txt for more information. 6 | 7 | #ifndef VACA_CLOSEEVENT_H 8 | #define VACA_CLOSEEVENT_H 9 | 10 | #include "vaca/CancelableEvent.h" 11 | 12 | namespace vaca { 13 | 14 | /** 15 | Event generated when a Frame is being closed. 16 | 17 | This is a CancelableEvent, so you can call #cancel to abort the 18 | close operation (it is useful to show a MsgBox like "Do you want 19 | to save your changes before close?" before the Frame is finally 20 | closed). 21 | */ 22 | class VACA_DLL CloseEvent : public CancelableEvent 23 | { 24 | public: 25 | 26 | CloseEvent(Frame* source); 27 | virtual ~CloseEvent(); 28 | 29 | }; 30 | 31 | } // namespace vaca 32 | 33 | #endif // VACA_CLOSEEVENT_H 34 | -------------------------------------------------------------------------------- /vaca/Separator.h: -------------------------------------------------------------------------------- 1 | // Vaca - Visual Application Components Abstraction 2 | // Copyright (c) 2005-2022 David Capello 3 | // 4 | // This file is distributed under the terms of the MIT license, 5 | // please read LICENSE.txt for more information. 6 | 7 | #ifndef VACA_SEPARATOR_H 8 | #define VACA_SEPARATOR_H 9 | 10 | #include "vaca/base.h" 11 | #include "vaca/Widget.h" 12 | 13 | namespace vaca { 14 | 15 | class VACA_DLL Separator : public Widget 16 | { 17 | public: 18 | 19 | struct Styles { 20 | static constexpr Style Default = 21 | Widget::Styles::Visible | 22 | Style(SS_NOTIFY | SS_SUNKEN, 0); 23 | }; 24 | 25 | Separator(Widget* parent, Style style = Styles::Default); 26 | virtual ~Separator(); 27 | 28 | protected: 29 | 30 | // Events 31 | virtual void onPreferredSize(PreferredSizeEvent& ev); 32 | 33 | }; 34 | 35 | } // namespace vaca 36 | 37 | #endif // VACA_SEPARATOR_H 38 | -------------------------------------------------------------------------------- /vaca/Separator.cpp: -------------------------------------------------------------------------------- 1 | // Vaca - Visual Application Components Abstraction 2 | // Copyright (c) 2005-2010 David Capello 3 | // 4 | // This file is distributed under the terms of the MIT license, 5 | // please read LICENSE.txt for more information. 6 | 7 | #include "vaca/Separator.h" 8 | #include "vaca/WidgetClass.h" 9 | #include "vaca/PreferredSizeEvent.h" 10 | 11 | using namespace vaca; 12 | 13 | Separator::Separator(Widget* parent, Style style) 14 | : Widget(WidgetClassName(WC_STATIC), parent, style) 15 | { 16 | } 17 | 18 | Separator::~Separator() 19 | { 20 | } 21 | 22 | /** 23 | The preferred size of a separator is a 2x2 box. It is your 24 | responsability to make the Separator widget a horizontal or 25 | vertical line (through the Layout of the @link Widget#getParent parent Widget@endlink). 26 | */ 27 | void Separator::onPreferredSize(PreferredSizeEvent& ev) 28 | { 29 | ev.setPreferredSize(2, 2); 30 | } 31 | -------------------------------------------------------------------------------- /tests/test_tab.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "vaca/vaca.h" 4 | 5 | using namespace vaca; 6 | 7 | TEST(Tab, Base) 8 | { 9 | Application app; 10 | Frame frame(L"Temporary"); 11 | TabBase tab(&frame); 12 | 13 | // default side 14 | assert(tab.getSide() == Side::Top); 15 | 16 | // default multiline 17 | assert(tab.isMultiline() == false); 18 | tab.setMultiline(true); 19 | assert(tab.isMultiline() == true); 20 | 21 | // change side 22 | tab.setSide(Side::Left); 23 | assert(tab.getSide() == Side::Left); 24 | 25 | // add/insert/remove pages 26 | tab.addPage(L"Remove me"); 27 | tab.addPage(L"A"); 28 | tab.addPage(L"C"); 29 | tab.addPage(L"D"); 30 | tab.insertPage(2, L"B"); 31 | tab.removePage(0); 32 | tab.removePage(3); 33 | 34 | assert(tab.getPageCount() == 3); 35 | assert(tab.getPageText(0) == L"A"); 36 | assert(tab.getPageText(1) == L"B"); 37 | assert(tab.getPageText(2) == L"C"); 38 | } 39 | -------------------------------------------------------------------------------- /examples/Console.h: -------------------------------------------------------------------------------- 1 | // Vaca - Visual Application Components Abstraction 2 | // Copyright (c) 2005-2009 David Capello 3 | // 4 | // This file is distributed under the terms of the MIT license, 5 | // please read LICENSE.txt for more information. 6 | 7 | // This class is a little widget to simulate a "console". 8 | // It is mainly used to show messages in some examples. 9 | class Console : public TextEdit 10 | { 11 | public: 12 | 13 | Console(Widget* parent) 14 | : TextEdit(L"", parent, TextEdit::Styles::TextArea + 15 | TextEdit::Styles::ReadOnly + 16 | Widget::Styles::Scroll) 17 | { 18 | setFont(Font(L"Courier New", 10)); 19 | setBgColor(Color::White); 20 | setFgColor(Color(0, 100, 0)); 21 | } 22 | 23 | void println(const String& str) 24 | { 25 | // append the text to the end 26 | setText(getText() + str + L"\r\n"); 27 | 28 | // scroll to the end 29 | scrollLines(getLineCount()); 30 | } 31 | 32 | }; 33 | -------------------------------------------------------------------------------- /vaca/FontDialog.h: -------------------------------------------------------------------------------- 1 | // Vaca - Visual Application Components Abstraction 2 | // Copyright (c) 2005-2010 David Capello 3 | // 4 | // This file is distributed under the terms of the MIT license, 5 | // please read LICENSE.txt for more information. 6 | 7 | #ifndef VACA_FONTDIALOG_H 8 | #define VACA_FONTDIALOG_H 9 | 10 | #include "vaca/base.h" 11 | #include "vaca/CommonDialog.h" 12 | #include "vaca/Font.h" 13 | 14 | namespace vaca { 15 | 16 | /** 17 | A common dialog box to select fonts. 18 | 19 | @see Font 20 | */ 21 | class VACA_DLL FontDialog : public CommonDialog 22 | { 23 | Font m_font; 24 | LOGFONT m_logFont; 25 | 26 | public: 27 | 28 | FontDialog(const Font& font, Widget* parent); 29 | virtual ~FontDialog(); 30 | 31 | virtual bool doModal(); 32 | 33 | Font getFont() const; 34 | bool getLogFont(LPLOGFONT lplf) const; 35 | 36 | }; 37 | 38 | } // namespace vaca 39 | 40 | #endif // VACA_FONTDIALOG_H 41 | -------------------------------------------------------------------------------- /vaca/TreeViewEvent.h: -------------------------------------------------------------------------------- 1 | // Vaca - Visual Application Components Abstraction 2 | // Copyright (c) 2005-2010 David Capello 3 | // 4 | // This file is distributed under the terms of the MIT license, 5 | // please read LICENSE.txt for more information. 6 | 7 | #ifndef VACA_TREEVIEWEVENT_H 8 | #define VACA_TREEVIEWEVENT_H 9 | 10 | #include "vaca/base.h" 11 | #include "vaca/CancelableEvent.h" 12 | 13 | namespace vaca { 14 | 15 | /** 16 | Event where interact a TreeView and TreeNode. 17 | */ 18 | class VACA_DLL TreeViewEvent : public CancelableEvent 19 | { 20 | TreeNode* m_treeNode; 21 | String m_label; 22 | 23 | public: 24 | 25 | TreeViewEvent(TreeView* treeView, TreeNode* treeNode, String label = L""); 26 | virtual ~TreeViewEvent(); 27 | 28 | TreeView* getTreeView(); 29 | TreeNode* getTreeNode(); 30 | 31 | String getLabel(); 32 | 33 | }; 34 | 35 | } // namespace vaca 36 | 37 | #endif // VACA_TREEVIEWEVENT_H 38 | -------------------------------------------------------------------------------- /vaca/Referenceable.h: -------------------------------------------------------------------------------- 1 | // Vaca - Visual Application Components Abstraction 2 | // Copyright (c) 2005-2010 David Capello 3 | // 4 | // This file is distributed under the terms of the MIT license, 5 | // please read LICENSE.txt for more information. 6 | 7 | #ifndef VACA_REFERENCEABLE_H 8 | #define VACA_REFERENCEABLE_H 9 | 10 | #include "vaca/base.h" 11 | #include "vaca/NonCopyable.h" 12 | 13 | namespace vaca { 14 | 15 | /** 16 | Class that counts references and can be wrapped by a SharedPtr. 17 | */ 18 | class VACA_DLL Referenceable : private NonCopyable 19 | { 20 | template friend class SharedPtr; 21 | unsigned m_refCount; 22 | 23 | public: 24 | 25 | Referenceable(); 26 | virtual ~Referenceable(); 27 | 28 | void ref(); 29 | unsigned unref(); 30 | 31 | unsigned getRefCount(); 32 | 33 | #ifndef NDEBUG 34 | static void showLeaks(); 35 | #endif 36 | 37 | private: 38 | void destroy(); 39 | }; 40 | 41 | } // namespace vaca 42 | 43 | #endif // VACA_REFERENCEABLE_H 44 | -------------------------------------------------------------------------------- /vaca/CustomLabel.cpp: -------------------------------------------------------------------------------- 1 | // Vaca - Visual Application Components Abstraction 2 | // Copyright (c) 2005-2010 David Capello 3 | // 4 | // This file is distributed under the terms of the MIT license, 5 | // please read LICENSE.txt for more information. 6 | 7 | #include "vaca/CustomLabel.h" 8 | #include "vaca/Debug.h" 9 | 10 | using namespace vaca; 11 | 12 | CustomLabel::CustomLabel(const String& text, Widget* parent, Style style) 13 | : Label(text, parent, style) 14 | , m_textAlign(TextAlign::Left) 15 | { 16 | } 17 | 18 | CustomLabel::~CustomLabel() 19 | { 20 | } 21 | 22 | TextAlign CustomLabel::getTextAlign() const 23 | { 24 | return m_textAlign; 25 | } 26 | 27 | void CustomLabel::setTextAlign(TextAlign align) 28 | { 29 | m_textAlign = align; 30 | invalidate(true); 31 | } 32 | 33 | bool CustomLabel::onReflectedDrawItem(Graphics& g, LPDRAWITEMSTRUCT lpDrawItem) 34 | { 35 | assert(lpDrawItem->CtlType == ODT_STATIC); 36 | 37 | return doPaint(g); 38 | } 39 | -------------------------------------------------------------------------------- /vaca/CancelableEvent.h: -------------------------------------------------------------------------------- 1 | // Vaca - Visual Application Components Abstraction 2 | // Copyright (c) 2005-2010 David Capello 3 | // 4 | // This file is distributed under the terms of the MIT license, 5 | // please read LICENSE.txt for more information. 6 | 7 | #ifndef VACA_CANCELABLEEVENT_H 8 | #define VACA_CANCELABLEEVENT_H 9 | 10 | #include "vaca/Event.h" 11 | 12 | namespace vaca { 13 | 14 | /** 15 | Event that can be canceled. 16 | 17 | For example, a CloseEvent can be canceled if you don't want to 18 | close the Frame (or the user cancel the event answering a MsgBox). 19 | */ 20 | class VACA_DLL CancelableEvent : public Event 21 | { 22 | /** 23 | The event was canceled. 24 | */ 25 | bool m_canceled; 26 | 27 | public: 28 | 29 | CancelableEvent(Component* source); 30 | virtual ~CancelableEvent(); 31 | 32 | void cancel(); 33 | bool isCanceled() const; 34 | 35 | }; 36 | 37 | } // namespace vaca 38 | 39 | #endif // VACA_CANCELABLEEVENT_H 40 | -------------------------------------------------------------------------------- /vaca/StatusBar.h: -------------------------------------------------------------------------------- 1 | // Vaca - Visual Application Components Abstraction 2 | // Copyright (c) 2005-2022 David Capello 3 | // 4 | // This file is distributed under the terms of the MIT license, 5 | // please read LICENSE.txt for more information. 6 | 7 | #ifndef VACA_STATUSBAR_H 8 | #define VACA_STATUSBAR_H 9 | 10 | #include "vaca/base.h" 11 | #include "vaca/Widget.h" 12 | 13 | namespace vaca { 14 | 15 | class VACA_DLL StatusBar : public Widget 16 | { 17 | public: 18 | 19 | struct Styles { 20 | static constexpr Style Default = 21 | Widget::Styles::Visible | 22 | Style(SBARS_SIZEGRIP, 0); 23 | }; 24 | 25 | StatusBar(Widget* parent, Style style = Styles::Default); 26 | virtual ~StatusBar(); 27 | 28 | virtual bool isLayoutFree() const; 29 | 30 | protected: 31 | // Events 32 | virtual void onPreferredSize(PreferredSizeEvent& ev); 33 | virtual void onLayout(LayoutEvent& ev); 34 | }; 35 | 36 | } // namespace vaca 37 | 38 | #endif // VACA_STATUSBAR_H 39 | -------------------------------------------------------------------------------- /vaca/ToggleButton.h: -------------------------------------------------------------------------------- 1 | // Vaca - Visual Application Components Abstraction 2 | // Copyright (c) 2005-2022 David Capello 3 | // 4 | // This file is distributed under the terms of the MIT license, 5 | // please read LICENSE.txt for more information. 6 | 7 | #ifndef VACA_TOGGLEBUTTON_H 8 | #define VACA_TOGGLEBUTTON_H 9 | 10 | #include "vaca/ButtonBase.h" 11 | 12 | namespace vaca { 13 | 14 | /** 15 | Handles a pusheable button (with BS_AUTOCHECKBOX | BS_PUSHLIKE styles). 16 | */ 17 | class VACA_DLL ToggleButton : public ButtonBase 18 | { 19 | public: 20 | 21 | struct Styles { 22 | static constexpr Style Default = 23 | Widget::Styles::Visible | 24 | Widget::Styles::Focusable | 25 | Style(BS_AUTOCHECKBOX | 26 | BS_PUSHLIKE, 0); 27 | }; 28 | 29 | ToggleButton(const String& text, Widget* parent, Style style = Styles::Default); 30 | virtual ~ToggleButton(); 31 | 32 | }; 33 | 34 | } // namespace vaca 35 | 36 | #endif // VACA_TOGGLEBUTTON_H 37 | -------------------------------------------------------------------------------- /vaca/CheckBox.h: -------------------------------------------------------------------------------- 1 | // Vaca - Visual Application Components Abstraction 2 | // Copyright (c) 2005-2022 David Capello 3 | // 4 | // This file is distributed under the terms of the MIT license, 5 | // please read LICENSE.txt for more information. 6 | 7 | #ifndef VACA_CHECKBOX_H 8 | #define VACA_CHECKBOX_H 9 | 10 | #include "vaca/ButtonBase.h" 11 | 12 | namespace vaca { 13 | 14 | /** 15 | Handles a check box button. 16 | 17 | @image html CheckBox.png 18 | */ 19 | class VACA_DLL CheckBox : public ButtonBase 20 | { 21 | public: 22 | 23 | struct Styles { 24 | /** 25 | Default style for CheckBox widget. 26 | */ 27 | static constexpr Style Default = 28 | Widget::Styles::Visible | 29 | Widget::Styles::Focusable | 30 | Style(BS_AUTOCHECKBOX, 0); 31 | }; 32 | 33 | CheckBox(const String& text, Widget* parent, Style style = Styles::Default); 34 | virtual ~CheckBox(); 35 | 36 | }; 37 | 38 | } // namespace vaca 39 | 40 | #endif // VACA_CHECKBOX_H 41 | -------------------------------------------------------------------------------- /vaca/Brush.cpp: -------------------------------------------------------------------------------- 1 | // Vaca - Visual Application Components Abstraction 2 | // Copyright (c) 2005-2010 David Capello 3 | // 4 | // This file is distributed under the terms of the MIT license, 5 | // please read LICENSE.txt for more information. 6 | 7 | #include "vaca/Brush.h" 8 | 9 | #if defined(VACA_WINDOWS) 10 | #include "win32/BrushImpl.h" 11 | #else 12 | #error Implement Brush class in your platform 13 | #endif 14 | 15 | using namespace vaca; 16 | 17 | Brush::Brush() 18 | : m_impl(new BrushImpl()) 19 | { 20 | } 21 | 22 | Brush::Brush(const Brush& brush) 23 | : m_impl(brush.m_impl) // Copy shared pointers 24 | { 25 | } 26 | 27 | Brush::Brush(const Color& color) 28 | : m_impl(new BrushImpl(color)) 29 | { 30 | } 31 | 32 | Brush::~Brush() 33 | { 34 | } 35 | 36 | Brush& Brush::operator=(const Brush& brush) 37 | { 38 | // Copy shared pointers 39 | m_impl = brush.m_impl; 40 | return *this; 41 | } 42 | 43 | Color Brush::getColor() const 44 | { 45 | return m_impl->getColor(); 46 | } 47 | -------------------------------------------------------------------------------- /vaca/PreferredSizeEvent.h: -------------------------------------------------------------------------------- 1 | // Vaca - Visual Application Components Abstraction 2 | // Copyright (c) 2005-2010 David Capello 3 | // 4 | // This file is distributed under the terms of the MIT license, 5 | // please read LICENSE.txt for more information. 6 | 7 | #ifndef VACA_PREFERREDSIZEEVENT_H 8 | #define VACA_PREFERREDSIZEEVENT_H 9 | 10 | #include "vaca/base.h" 11 | #include "vaca/Event.h" 12 | #include "vaca/Size.h" 13 | 14 | namespace vaca { 15 | 16 | class VACA_DLL PreferredSizeEvent : public Event 17 | { 18 | Size m_fitIn; 19 | Size m_preferredSize; 20 | 21 | public: 22 | 23 | PreferredSizeEvent(Widget* source, const Size& fitIn); 24 | virtual ~PreferredSizeEvent(); 25 | 26 | Size fitInSize() const; 27 | int fitInWidth() const; 28 | int fitInHeight() const; 29 | 30 | Size getPreferredSize() const; 31 | void setPreferredSize(const Size& preferredSize); 32 | void setPreferredSize(int w, int h); 33 | 34 | }; 35 | 36 | } // namespace vaca 37 | 38 | #endif // VACA_PREFERREDSIZEEVENT_H 39 | -------------------------------------------------------------------------------- /vaca/Anchor.h: -------------------------------------------------------------------------------- 1 | // Vaca - Visual Application Components Abstraction 2 | // Copyright (c) 2005-2010 David Capello 3 | // 4 | // This file is distributed under the terms of the MIT license, 5 | // please read LICENSE.txt for more information. 6 | 7 | #ifndef VACA_ANCHOR_H 8 | #define VACA_ANCHOR_H 9 | 10 | #include "vaca/base.h" 11 | #include "vaca/Constraint.h" 12 | #include "vaca/Rect.h" 13 | 14 | namespace vaca { 15 | 16 | /** 17 | Anchor constraint. You should setup an Anchor contraint for every 18 | widget controled by an AnchorLayout. 19 | 20 | @see AnchorLayout. 21 | */ 22 | class VACA_DLL Anchor : public Constraint 23 | { 24 | Rect m_refRect; 25 | Sides m_sides; 26 | 27 | public: 28 | 29 | Anchor(const Rect& refRect, Sides borders); 30 | virtual ~Anchor(); 31 | 32 | Rect getRefRect() const; 33 | void setRefRect(const Rect& refRect); 34 | 35 | Sides getSides() const; 36 | void setSides(Sides borders); 37 | 38 | }; // Anchor 39 | 40 | } // namespace vaca 41 | 42 | #endif // VACA_ANCHOR_H 43 | -------------------------------------------------------------------------------- /vaca/ClientLayout.h: -------------------------------------------------------------------------------- 1 | // Vaca - Visual Application Components Abstraction 2 | // Copyright (c) 2005-2010 David Capello 3 | // 4 | // This file is distributed under the terms of the MIT license, 5 | // please read LICENSE.txt for more information. 6 | 7 | #ifndef VACA_CLIENTLAYOUT_H 8 | #define VACA_CLIENTLAYOUT_H 9 | 10 | #include "vaca/base.h" 11 | #include "vaca/Layout.h" 12 | 13 | namespace vaca { 14 | 15 | /** 16 | The more simplest Layout manager: positions all the widgets in the 17 | full client area. It's useful only if you have one child in the 18 | parent widget. 19 | */ 20 | class VACA_DLL ClientLayout : public Layout 21 | { 22 | int m_border; 23 | 24 | public: 25 | 26 | ClientLayout(); 27 | ClientLayout(int border); 28 | virtual ~ClientLayout(); 29 | 30 | virtual Size getPreferredSize(Widget* parent, WidgetList& widgets, const Size& fitIn); 31 | virtual void layout(Widget* parent, WidgetList& widgets, const Rect& rc); 32 | 33 | }; 34 | 35 | } // namespace vaca 36 | 37 | #endif // VACA_CLIENTLAYOUT_H 38 | -------------------------------------------------------------------------------- /vaca/win32/MutexImpl.h: -------------------------------------------------------------------------------- 1 | // Vaca - Visual Application Components Abstraction 2 | // Copyright (c) 2005-2010 David Capello 3 | // 4 | // This file is distributed under the terms of the MIT license, 5 | // please read LICENSE.txt for more information. 6 | 7 | #ifndef _WIN32_WINNT 8 | #define _WIN32_WINNT 0x0400 9 | #endif 10 | #define WIN32_LEAN_AND_MEAN 11 | #include 12 | 13 | class vaca::Mutex::MutexImpl 14 | { 15 | CRITICAL_SECTION m_handle; 16 | 17 | public: 18 | 19 | MutexImpl() 20 | { 21 | InitializeCriticalSection(&m_handle); 22 | } 23 | 24 | ~MutexImpl() 25 | { 26 | DeleteCriticalSection(&m_handle); 27 | } 28 | 29 | void lock() 30 | { 31 | EnterCriticalSection(&m_handle); 32 | } 33 | 34 | bool tryLock() 35 | { 36 | #if(_WIN32_WINNT >= 0x0400) 37 | return TryEnterCriticalSection(&m_handle) ? true: false; 38 | #else 39 | #error Vaca does not support the target platform 40 | #endif 41 | } 42 | 43 | void unlock() 44 | { 45 | LeaveCriticalSection(&m_handle); 46 | } 47 | 48 | }; 49 | -------------------------------------------------------------------------------- /tests/test_menu.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "vaca/vaca.h" 4 | 5 | using namespace vaca; 6 | 7 | class MenuTest : public testing::Test { 8 | Application app; 9 | }; 10 | 11 | TEST_F(MenuTest, Label) 12 | { 13 | MenuItem mi(L"MenuItem label", 1); 14 | EXPECT_EQ(L"MenuItem label", mi.getText()); 15 | 16 | Menu m(L"Menu label"); 17 | EXPECT_EQ(L"Menu label", m.getText()); 18 | } 19 | 20 | TEST_F(MenuTest, Enabled) 21 | { 22 | MenuItem mi(L"a", 1); 23 | EXPECT_TRUE(mi.isEnabled()); 24 | mi.setEnabled(false); 25 | EXPECT_FALSE(mi.isEnabled()); 26 | 27 | Menu m(L"b"); 28 | 29 | m.add(&mi); 30 | EXPECT_FALSE(mi.isEnabled()); 31 | mi.setEnabled(true); 32 | EXPECT_TRUE(mi.isEnabled()); 33 | m.remove(&mi); 34 | } 35 | 36 | TEST_F(MenuTest, Checked) 37 | { 38 | MenuItem mi(L"a", 1); 39 | EXPECT_FALSE(mi.isChecked()); 40 | mi.setChecked(true); 41 | EXPECT_TRUE(mi.isChecked()); 42 | 43 | Menu m(L"b"); 44 | 45 | m.add(&mi); 46 | EXPECT_TRUE(mi.isChecked()); 47 | mi.setChecked(false); 48 | EXPECT_FALSE(mi.isChecked()); 49 | m.remove(&mi); 50 | } 51 | -------------------------------------------------------------------------------- /vaca/Exception.h: -------------------------------------------------------------------------------- 1 | // Vaca - Visual Application Components Abstraction 2 | // Copyright (c) 2005-2010 David Capello 3 | // 4 | // This file is distributed under the terms of the MIT license, 5 | // please read LICENSE.txt for more information. 6 | 7 | #ifndef VACA_EXCEPTION_H 8 | #define VACA_EXCEPTION_H 9 | 10 | #include "vaca/base.h" 11 | 12 | #include 13 | 14 | namespace vaca { 15 | 16 | /** 17 | Exception generated from Vaca. 18 | 19 | Base class for every exception generated by Vaca objects. 20 | */ 21 | class VACA_DLL Exception : public std::exception 22 | { 23 | String m_message; 24 | std::string m_what; 25 | int m_errorCode; 26 | 27 | public: 28 | 29 | Exception(); 30 | Exception(const String& message); 31 | virtual ~Exception() throw(); 32 | 33 | virtual const char* what() const throw(); 34 | virtual const String& getMessage() const throw(); 35 | 36 | int getErrorCode() const; 37 | 38 | private: 39 | 40 | void initialize(); 41 | 42 | }; 43 | 44 | } // namespace vaca 45 | 46 | #endif // VACA_EXCEPTION_H 47 | -------------------------------------------------------------------------------- /vaca/LayoutEvent.cpp: -------------------------------------------------------------------------------- 1 | // Vaca - Visual Application Components Abstraction 2 | // Copyright (c) 2005-2010 David Capello 3 | // 4 | // This file is distributed under the terms of the MIT license, 5 | // please read LICENSE.txt for more information. 6 | 7 | #include "vaca/LayoutEvent.h" 8 | #include "vaca/Widget.h" 9 | 10 | using namespace vaca; 11 | 12 | LayoutEvent::LayoutEvent(Widget* source, const Rect& bounds) 13 | : Event(source) 14 | , m_bounds(bounds) 15 | { 16 | } 17 | 18 | /** 19 | Destroys the LayoutEvent. 20 | */ 21 | LayoutEvent::~LayoutEvent() 22 | { 23 | } 24 | 25 | /** 26 | Returns the area where Widget#onLayout member function should 27 | put children widgets. 28 | 29 | It is generally the client bounds, but other widgets (like Tab) 30 | could reduce this rectangle to use a small area inside the widget. 31 | 32 | @see Widget#getClientBounds 33 | */ 34 | Rect LayoutEvent::getBounds() const 35 | { 36 | return m_bounds; 37 | } 38 | 39 | void LayoutEvent::setBounds(const Rect& bounds) 40 | { 41 | m_bounds = bounds; 42 | } 43 | -------------------------------------------------------------------------------- /vaca/Layout.cpp: -------------------------------------------------------------------------------- 1 | // Vaca - Visual Application Components Abstraction 2 | // Copyright (c) 2005-2010 David Capello 3 | // 4 | // This file is distributed under the terms of the MIT license, 5 | // please read LICENSE.txt for more information. 6 | 7 | #include "vaca/Layout.h" 8 | #include "vaca/Debug.h" 9 | #include "vaca/Widget.h" 10 | 11 | using namespace vaca; 12 | 13 | Layout::Layout() 14 | { 15 | } 16 | 17 | Layout::~Layout() 18 | { 19 | } 20 | 21 | Size Layout::getPreferredSize(Widget* parent, WidgetList& widgets, const Size& fitIn) 22 | { 23 | return Size(0, 0); 24 | } 25 | 26 | ////////////////////////////////////////////////////////////////////// 27 | // WidgetsMovement 28 | 29 | #include "win32/WidgetsMovementImpl.h" 30 | 31 | WidgetsMovement::WidgetsMovement(const WidgetList& widgets) 32 | : m_impl(new WidgetsMovementImpl(widgets)) 33 | { 34 | } 35 | 36 | WidgetsMovement::~WidgetsMovement() 37 | { 38 | delete m_impl; 39 | } 40 | 41 | void WidgetsMovement::moveWidget(Widget* widget, const Rect& rc) 42 | { 43 | m_impl->moveWidget(widget, rc); 44 | } 45 | -------------------------------------------------------------------------------- /examples/DialogResource/DialogResource.rc: -------------------------------------------------------------------------------- 1 | #include "resource.h" 2 | #include "windows.h" 3 | 4 | #ifdef EXAMPLE_RC_WITH_MANIFEST 5 | APP_MANIFEST RT_MANIFEST "Example.manifest" 6 | #endif 7 | 8 | IDI_VACA ICON "../Vaca.ico" 9 | 10 | IDD_MAIN DIALOGEX 0, 0, 200, 100 11 | CAPTION "Main Dialog" 12 | STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | 13 | WS_SYSMENU | WS_SIZEBOX | WS_MINIMIZEBOX | WS_MAXIMIZEBOX 14 | EXSTYLE WS_EX_APPWINDOW 15 | FONT 8, "MS Shell Dlg", 0, 0, 0x1 16 | BEGIN 17 | LTEXT "These widgets are defined in a .rc file",2,2,0,119,8 18 | PUSHBUTTON "About",IDC_MAIN_ABOUT_BUTTON,2,14,119,14,WS_GROUP 19 | PUSHBUTTON "IDOK button",IDOK,2,30,119,14,WS_GROUP 20 | END 21 | 22 | IDD_ABOUT DIALOGEX 0, 0, 133, 54 23 | CAPTION "About" 24 | STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU 25 | EXSTYLE WS_EX_APPWINDOW 26 | FONT 8, "MS Shell Dlg", 0, 0, 0x1 27 | BEGIN 28 | LTEXT "DialogResource",0,7,7,119,8,SS_NOPREFIX 29 | LTEXT "Vaca library example",0,7,22,119,8 30 | DEFPUSHBUTTON "OK",IDOK,85,34,41,13,WS_GROUP 31 | END 32 | -------------------------------------------------------------------------------- /tests/test_point.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "vaca/Point.h" 4 | 5 | using namespace vaca; 6 | 7 | inline std::ostream& operator<<(std::ostream& os, const Point& pt) 8 | { 9 | return os << "Point(" << pt.x << ", " << pt.y << ")\n"; 10 | } 11 | 12 | TEST(Point, Basics) 13 | { 14 | Point p1; 15 | EXPECT_EQ(0, p1.x); 16 | EXPECT_EQ(0, p1.y); 17 | 18 | Point p2(32, 40); 19 | EXPECT_EQ(32, p2.x); 20 | EXPECT_EQ(40, p2.y); 21 | 22 | EXPECT_TRUE(p1 != p2); 23 | 24 | p1 = p2; 25 | EXPECT_TRUE(p1 == p2); 26 | 27 | p1 += p2; 28 | EXPECT_EQ(64, p1.x); 29 | EXPECT_EQ(80, p1.y); 30 | 31 | p1 /= 4; 32 | EXPECT_EQ(16, p1.x); 33 | EXPECT_EQ(20, p1.y); 34 | 35 | p1 += 4; 36 | EXPECT_EQ(20, p1.x); 37 | EXPECT_EQ(24, p1.y); 38 | 39 | p1 *= 2; 40 | EXPECT_EQ(40, p1.x); 41 | EXPECT_EQ(48, p1.y); 42 | 43 | p1 -= p2; 44 | EXPECT_EQ(8, p1.x); 45 | EXPECT_EQ(8, p1.y); 46 | } 47 | 48 | TEST(Point, Operators) 49 | { 50 | EXPECT_EQ(Point(-1, -3), -Point(1, 3)); 51 | 52 | EXPECT_EQ(Point(8, 4), Point(3, 3)+Point(5, 1)); 53 | EXPECT_EQ(Point(2, 1), Point(3, 2)-Point(1, 1)); 54 | } 55 | -------------------------------------------------------------------------------- /doc/pages/index.h: -------------------------------------------------------------------------------- 1 | namespace vaca { 2 | 3 | /** 4 | 5 | @mainpage Vaca 0.0.8 6 | 7 | @image html Vaca.png 8 |
9 |
by David Capello
10 | 11 | Licensed under the terms of the @ref page_license "New BSD license". @n 12 | Report bugs, errors, and mistakes to davidcapello@gmail.com. 13 | 14 |
15 | Vaca is an experimental project, the API is unstable. @n 16 | Use it at your own risk or contribute to its development. 17 |
18 |
19 | 20 | @section index_manual User Manual 21 | 22 | @li @subpage page_intro 23 | @li @subpage page_license 24 | @li @subpage page_platforms 25 | @li @subpage page_devel 26 | @li @subpage page_mess 27 | @li @subpage page_examples 28 | @li @subpage page_tn 29 | 30 | 31 | @section index_reference Reference 32 | 33 | @li @subpage page_constants 34 | @li @subpage page_functions 35 | @li @subpage page_classes 36 | 37 | */ 38 | 39 | } 40 | -------------------------------------------------------------------------------- /doc/pages/tn009.h: -------------------------------------------------------------------------------- 1 | namespace vaca { 2 | 3 | /** 4 | 5 | @page page_tn_009 TN009: Reflection 6 | 7 | Vaca supports reflection of @c WM_COMMAND, @c WM_NOTIFY and @c WM_DRAWITEM 8 | using the #vaca::Widget methods: 9 | 10 | @li @link vaca::Widget#onReflectedCommand Widget::onReflectedCommand@endlink 11 | @li @link vaca::Widget#onReflectedNotify Widget::onReflectedNotify@endlink 12 | @li @link vaca::Widget#onReflectedDrawItem Widget::onReflectedDrawItem@endlink 13 | 14 | When a widget (e.g. @link vaca::Button Button@endlink) sends a notification 15 | (e.g. @c BN_CLICKED) to its parent widget (e.g. @link vaca::Frame Frame@endlink), 16 | the @c Frame processes the @c WM_COMMAND and extracts the handle of the button 17 | from the @c lParam (a @c HWND). Then uses the @link vaca::Widget::fromHandle Widget::fromHandle@endlink 18 | to get the @c "Button*" pointer, and finally calls 19 | @link vaca::ButtonBase::onReflectedCommand ButtonBase::onReflectedCommand@endlink(...). 20 | 21 | @see @link vaca::Widget#wndProc Widget::wndProc@endlink, 22 | @link vaca::Widget#fromHandle Widget::fromHandle@endlink. 23 | 24 | */ 25 | 26 | } 27 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2005-2022 David Capello 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the 5 | "Software"), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to 9 | the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be 12 | included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /vaca/KeyEvent.cpp: -------------------------------------------------------------------------------- 1 | // Vaca - Visual Application Components Abstraction 2 | // Copyright (c) 2005-2010 David Capello 3 | // 4 | // This file is distributed under the terms of the MIT license, 5 | // please read LICENSE.txt for more information. 6 | 7 | #include "vaca/KeyEvent.h" 8 | #include "vaca/Widget.h" 9 | 10 | using namespace vaca; 11 | 12 | KeyEvent::KeyEvent(Widget* source, Keys::Type keys, Char charCode) 13 | : ConsumableEvent(source) 14 | , m_keys(keys) 15 | , m_charCode(charCode) 16 | { 17 | } 18 | 19 | KeyEvent::~KeyEvent() 20 | { 21 | } 22 | 23 | Keys::Type KeyEvent::getKeyCode() const 24 | { 25 | return m_keys & Keys::KeyCode; 26 | } 27 | 28 | Keys::Type KeyEvent::getModifiers() const 29 | { 30 | return m_keys & Keys::Modifiers; 31 | } 32 | 33 | Char KeyEvent::getCharCode() const 34 | { 35 | return m_charCode; 36 | } 37 | 38 | bool KeyEvent::isShift() const 39 | { 40 | return (m_keys & Keys::Shift) != 0; 41 | } 42 | 43 | bool KeyEvent::isControl() const 44 | { 45 | return (m_keys & Keys::Control) != 0; 46 | } 47 | 48 | bool KeyEvent::isAlt() const 49 | { 50 | return (m_keys & Keys::Alt) != 0; 51 | } 52 | -------------------------------------------------------------------------------- /vaca/ScrollInfo.h: -------------------------------------------------------------------------------- 1 | // Vaca - Visual Application Components Abstraction 2 | // Copyright (c) 2005-2010 David Capello 3 | // 4 | // This file is distributed under the terms of the MIT license, 5 | // please read LICENSE.txt for more information. 6 | 7 | #ifndef VACA_SCROLLINFO_H 8 | #define VACA_SCROLLINFO_H 9 | 10 | #include "vaca/base.h" 11 | 12 | namespace vaca { 13 | 14 | /** 15 | Auxiliary structure to get and set scroll information. 16 | 17 | Scroll information includes: the valid range where the scroll 18 | position can be, and the page size. 19 | 20 | @see Widget#getScrollInfo, Widget#getScrollPos 21 | */ 22 | class VACA_DLL ScrollInfo 23 | { 24 | int m_minPos; 25 | int m_maxPos; 26 | int m_pageSize; 27 | 28 | public: 29 | ScrollInfo(); 30 | ScrollInfo(int minPos, int maxPos, int pageSize); 31 | virtual ~ScrollInfo(); 32 | 33 | int getMinPos() const; 34 | int getMaxPos() const; 35 | int getPageSize() const; 36 | 37 | void setMinPos(int minPos); 38 | void setMaxPos(int maxPos); 39 | void setPageSize(int pageSize); 40 | 41 | }; 42 | 43 | } // namespace vaca 44 | 45 | #endif // VACA_SCROLLINFO_H 46 | -------------------------------------------------------------------------------- /vaca/ScrollInfo.cpp: -------------------------------------------------------------------------------- 1 | // Vaca - Visual Application Components Abstraction 2 | // Copyright (c) 2005-2010 David Capello 3 | // 4 | // This file is distributed under the terms of the MIT license, 5 | // please read LICENSE.txt for more information. 6 | 7 | #include "vaca/ScrollInfo.h" 8 | 9 | using namespace vaca; 10 | 11 | ScrollInfo::ScrollInfo() 12 | { 13 | m_minPos = m_maxPos = m_pageSize = 0; 14 | } 15 | 16 | ScrollInfo::ScrollInfo(int minPos, int maxPos, int pageSize) 17 | : m_minPos(minPos) 18 | , m_maxPos(maxPos) 19 | , m_pageSize(pageSize) 20 | { 21 | } 22 | 23 | ScrollInfo::~ScrollInfo() 24 | { 25 | } 26 | 27 | int ScrollInfo::getMinPos() const 28 | { 29 | return m_minPos; 30 | } 31 | 32 | int ScrollInfo::getMaxPos() const 33 | { 34 | return m_maxPos; 35 | } 36 | 37 | int ScrollInfo::getPageSize() const 38 | { 39 | return m_pageSize; 40 | } 41 | 42 | void ScrollInfo::setMinPos(int minPos) 43 | { 44 | m_minPos = minPos; 45 | } 46 | 47 | void ScrollInfo::setMaxPos(int maxPos) 48 | { 49 | m_maxPos = maxPos; 50 | } 51 | 52 | void ScrollInfo::setPageSize(int pageSize) 53 | { 54 | m_pageSize = pageSize; 55 | } 56 | -------------------------------------------------------------------------------- /vaca/BoxConstraint.h: -------------------------------------------------------------------------------- 1 | // Vaca - Visual Application Components Abstraction 2 | // Copyright (c) 2005-2010 David Capello 3 | // 4 | // This file is distributed under the terms of the MIT license, 5 | // please read LICENSE.txt for more information. 6 | 7 | #ifndef VACA_BOXCONSTRAINT_H 8 | #define VACA_BOXCONSTRAINT_H 9 | 10 | #include "vaca/base.h" 11 | #include "vaca/Constraint.h" 12 | 13 | namespace vaca { 14 | 15 | /** 16 | Defines a constraint for the BoxLayout. With BoxLayout a Widget can 17 | be expansive or not. An expansive widget tries to ocuppy more space 18 | what Widget::getPreferredSize() returns (generally widgets like 19 | ListBox or Edit should be expansive). 20 | 21 | If you don't setup an BoxConstraint for a widget controlled by a 22 | BoxLayout, the widget'll be known as non-expansive. 23 | */ 24 | class VACA_DLL BoxConstraint : public Constraint 25 | { 26 | bool m_expansive; 27 | 28 | public: 29 | 30 | BoxConstraint(bool expansive); 31 | virtual ~BoxConstraint(); 32 | 33 | bool isExpansive(); 34 | void setExpansive(bool expansive); 35 | 36 | }; 37 | 38 | } // namespace vaca 39 | 40 | #endif // VACA_BOXCONSTRAINT_H 41 | -------------------------------------------------------------------------------- /vaca/Button.cpp: -------------------------------------------------------------------------------- 1 | // Vaca - Visual Application Components Abstraction 2 | // Copyright (c) 2005-2010 David Capello 3 | // 4 | // This file is distributed under the terms of the MIT license, 5 | // please read LICENSE.txt for more information. 6 | 7 | #include "vaca/Button.h" 8 | #include "vaca/Debug.h" 9 | 10 | using namespace vaca; 11 | 12 | Button::Button(const String& text, Widget* parent, Style style) 13 | : ButtonBase(parent, style) 14 | { 15 | setText(text); 16 | } 17 | 18 | Button::Button(const String& text, CommandId id, Widget* parent, Style style) 19 | : ButtonBase(parent, style) 20 | { 21 | setText(text); 22 | setId(id); 23 | } 24 | 25 | Button::Button(HWND handle) 26 | : ButtonBase(handle) 27 | { 28 | } 29 | 30 | Button::~Button() 31 | { 32 | } 33 | 34 | bool Button::isDefault() 35 | { 36 | return (getStyle().regular & BS_DEFPUSHBUTTON) != 0; 37 | } 38 | 39 | void Button::setDefault(bool state) 40 | { 41 | if (state) { 42 | addStyle(Style(BS_DEFPUSHBUTTON, 0)); 43 | // setId(IDOK); 44 | } 45 | else { 46 | removeStyle(Style(BS_DEFPUSHBUTTON, 0)); 47 | // if (getId() == IDOK) 48 | // setId(0); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /vaca/Constraint.h: -------------------------------------------------------------------------------- 1 | // Vaca - Visual Application Components Abstraction 2 | // Copyright (c) 2005-2010 David Capello 3 | // 4 | // This file is distributed under the terms of the MIT license, 5 | // please read LICENSE.txt for more information. 6 | 7 | #ifndef VACA_CONSTRAINT_H 8 | #define VACA_CONSTRAINT_H 9 | 10 | #include "vaca/base.h" 11 | #include "vaca/Referenceable.h" 12 | 13 | namespace vaca { 14 | 15 | /** 16 | Abstract class to represent a constraint. Constraints are useful to 17 | specify conditions to different arrangements using the same Layout 18 | manager. 19 | 20 | Each widget can have a constraint. It's only useful when the parent 21 | has a layout manager that known about the constraint of the widget 22 | (the child). 23 | 24 | A constraint is an object to indicate to the layout manager (of the 25 | parent widget) special properties to be used when the layout manager 26 | must to arrange the widget. 27 | */ 28 | class VACA_DLL Constraint : public Referenceable 29 | { 30 | public: 31 | 32 | Constraint(); 33 | virtual ~Constraint(); 34 | 35 | }; 36 | 37 | } // namespace vaca 38 | 39 | #endif // VACA_CONSTRAINT_H 40 | -------------------------------------------------------------------------------- /vaca/ButtonBase.h: -------------------------------------------------------------------------------- 1 | // Vaca - Visual Application Components Abstraction 2 | // Copyright (c) 2005-2010 David Capello 3 | // 4 | // This file is distributed under the terms of the MIT license, 5 | // please read LICENSE.txt for more information. 6 | 7 | #ifndef VACA_BUTTONBASE_H 8 | #define VACA_BUTTONBASE_H 9 | 10 | #include "vaca/Widget.h" 11 | 12 | namespace vaca { 13 | 14 | /** 15 | Base for every button. 16 | 17 | @win32 18 | It's a wrapper for the @msdn{BUTTON} class. 19 | @endwin32 20 | */ 21 | class VACA_DLL ButtonBase : public Widget 22 | { 23 | public: 24 | 25 | ButtonBase(Widget* parent, Style style); 26 | explicit ButtonBase(HWND handle); 27 | virtual ~ButtonBase(); 28 | 29 | bool isSelected(); 30 | void setSelected(bool state); 31 | 32 | // Signals 33 | Signal Click; ///< @see onClick 34 | 35 | protected: 36 | // Events 37 | virtual void onPreferredSize(PreferredSizeEvent& ev); 38 | 39 | // New events 40 | virtual void onClick(Event& ev); 41 | 42 | // Reflected notifications 43 | virtual bool onReflectedCommand(int id, int code, LRESULT& lResult); 44 | }; 45 | 46 | } // namespace vaca 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /doc/pages/tn008.h: -------------------------------------------------------------------------------- 1 | namespace vaca { 2 | 3 | /** 4 | 5 | @page page_tn_008 TN008: Unicode support 6 | 7 | @li @ref page_tn_008_string_literals 8 | @li @ref page_tn_008_convert_strings 9 | @li @ref page_tn_008_unicode_chars 10 | 11 | 12 | @section page_tn_008_string_literals String Literals 13 | 14 | You have to use the L suffix to define string literals. For example: 15 | @code 16 | String str = L"Hi"; 17 | @endcode 18 | This creates a wide character string literal to initialize @c str String. 19 | 20 | 21 | @section page_tn_008_convert_strings Convert Strings 22 | You can use the convert_to function to convert an ASCII string 23 | to a Vaca String: 24 | @code 25 | String a = convert_to("Hi"); // Use L"Hi" for literals 26 | 27 | char* b = strdup("Hi"); 28 | String c = convert_to(b); 29 | 30 | std::string d = "Hi"; 31 | String e = convert_to(d); 32 | @endcode 33 | 34 | 35 | @section page_tn_008_unicode_chars Unicode Characters 36 | You can use \\xNNNN to create Unicode characters. For example: 37 | @code 38 | Char a_character = L'\x0061'; // same as L'a' 39 | String japanese = L"\x65E5\x672C\x8A9E"; // 日本語 40 | @endcode 41 | 42 | 43 | */ 44 | 45 | } 46 | -------------------------------------------------------------------------------- /vaca/KeyEvent.h: -------------------------------------------------------------------------------- 1 | // Vaca - Visual Application Components Abstraction 2 | // Copyright (c) 2005-2010 David Capello 3 | // 4 | // This file is distributed under the terms of the MIT license, 5 | // please read LICENSE.txt for more information. 6 | 7 | #ifndef VACA_KEYEVENT_H 8 | #define VACA_KEYEVENT_H 9 | 10 | #include "vaca/base.h" 11 | #include "vaca/ConsumableEvent.h" 12 | #include "vaca/Keys.h" 13 | 14 | namespace vaca { 15 | 16 | /** 17 | Data for an event that comes from the keyboard. 18 | */ 19 | class VACA_DLL KeyEvent : public ConsumableEvent 20 | { 21 | /** 22 | Virtual-key code. 23 | 24 | @see #getKeyCode, Keys 25 | */ 26 | int m_keys; 27 | 28 | /** 29 | Character-key code. 30 | 31 | @see #getCharCode 32 | */ 33 | Char m_charCode; 34 | 35 | public: 36 | 37 | KeyEvent(Widget* source, Keys::Type keys, Char charCode); 38 | virtual ~KeyEvent(); 39 | 40 | Keys::Type getKeyCode() const; 41 | Keys::Type getModifiers() const; 42 | Char getCharCode() const; 43 | 44 | bool isShift() const; 45 | bool isControl() const; 46 | bool isAlt() const; 47 | 48 | }; 49 | 50 | } // namespace vaca 51 | 52 | #endif // VACA_KEYEVENT_H 53 | -------------------------------------------------------------------------------- /vaca/Mutex.h: -------------------------------------------------------------------------------- 1 | // Vaca - Visual Application Components Abstraction 2 | // Copyright (c) 2005-2010 David Capello 3 | // 4 | // This file is distributed under the terms of the MIT license, 5 | // please read LICENSE.txt for more information. 6 | 7 | #ifndef VACA_MUTEX_H 8 | #define VACA_MUTEX_H 9 | 10 | #include "vaca/base.h" 11 | #include "vaca/NonCopyable.h" 12 | 13 | namespace vaca { 14 | 15 | /** 16 | An object to synchronize threads using mutual exclusion of critical 17 | sections. 18 | 19 | This kind of mutex can be used to synchronize multiple threads of 20 | the same process. No multiple processes! 21 | 22 | @win32 23 | This is a @msdn{CRITICAL_SECTION} wrapper. 24 | @endwin32 25 | 26 | @see ScopedLock, ConditionVariable, Thread, 27 | @wikipedia{Critical_section, Critical Section in Wikipedia} 28 | @wikipedia{Mutex, Mutex in Wikipedia} 29 | */ 30 | class VACA_DLL Mutex : private NonCopyable 31 | { 32 | class MutexImpl; 33 | MutexImpl* m_impl; 34 | 35 | public: 36 | 37 | Mutex(); 38 | ~Mutex(); 39 | 40 | void lock(); 41 | bool tryLock(); 42 | void unlock(); 43 | 44 | }; 45 | 46 | } // namespace vaca 47 | 48 | #endif // VACA_MUTEX_H 49 | -------------------------------------------------------------------------------- /vaca/NonCopyable.h: -------------------------------------------------------------------------------- 1 | // Vaca - Visual Application Components Abstraction 2 | // Copyright (c) 2005-2010 David Capello 3 | // 4 | // This file is distributed under the terms of the MIT license, 5 | // please read LICENSE.txt for more information. 6 | 7 | #ifndef VACA_NONCOPYABLE_H 8 | #define VACA_NONCOPYABLE_H 9 | 10 | #include "vaca/base.h" 11 | 12 | namespace vaca { 13 | 14 | /** 15 | Class which can't be copied. 16 | 17 | If you derive from this class, then you will not be able to make 18 | copies of your own class. This means that the class will be 19 | copied neither using the copy constructor nor the assigment operator. 20 | 21 | Example: 22 | @code 23 | class MyClass : private NonCopyable 24 | { 25 | public: 26 | MyClass() { 27 | } 28 | }; 29 | int main() 30 | { 31 | MyClass a, b; 32 | MyClass c(a); // <-- compiler error 33 | b = a; // <-- compiler error 34 | } 35 | @endcode 36 | */ 37 | class VACA_DLL NonCopyable 38 | { 39 | public: 40 | NonCopyable() { } 41 | ~NonCopyable() { } 42 | private: 43 | NonCopyable(const NonCopyable&); 44 | NonCopyable& operator=(const NonCopyable&); 45 | }; 46 | 47 | } // namespace vaca 48 | 49 | #endif // VACA_NONCOPYABLE_H 50 | -------------------------------------------------------------------------------- /vaca/StatusBar.cpp: -------------------------------------------------------------------------------- 1 | // Vaca - Visual Application Components Abstraction 2 | // Copyright (c) 2005-2010 David Capello 3 | // 4 | // This file is distributed under the terms of the MIT license, 5 | // please read LICENSE.txt for more information. 6 | 7 | #include "vaca/StatusBar.h" 8 | #include "vaca/WidgetClass.h" 9 | #include "vaca/PreferredSizeEvent.h" 10 | #include "vaca/LayoutEvent.h" 11 | 12 | using namespace vaca; 13 | 14 | StatusBar::StatusBar(Widget* parent, Style style) 15 | : Widget(WidgetClassName(STATUSCLASSNAME), parent, style) 16 | { 17 | } 18 | 19 | StatusBar::~StatusBar() 20 | { 21 | } 22 | 23 | /** 24 | A status bar is arranged by a Frame, but doesn't depend of the 25 | current Layout manager in that Frame. 26 | */ 27 | bool StatusBar::isLayoutFree() const 28 | { 29 | return true; 30 | } 31 | 32 | void StatusBar::onPreferredSize(PreferredSizeEvent& ev) 33 | { 34 | ev.setPreferredSize(0, 24); 35 | } 36 | 37 | void StatusBar::onLayout(LayoutEvent& ev) 38 | { 39 | Rect rc = ev.getBounds(); 40 | Size pref = getPreferredSize(); 41 | 42 | setBounds(Rect(rc.x, rc.y+rc.h-pref.h, rc.w, pref.h)); 43 | 44 | rc.h -= pref.h; 45 | ev.setBounds(rc); 46 | 47 | Widget::onLayout(ev); 48 | } 49 | -------------------------------------------------------------------------------- /vaca/AnchorLayout.h: -------------------------------------------------------------------------------- 1 | // Vaca - Visual Application Components Abstraction 2 | // Copyright (c) 2005-2010 David Capello 3 | // 4 | // This file is distributed under the terms of the MIT license, 5 | // please read LICENSE.txt for more information. 6 | 7 | #ifndef VACA_ANCHORLAYOUT_H 8 | #define VACA_ANCHORLAYOUT_H 9 | 10 | #include "vaca/base.h" 11 | #include "vaca/Layout.h" 12 | 13 | namespace vaca { 14 | 15 | /** 16 | An AnchorLayout tries to maintain the same aspect of the widgets 17 | using references rectangles. It uses Anchor contraints to known 18 | which side of a child must be "anchored" (to maintain the same 19 | distance) to which side of the parent. 20 | 21 | @image html AnchorLayout.png 22 | 23 | @see AnchorLayout#AnchorLayout, Anchor 24 | */ 25 | class VACA_DLL AnchorLayout : public Layout 26 | { 27 | /** 28 | The size of the imaginary rectangle @c Rect(Point(0,0),refSize). 29 | 30 | @see AnchorLayout#AnchorLayout 31 | */ 32 | Size m_refSize; 33 | 34 | public: 35 | 36 | AnchorLayout(const Size& refSize); 37 | 38 | virtual void layout(Widget* parent, WidgetList& widgets, const Rect& rc); 39 | 40 | }; 41 | 42 | } // namespace vaca 43 | 44 | #endif // VACA_ANCHORLAYOUT_H 45 | -------------------------------------------------------------------------------- /vaca/win32/WidgetsMovementImpl.h: -------------------------------------------------------------------------------- 1 | // Vaca - Visual Application Components Abstraction 2 | // Copyright (c) 2005-2010 David Capello 3 | // 4 | // This file is distributed under the terms of the MIT license, 5 | // please read LICENSE.txt for more information. 6 | 7 | #ifndef _WIN32_WINNT 8 | #define _WIN32_WINNT 0x0400 9 | #endif 10 | #define WIN32_LEAN_AND_MEAN 11 | #include 12 | 13 | class vaca::WidgetsMovement::WidgetsMovementImpl 14 | { 15 | HDWP m_hdwp; 16 | WidgetList m_relayoutWidgets; 17 | 18 | public: 19 | 20 | WidgetsMovementImpl(const WidgetList& widgets) 21 | { 22 | m_hdwp = BeginDeferWindowPos(widgets.size()); 23 | } 24 | 25 | ~WidgetsMovementImpl() 26 | { 27 | EndDeferWindowPos(m_hdwp); 28 | m_hdwp = NULL; 29 | 30 | for (WidgetList::iterator it=m_relayoutWidgets.begin(); 31 | it!=m_relayoutWidgets.end(); ++it) { 32 | (*it)->layout(); 33 | } 34 | } 35 | 36 | void moveWidget(Widget* widget, const Rect& rc) 37 | { 38 | m_hdwp = DeferWindowPos(m_hdwp, widget->getHandle(), NULL, 39 | rc.x, rc.y, rc.w, rc.h, 40 | SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_NOACTIVATE); 41 | 42 | m_relayoutWidgets.push_back(widget); 43 | } 44 | 45 | }; 46 | -------------------------------------------------------------------------------- /examples/Undo/Document.h: -------------------------------------------------------------------------------- 1 | // Vaca - Visual Application Components Abstraction 2 | // Copyright (c) 2005-2009 David Capello 3 | // 4 | // This file is distributed under the terms of the MIT license, 5 | // please read LICENSE.txt for more information. 6 | 7 | #ifndef DOCUMENT_H 8 | #define DOCUMENT_H 9 | 10 | #include 11 | 12 | using namespace vaca; 13 | 14 | typedef String::size_type DocPos; 15 | 16 | class Document : public Referenceable 17 | { 18 | String m_name; 19 | String m_string; 20 | 21 | public: 22 | 23 | Document(const String& name) : m_name(name) { 24 | } 25 | 26 | ~Document() { 27 | } 28 | 29 | String getName() { 30 | return m_name; 31 | } 32 | 33 | Char at(DocPos pos) const { 34 | return m_string.at(pos); 35 | } 36 | 37 | DocPos size() const { 38 | return m_string.size(); 39 | } 40 | 41 | void add(DocPos pos, Char chr) { 42 | m_string.insert(pos, 1, chr); 43 | } 44 | 45 | void add(DocPos pos, const String& s) { 46 | m_string.insert(pos, s); 47 | } 48 | 49 | void remove(DocPos pos, DocPos n) { 50 | m_string.erase(pos, n); 51 | } 52 | 53 | }; 54 | 55 | typedef SharedPtr DocumentPtr; 56 | 57 | #endif // DOCUMENT_H 58 | -------------------------------------------------------------------------------- /vaca/Button.h: -------------------------------------------------------------------------------- 1 | // Vaca - Visual Application Components Abstraction 2 | // Copyright (c) 2005-2022 David Capello 3 | // 4 | // This file is distributed under the terms of the MIT license, 5 | // please read LICENSE.txt for more information. 6 | 7 | #ifndef VACA_BUTTON_H 8 | #define VACA_BUTTON_H 9 | 10 | #include "vaca/ButtonBase.h" 11 | 12 | namespace vaca { 13 | 14 | /** 15 | Handles a pusheable button. These are the more common buttons, like 16 | "OK" or "Cancel". 17 | 18 | @image html Button.png 19 | */ 20 | class VACA_DLL Button : public ButtonBase 21 | { 22 | public: 23 | 24 | struct Styles { 25 | 26 | /** 27 | Default style for Button widget. 28 | */ 29 | static constexpr Style Default = 30 | Widget::Styles::Visible | 31 | Widget::Styles::Focusable | 32 | Style(BS_PUSHBUTTON, 0); 33 | }; 34 | 35 | Button(const String& text, Widget* parent, Style style = Styles::Default); 36 | Button(const String& text, CommandId id, Widget* parent, Style style = Styles::Default); 37 | explicit Button(HWND handle); 38 | virtual ~Button(); 39 | 40 | bool isDefault(); 41 | void setDefault(bool state); 42 | 43 | }; 44 | 45 | } // namespace vaca 46 | 47 | #endif // VACA_BUTTON_H 48 | -------------------------------------------------------------------------------- /vaca/Component.h: -------------------------------------------------------------------------------- 1 | // Vaca - Visual Application Components Abstraction 2 | // Copyright (c) 2005-2010 David Capello 3 | // 4 | // This file is distributed under the terms of the MIT license, 5 | // please read LICENSE.txt for more information. 6 | 7 | #ifndef VACA_COMPONENT_H 8 | #define VACA_COMPONENT_H 9 | 10 | #include "vaca/base.h" 11 | #include "vaca/Referenceable.h" 12 | #include 13 | 14 | namespace vaca { 15 | 16 | /** 17 | A component is a visual object, such as widgets or menus. 18 | 19 | Components are non-copyable but are referenceable (e.g. you can 20 | use them inside a SharedPtr). 21 | 22 | @see NonCopyable, Referenceable, SharedPtr 23 | */ 24 | class VACA_DLL Component : public Referenceable 25 | { 26 | public: 27 | typedef std::map Properties; 28 | 29 | Component(); 30 | virtual ~Component(); 31 | 32 | PropertyPtr getProperty(const String& name); 33 | void setProperty(PropertyPtr property); 34 | 35 | bool hasProperty(const String& name); 36 | void removeProperty(const String& name); 37 | 38 | const Properties& getProperties() const; 39 | 40 | private: 41 | Properties m_properties; 42 | }; 43 | 44 | } // namespace vaca 45 | 46 | #endif // VACA_COMPONENT_H 47 | -------------------------------------------------------------------------------- /vaca/win32/BrushImpl.h: -------------------------------------------------------------------------------- 1 | // Vaca - Visual Application Components Abstraction 2 | // Copyright (c) 2005-2010 David Capello 3 | // 4 | // This file is distributed under the terms of the MIT license, 5 | // please read LICENSE.txt for more information. 6 | 7 | #ifndef _WIN32_WINNT 8 | #define _WIN32_WINNT 0x0400 9 | #endif 10 | #define WIN32_LEAN_AND_MEAN 11 | #include 12 | 13 | #include "vaca/Color.h" 14 | #include "vaca/GdiObject.h" 15 | #include "vaca/win32.h" 16 | 17 | class vaca::Brush::BrushImpl : public GdiObject 18 | { 19 | public: 20 | 21 | BrushImpl() 22 | : GdiObject(CreateSolidBrush(RGB(0, 0, 0))) { 23 | } 24 | 25 | BrushImpl(const Color& color) 26 | : GdiObject(CreateSolidBrush(convert_to(color))) { 27 | } 28 | 29 | ~BrushImpl() { 30 | } 31 | 32 | Color getColor() const { 33 | LOGBRUSH lb; 34 | assert(getHandle()); 35 | ::GetObject(getHandle(), sizeof(LOGBRUSH), &lb); 36 | return convert_to(lb.lbColor); 37 | } 38 | 39 | }; 40 | 41 | template<> HBRUSH vaca::convert_to(const Brush& brush) 42 | { 43 | // 1) getHandle is defined in GdiObject class 44 | // 2) convert_to<> is friend of Brush class 45 | return brush.m_impl->getHandle(); 46 | } 47 | -------------------------------------------------------------------------------- /vaca/win32.h: -------------------------------------------------------------------------------- 1 | // Vaca - Visual Application Components Abstraction 2 | // Copyright (c) 2005-2010 David Capello 3 | // 4 | // This file is distributed under the terms of the MIT license, 5 | // please read LICENSE.txt for more information. 6 | 7 | #ifndef VACA_WIN32_H 8 | #define VACA_WIN32_H 9 | 10 | #include "vaca/base.h" 11 | 12 | #ifndef VACA_WINDOWS 13 | #error You cannot use this header file outside Windows platform. 14 | #endif 15 | 16 | #define WIN32_LEAN_AND_MEAN 17 | #include 18 | 19 | namespace vaca { 20 | 21 | template<> VACA_DLL POINT convert_to(const Point& pt); 22 | template<> VACA_DLL Point convert_to(const POINT& pt); 23 | template<> VACA_DLL Point convert_to(const POINTS& pt); 24 | template<> VACA_DLL SIZE convert_to(const Size& sz); 25 | template<> VACA_DLL Size convert_to(const SIZE& sz); 26 | template<> VACA_DLL RECT convert_to(const Rect& rc); 27 | template<> VACA_DLL Rect convert_to(const RECT& rc); 28 | 29 | template<> VACA_DLL COLORREF convert_to(const Color& color); 30 | template<> VACA_DLL Color convert_to(const COLORREF& colorref); 31 | 32 | template<> VACA_DLL HPEN convert_to(const Pen& pen); 33 | template<> VACA_DLL HBRUSH convert_to(const Brush& brush); 34 | 35 | } 36 | 37 | #endif // VACA_WIN32_H 38 | -------------------------------------------------------------------------------- /tests/test_size.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "vaca/Size.h" 4 | 5 | using namespace vaca; 6 | 7 | inline std::ostream& operator<<(std::ostream& os, const Size& sz) 8 | { 9 | return os << "Size(" << sz.w << ", " << sz.h << ")\n"; 10 | } 11 | 12 | TEST(Size, Basics) 13 | { 14 | Size s1; 15 | EXPECT_EQ(0, s1.w); 16 | EXPECT_EQ(0, s1.h); 17 | 18 | Size s2(32, 40); 19 | EXPECT_EQ(32, s2.w); 20 | EXPECT_EQ(40, s2.h); 21 | 22 | EXPECT_TRUE(s1 != s2); 23 | 24 | s1 = s2; 25 | EXPECT_TRUE(s1 == s2); 26 | 27 | s1 += s2; 28 | EXPECT_EQ(64, s1.w); 29 | EXPECT_EQ(80, s1.h); 30 | 31 | s1 /= 4; 32 | EXPECT_EQ(16, s1.w); 33 | EXPECT_EQ(20, s1.h); 34 | 35 | s1 += 4; 36 | EXPECT_EQ(20, s1.w); 37 | EXPECT_EQ(24, s1.h); 38 | 39 | s1 *= 2; 40 | EXPECT_EQ(40, s1.w); 41 | EXPECT_EQ(48, s1.h); 42 | 43 | s1 -= s2; 44 | EXPECT_EQ(8, s1.w); 45 | EXPECT_EQ(8, s1.h); 46 | } 47 | 48 | TEST(Size, Operators) 49 | { 50 | EXPECT_EQ(Size(-1, -3), -Size(1, 3)); 51 | 52 | EXPECT_EQ(Size(8, 4), Size(3, 3)+Size(5, 1)); 53 | EXPECT_EQ(Size(2, 1), Size(3, 2)-Size(1, 1)); 54 | } 55 | 56 | TEST(Size, UnionAndIntersection) 57 | { 58 | EXPECT_EQ(Size(4, 2), Size(1, 2).createUnion(Size(4, 1))); 59 | EXPECT_EQ(Size(1, 1), Size(1, 2).createIntersect(Size(4, 1))); 60 | } 61 | -------------------------------------------------------------------------------- /vaca/GroupBox.h: -------------------------------------------------------------------------------- 1 | // Vaca - Visual Application Components Abstraction 2 | // Copyright (c) 2005-2022 David Capello 3 | // 4 | // This file is distributed under the terms of the MIT license, 5 | // please read LICENSE.txt for more information. 6 | 7 | #ifndef VACA_GROUPBOX_H 8 | #define VACA_GROUPBOX_H 9 | 10 | #include "vaca/Widget.h" 11 | 12 | namespace vaca { 13 | 14 | /** 15 | An edge (with a label optionally) that can be used to group 16 | sub-widgets. 17 | */ 18 | class VACA_DLL GroupBox : public Widget 19 | { 20 | public: 21 | 22 | struct Styles { 23 | /** 24 | Default style for GroupBox widget. 25 | */ 26 | static constexpr Style Default = 27 | Widget::Styles::Visible | 28 | Widget::Styles::Container | 29 | Style(BS_GROUPBOX, 0); 30 | }; 31 | 32 | GroupBox(const String& text, Widget* parent, Style style = Styles::Default); 33 | virtual ~GroupBox(); 34 | 35 | Size getNonClientSize(); 36 | 37 | protected: 38 | 39 | // Events 40 | virtual void onPreferredSize(PreferredSizeEvent& ev); 41 | virtual void onLayout(LayoutEvent& ev); 42 | 43 | virtual bool wndProc(UINT message, WPARAM wParam, LPARAM lParam, LRESULT& lResult); 44 | 45 | }; 46 | 47 | } // namespace vaca 48 | 49 | #endif // VACA_GROUPBOX_H 50 | -------------------------------------------------------------------------------- /vaca/Brush.h: -------------------------------------------------------------------------------- 1 | // Vaca - Visual Application Components Abstraction 2 | // Copyright (c) 2005-2010 David Capello 3 | // 4 | // This file is distributed under the terms of the MIT license, 5 | // please read LICENSE.txt for more information. 6 | 7 | #ifndef VACA_BRUSH_H 8 | #define VACA_BRUSH_H 9 | 10 | #include "vaca/base.h" 11 | #include "vaca/SharedPtr.h" 12 | 13 | namespace vaca { 14 | 15 | /** 16 | A brush can be used to fill rectangles, ellipses, and paths. 17 | 18 | This is a SharedPtr, so if you copy instances of brushes they will be 19 | referencing to the same place. You can't clone brushes because you can't 20 | modify them. 21 | 22 | @win32 23 | This is a @msdn{HBRUSH} wrapper. 24 | @endwin32 25 | 26 | @see Graphics, Graphics#fillRect, Graphics#fillPath 27 | */ 28 | class VACA_DLL Brush 29 | { 30 | template 31 | friend To convert_to(const From& from); 32 | 33 | public: 34 | Brush(); 35 | Brush(const Brush& brush); 36 | explicit Brush(const Color& color); 37 | virtual ~Brush(); 38 | 39 | Brush& operator=(const Brush& brush); 40 | 41 | Color getColor() const; 42 | 43 | private: 44 | class BrushImpl; 45 | SharedPtr m_impl; 46 | }; 47 | 48 | } // namespace vaca 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /doc/pages/tn006.h: -------------------------------------------------------------------------------- 1 | namespace vaca { 2 | 3 | /** 4 | 5 | @page page_tn_006 TN006: Deleting a Widget inside its event 6 | 7 | @li @ref page_tn_006_problem 8 | @li @ref page_tn_006_solution 9 | @li @ref page_tn_006_example 10 | 11 | 12 | @section page_tn_006_problem The Problem 13 | 14 | There are a problem with signals: 15 | @warning YOU CAN'T DELETE A WIDGET INSIDE AN EVENT WHICH THE WIDGET BY 16 | ITSELF GENERATED. 17 | 18 | It means that if a widget's event is activated 19 | (e.g. Widget#onKeyDown), then you can't delete that widget in your own 20 | event handler (or a slot connected to the Widget#KeyDown signal). 21 | The widget must be deleted after the original message is processed 22 | (it is when the widget is not referenced anymore). 23 | 24 | @see @ref page_mess 25 | 26 | 27 | @section page_tn_006_solution The Solution 28 | 29 | The solution is simple: Use the #delete_widget function. 30 | 31 | @image html DeleteInEvent.png 32 | 33 | @see delete_widget 34 | 35 | 36 | @section page_tn_006_example An Example 37 | 38 | See the @ref page_examples_texteditor, it uses the #delete_widget to 39 | delete an #MdiChild when its close button is pushed by the user. I think 40 | that it's the only case where @ref delete_widget could be necessary to use. 41 | 42 | */ 43 | 44 | } 45 | -------------------------------------------------------------------------------- /tests/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Vaca - Visual Application Components Abstraction 2 | # Copyright (c) 2005-2010 David Capello 3 | # All rights reserved. 4 | 5 | # Fix to compile gtest with VC11 (2012) 6 | if (MSVC_VERSION EQUAL 1700) 7 | add_definitions(-D_VARIADIC_MAX=10) 8 | endif() 9 | 10 | include_directories(.) 11 | 12 | include(FetchContent) 13 | FetchContent_Declare( 14 | googletest 15 | URL https://github.com/google/googletest/archive/3655149a60ad7bfeb0902f7308b95dafa97a68ad.zip 16 | ) 17 | set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) 18 | FetchContent_MakeAvailable(googletest) 19 | 20 | function(add_vaca_test name) 21 | add_executable(${name} ${name}.cpp) 22 | 23 | set_target_properties(${name} PROPERTIES 24 | COMPILE_FLAGS "${common_flags}") 25 | 26 | target_link_libraries(${name} gtest_main vaca) 27 | 28 | add_test(NAME ${name} COMMAND ${name}) 29 | endfunction(add_vaca_test) 30 | 31 | add_vaca_test(test_handle) 32 | add_vaca_test(test_image) 33 | add_vaca_test(test_menu) 34 | add_vaca_test(test_pen) 35 | add_vaca_test(test_point) 36 | add_vaca_test(test_rect) 37 | add_vaca_test(test_region) 38 | add_vaca_test(test_sharedptr) 39 | add_vaca_test(test_signal) 40 | add_vaca_test(test_size) 41 | add_vaca_test(test_string) 42 | add_vaca_test(test_tab) 43 | add_vaca_test(test_thread) 44 | add_vaca_test(test_widget) 45 | -------------------------------------------------------------------------------- /vaca/FindFiles.cpp: -------------------------------------------------------------------------------- 1 | // Vaca - Visual Application Components Abstraction 2 | // Copyright (c) 2005-2010 David Capello 3 | // 4 | // This file is distributed under the terms of the MIT license, 5 | // please read LICENSE.txt for more information. 6 | 7 | #include "vaca/FindFiles.h" 8 | #include "vaca/String.h" 9 | 10 | using namespace vaca; 11 | 12 | FindFiles::FindFiles(const String& pattern) 13 | { 14 | m_pattern = pattern; 15 | m_handle = NULL; 16 | } 17 | 18 | FindFiles::~FindFiles() 19 | { 20 | if (m_handle) 21 | FindClose(m_handle); 22 | } 23 | 24 | bool FindFiles::next() 25 | { 26 | if (!m_handle) { 27 | m_handle = FindFirstFile(m_pattern.c_str(), &m_data); 28 | return m_handle ? true: false; 29 | } 30 | else { 31 | return FindNextFile(m_handle, &m_data) ? true: false; 32 | } 33 | } 34 | 35 | String FindFiles::getFileName() const 36 | { 37 | return m_data.cFileName; 38 | } 39 | 40 | String FindFiles::getFullFileName() const 41 | { 42 | return file_path(m_pattern) / m_data.cFileName; 43 | } 44 | 45 | bool FindFiles::isFile() const 46 | { 47 | return m_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ? false: true; 48 | } 49 | 50 | bool FindFiles::isDirectory() const 51 | { 52 | return m_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ? true: false; 53 | } 54 | -------------------------------------------------------------------------------- /doc/pages/tn005.h: -------------------------------------------------------------------------------- 1 | namespace vaca { 2 | 3 | /** 4 | 5 | @page page_tn_005 TN005: MdiChild limitations when construct it (Win32) 6 | 7 | Win32 makes visible all MdiChild when they are created. There are no 8 | way to fix this: Vaca uses @c CreateWindowEx with the @c WS_EX_MDICHILD 9 | style, also I tried to use @c WM_MDICREATE without passing @c WS_VISIBLE 10 | but has the same behaviour (I think that it's impossible to create a hidden 11 | MdiChild). 12 | 13 | Also, Windows ignores some other styles (for example: you can't 14 | create a MdiChild without the WS_MAXIMIZEBOX style). But is possible 15 | to change that styles after creation (using vaca::Widget::removeStyle or 16 | vaca::Widget::addStyle). 17 | 18 | Other problem is that because MdiChild is visible when it's 19 | constructed, we lost some messages (like WM_SETFOCUS, WM_MDIACTIVATE): They 20 | are passed directly to MdiChild#defWndProc (DefMDIChildProc finally). 21 | So MdiChild#wndProc can't hook these events, and the onFocusEnter() and 22 | onActivate() events aren't generated. 23 | 24 | To fix this, we repost various messages to the message queue using 25 | @msdn{PostMessage}: 26 | @li @c WM_SETFOCUS to generate Widget#onFocusEnter. 27 | @li @c WM_MDIACTIVATE to generate Frame#onActivate. 28 | @li @c WM_SIZE to generate Frame#onResize (and layout children). 29 | 30 | */ 31 | 32 | } 33 | -------------------------------------------------------------------------------- /vaca/BoxLayout.h: -------------------------------------------------------------------------------- 1 | // Vaca - Visual Application Components Abstraction 2 | // Copyright (c) 2005-2010 David Capello 3 | // 4 | // This file is distributed under the terms of the MIT license, 5 | // please read LICENSE.txt for more information. 6 | 7 | #ifndef VACA_BOXLAYOUT_H 8 | #define VACA_BOXLAYOUT_H 9 | 10 | #include "vaca/base.h" 11 | #include "vaca/Layout.h" 12 | 13 | namespace vaca { 14 | 15 | // ====================================================================== 16 | // BoxLayout 17 | 18 | class VACA_DLL BoxLayout : public Layout 19 | { 20 | Orientation m_orientation; 21 | bool m_homogeneous; 22 | int m_border; 23 | int m_childSpacing; 24 | 25 | public: 26 | 27 | BoxLayout(Orientation orientation, 28 | bool homogeneous, 29 | int borderSize = 4, 30 | int childSpacing = 4); 31 | 32 | bool isHorizontal(); 33 | bool isVertical(); 34 | 35 | bool isHomogeneous(); 36 | 37 | int getBorder(); 38 | void setBorder(int border); 39 | 40 | int getChildSpacing(); 41 | void setChildSpacing(int childSpacing); 42 | 43 | virtual Size getPreferredSize(Widget* parent, WidgetList& widgets, const Size& fitIn); 44 | 45 | protected: 46 | 47 | virtual void layout(Widget* parent, WidgetList& widgets, const Rect& rc); 48 | 49 | }; 50 | 51 | } // namespace vaca 52 | 53 | #endif // VACA_BOXLAYOUT_H 54 | -------------------------------------------------------------------------------- /vaca/ColorDialog.cpp: -------------------------------------------------------------------------------- 1 | // Vaca - Visual Application Components Abstraction 2 | // Copyright (c) 2005-2010 David Capello 3 | // 4 | // This file is distributed under the terms of the MIT license, 5 | // please read LICENSE.txt for more information. 6 | 7 | #include "vaca/ColorDialog.h" 8 | #include "vaca/Application.h" 9 | #include "vaca/win32.h" 10 | 11 | using namespace vaca; 12 | 13 | ColorDialog::ColorDialog(const Color& color, Widget* parent) 14 | : CommonDialog(parent) 15 | , m_color(color) 16 | { 17 | for (int i=0; i<16; ++i) 18 | m_customColors[i] = RGB(255, 255, 255); 19 | } 20 | 21 | ColorDialog::~ColorDialog() 22 | { 23 | } 24 | 25 | bool ColorDialog::doModal() 26 | { 27 | CHOOSECOLOR cc; 28 | 29 | cc.lStructSize = sizeof(CHOOSECOLOR); 30 | cc.hwndOwner = getParentHandle(); 31 | cc.hInstance = NULL; 32 | cc.rgbResult = convert_to(m_color); 33 | cc.lpCustColors = m_customColors; 34 | cc.Flags = 0 35 | | CC_ANYCOLOR 36 | | CC_FULLOPEN 37 | | CC_RGBINIT 38 | | CC_SOLIDCOLOR 39 | ; 40 | // cc.lCustData; 41 | // cc.lpfnHook; 42 | // cc.lpTemplateName; 43 | 44 | if (ChooseColor(&cc)) { 45 | m_color = convert_to(cc.rgbResult); 46 | return true; 47 | } 48 | else 49 | return false; 50 | } 51 | 52 | Color ColorDialog::getColor() const 53 | { 54 | return m_color; 55 | } 56 | -------------------------------------------------------------------------------- /vaca/TimePoint.cpp: -------------------------------------------------------------------------------- 1 | // Vaca - Visual Application Components Abstraction 2 | // Copyright (c) 2005-2010 David Capello 3 | // 4 | // This file is distributed under the terms of the MIT license, 5 | // please read LICENSE.txt for more information. 6 | 7 | #include "vaca/TimePoint.h" 8 | 9 | using namespace vaca; 10 | 11 | /** 12 | Creates a new TimePoint starting the chronometer from this point. 13 | 14 | @see #elapsed 15 | */ 16 | TimePoint::TimePoint() 17 | { 18 | QueryPerformanceFrequency(&m_freq); 19 | reset(); 20 | } 21 | 22 | /** 23 | Destroys the TimePoint. 24 | */ 25 | TimePoint::~TimePoint() 26 | { 27 | } 28 | 29 | /** 30 | Resets the chronometer. 31 | 32 | Next calls to #elapsed will return the time elapsed from the 33 | last call of #reset. 34 | 35 | @see #elapsed 36 | */ 37 | void TimePoint::reset() 38 | { 39 | QueryPerformanceCounter(&m_point); 40 | } 41 | 42 | /** 43 | Returns the life-time in seconds of this object. 44 | 45 | The life-time is the elapsed time from the construction of the 46 | object (or from the last call to #reset member function). 47 | 48 | @see reset 49 | */ 50 | double TimePoint::elapsed() const 51 | { 52 | LARGE_INTEGER now; 53 | QueryPerformanceCounter(&now); 54 | return static_cast(now.QuadPart - m_point.QuadPart) 55 | / static_cast(m_freq.QuadPart); 56 | } 57 | -------------------------------------------------------------------------------- /doc/pages/license.h: -------------------------------------------------------------------------------- 1 | namespace vaca { 2 | 3 | /** 4 | 5 | @page page_license License 6 | 7 | Vaca is licensed under the terms of the MIT license. 8 | 9 |
10 | 11 | Vaca - Visual Application Components Abstraction @n 12 | Copyright (c) 2005-2011 David Capello 13 | 14 | Permission is hereby granted, free of charge, to any person obtaining 15 | a copy of this software and associated documentation files (the 16 | "Software"), to deal in the Software without restriction, including 17 | without limitation the rights to use, copy, modify, merge, publish, 18 | distribute, sublicense, and/or sell copies of the Software, and to 19 | permit persons to whom the Software is furnished to do so, subject to 20 | the following conditions: 21 | 22 | The above copyright notice and this permission notice shall be 23 | included in all copies or substantial portions of the Software. 24 | 25 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 26 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 27 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 28 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 29 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 30 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 31 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 32 | 33 | */ 34 | 35 | } 36 | -------------------------------------------------------------------------------- /vaca/ListColumn.h: -------------------------------------------------------------------------------- 1 | // Vaca - Visual Application Components Abstraction 2 | // Copyright (c) 2005-2010 David Capello 3 | // 4 | // This file is distributed under the terms of the MIT license, 5 | // please read LICENSE.txt for more information. 6 | 7 | #ifndef VACA_LISTCOLUMN_H 8 | #define VACA_LISTCOLUMN_H 9 | 10 | #include "vaca/base.h" 11 | #include "vaca/Component.h" 12 | 13 | namespace vaca { 14 | 15 | /** 16 | A column in a ListView. 17 | */ 18 | class VACA_DLL ListColumn : public Component 19 | { 20 | friend class ListView; 21 | 22 | int m_index; 23 | String m_text; 24 | TextAlign m_textAlign; 25 | int m_width; 26 | ListView* m_owner; 27 | 28 | public: 29 | 30 | ListColumn(const String& text, TextAlign textAlign = TextAlign::Left); 31 | virtual ~ListColumn(); 32 | 33 | ListView* getListView(); 34 | 35 | String getText() const; 36 | void setText(const String& text); 37 | 38 | TextAlign getTextAlign() const; 39 | void setTextAlign(TextAlign textAlign); 40 | 41 | int getWidth() const; 42 | void setWidth(int width); 43 | void setPreferredWidth(bool useHeader = true); 44 | 45 | Rect getBounds() const; 46 | 47 | // int getIndex() const; 48 | // static ListColumn* fromIndex(HWND hwnd, int index); 49 | 50 | private: 51 | void addToListView(ListView* listView); 52 | void removeFromListView(); 53 | 54 | }; 55 | 56 | } // namespace vaca 57 | 58 | #endif // VACA_LISTCOLUMN_H 59 | -------------------------------------------------------------------------------- /vaca/BasicDockArea.h: -------------------------------------------------------------------------------- 1 | // Vaca - Visual Application Components Abstraction 2 | // Copyright (c) 2005-2022 David Capello 3 | // 4 | // This file is distributed under the terms of the MIT license, 5 | // please read LICENSE.txt for more information. 6 | 7 | #ifndef VACA_BASICDOCKAREA_H 8 | #define VACA_BASICDOCKAREA_H 9 | 10 | #include "vaca/base.h" 11 | #include "vaca/DockArea.h" 12 | 13 | namespace vaca { 14 | 15 | /** 16 | The most basic dock area management. 17 | */ 18 | class VACA_DLL BasicDockArea : public DockArea 19 | { 20 | public: 21 | 22 | struct Styles { 23 | /** 24 | Default style for BasicDockArea widget. 25 | */ 26 | static constexpr Style Default = Widget::Styles::Visible; 27 | }; 28 | 29 | BasicDockArea(Side side, Widget* parent, Style style = Styles::Default); 30 | virtual ~BasicDockArea(); 31 | 32 | virtual bool hitTest(DockBar* bar, const Point& cursor, const Point& anchor, bool fromInside); 33 | virtual DockInfo* createDefaultDockInfo(DockBar* bar); 34 | virtual DockInfo* createDockInfo(DockBar* bar, const Point& cursor, const Point& anchor); 35 | virtual void drawXorTracker(Graphics& g, DockInfo* dockInfo); 36 | 37 | virtual void layout(); 38 | 39 | protected: 40 | // Events 41 | virtual void onPreferredSize(PreferredSizeEvent& ev); 42 | 43 | }; 44 | 45 | } // namespace vaca 46 | 47 | #endif // VACA_BASICDOCKAREA_H 48 | -------------------------------------------------------------------------------- /vaca/CustomLabel.h: -------------------------------------------------------------------------------- 1 | // Vaca - Visual Application Components Abstraction 2 | // Copyright (c) 2005-2022 David Capello 3 | // 4 | // This file is distributed under the terms of the MIT license, 5 | // please read LICENSE.txt for more information. 6 | 7 | #ifndef VACA_CUSTOMLABEL_H 8 | #define VACA_CUSTOMLABEL_H 9 | 10 | #include "vaca/base.h" 11 | #include "vaca/Label.h" 12 | 13 | namespace vaca { 14 | 15 | /** 16 | Customized static label control. 17 | */ 18 | class VACA_DLL CustomLabel : public Label 19 | { 20 | // SS_OWNERDRAW has the bit 1, so we can't use the 21 | // SS_CENTER/SS_RIGHT to known the text-alignment. We must to hold 22 | // on in some place. 23 | TextAlign m_textAlign; 24 | 25 | public: 26 | 27 | struct Styles { 28 | /** 29 | Default style for CustomLabel. 30 | */ 31 | static constexpr Style Default = 32 | Label::Styles::Default | 33 | Style(SS_OWNERDRAW, 0); 34 | }; 35 | 36 | CustomLabel(const String& text, Widget* parent, Style style = Styles::Default); 37 | virtual ~CustomLabel(); 38 | 39 | virtual TextAlign getTextAlign() const; 40 | virtual void setTextAlign(TextAlign align); 41 | 42 | protected: 43 | 44 | // Reflected notifications 45 | virtual bool onReflectedDrawItem(Graphics& g, LPDRAWITEMSTRUCT lpDrawItem); 46 | 47 | }; 48 | 49 | } // namespace vaca 50 | 51 | #endif // VACA_CUSTOMLABEL_H 52 | -------------------------------------------------------------------------------- /vaca/ListItem.h: -------------------------------------------------------------------------------- 1 | // Vaca - Visual Application Components Abstraction 2 | // Copyright (c) 2005-2010 David Capello 3 | // 4 | // This file is distributed under the terms of the MIT license, 5 | // please read LICENSE.txt for more information. 6 | 7 | #ifndef VACA_LISTITEM_H 8 | #define VACA_LISTITEM_H 9 | 10 | #include "vaca/base.h" 11 | #include "vaca/Component.h" 12 | 13 | #include 14 | 15 | namespace vaca { 16 | 17 | /** 18 | An item in a ListView. 19 | */ 20 | class VACA_DLL ListItem : public Component 21 | { 22 | friend class ListView; 23 | 24 | int m_index; 25 | std::vector m_text; 26 | int m_image; 27 | ListView* m_owner; 28 | 29 | public: 30 | 31 | ListItem(const String& text = L"", int imageIndex = -1); 32 | virtual ~ListItem(); 33 | 34 | ListView* getListView(); 35 | int getIndex(); 36 | Rect getBounds() const; 37 | 38 | virtual String getText(size_t columnIndex = 0); 39 | virtual int getImage(); 40 | 41 | void setText(const String& text, size_t columnIndex = 0); 42 | void setImage(int image); 43 | 44 | void update(); 45 | 46 | bool isSelected() const; 47 | void setSelected(bool state); 48 | 49 | void ensureVisible(); 50 | 51 | private: 52 | void addToListView(ListView* listView); 53 | void removeFromListView(); 54 | 55 | }; 56 | 57 | } // namespace vaca 58 | 59 | #endif // VACA_LISTITEM_H 60 | -------------------------------------------------------------------------------- /vaca/Point.h: -------------------------------------------------------------------------------- 1 | // Vaca - Visual Application Components Abstraction 2 | // Copyright (c) 2005-2010 David Capello 3 | // 4 | // This file is distributed under the terms of the MIT license, 5 | // please read LICENSE.txt for more information. 6 | 7 | #ifndef VACA_POINT_H 8 | #define VACA_POINT_H 9 | 10 | #include "vaca/base.h" 11 | 12 | namespace vaca { 13 | 14 | /** 15 | A 2D coordinate in the screen or client area of a widget. 16 | */ 17 | class VACA_DLL Point 18 | { 19 | public: 20 | 21 | int x, y; 22 | 23 | Point(); 24 | Point(int x, int y); 25 | Point(const Point& point); 26 | explicit Point(const Size& size); 27 | 28 | const Point& operator=(const Point& pt); 29 | const Point& operator+=(const Point& pt); 30 | const Point& operator-=(const Point& pt); 31 | const Point& operator+=(int value); 32 | const Point& operator-=(int value); 33 | const Point& operator*=(int value); 34 | const Point& operator/=(int value); 35 | Point operator+(const Point& pt) const; 36 | Point operator-(const Point& pt) const; 37 | Point operator+(int value) const; 38 | Point operator-(int value) const; 39 | Point operator*(int value) const; 40 | Point operator/(int value) const; 41 | Point operator-() const; 42 | 43 | bool operator==(const Point& pt) const; 44 | bool operator!=(const Point& pt) const; 45 | 46 | }; 47 | 48 | } // namespace vaca 49 | 50 | #endif // VACA_POINT_H 51 | -------------------------------------------------------------------------------- /doc/pages/tn012.h: -------------------------------------------------------------------------------- 1 | namespace vaca { 2 | 3 | /** 4 | 5 | @page page_tn_012 TN012: Using Parent's Signals in Children's Constructors 6 | 7 | You can't use signals that aren't constructed. This piece of code has 8 | a bug: 9 | 10 | @code 11 | class Frm; 12 | 13 | class But : public Button 14 | { 15 | public: 16 | But(Frm* parent); 17 | private: 18 | void onSig(); 19 | }; 20 | 21 | class Frm : public Frame 22 | { 23 | But but; 24 | public: 25 | Frm(); 26 | Signal Sig; 27 | }; 28 | 29 | But::But(Frm* parent) : Button("...", parent) 30 | { 31 | // here we are using "Sig", but it isn't constructed yet! 32 | parent->Sig.connect(&But::onSig, this); 33 | } 34 | 35 | void But::onSig() { } 36 | 37 | Frm::Frm() : Frame("..."), but(this) 38 | { 39 | } 40 | @endcode 41 | 42 | Here you can't use @c Frm::Sig in @c But::But constructor because the signal 43 | isn't constructed yet. You have some options: 44 | 45 | 1) Put all Widget members after signals: 46 | @code 47 | class Frm : public Frame 48 | { 49 | public: 50 | Frm(); 51 | Signal Sig; 52 | private: 53 | But but; 54 | }; 55 | @endcode 56 | 57 | 2) Construct the Widget after the signal is created: 58 | @code 59 | class Frm : public Frame 60 | { 61 | std::unique_ptr but; 62 | public: 63 | Frm(); 64 | Signal Sig; 65 | }; 66 | ... 67 | Frm::Frm() : Frame("...") 68 | { 69 | but = std::make_unique(this); 70 | } 71 | @endcode 72 | 73 | */ 74 | 75 | } 76 | -------------------------------------------------------------------------------- /AUTHORS.txt: -------------------------------------------------------------------------------- 1 | ---------------------------------------------------------------------- 2 | DEVELOPERS 3 | ---------------------------------------------------------------------- 4 | 5 | David Capello 6 | Main developer, maintainer. 7 | 8 | Jie Zhang 9 | Contributed SplitBar and ReBar classes (with examples). 10 | 11 | 12 | ---------------------------------------------------------------------- 13 | THANKS TO 14 | ---------------------------------------------------------------------- 15 | 16 | Thanks for comments, feedback, bug reports to: 17 | Emil Kirichev 18 | Przemyslaw Szurmak 19 | 20 | J Brown 21 | His site http://www.catch22.net has some good Windows tricks. 22 | 23 | William E. Kempf 24 | For his work in the Boost.Threads library and the ConditionVariable class. 25 | 26 | Developers of: 27 | Adobe Open Source http://opensource.adobe.com/ 28 | Boost http://www.boost.org/ 29 | Doxygen http://www.doxygen.org/ 30 | GCC http://gcc.gnu.org/ 31 | GTK+ http://www.gtk.org/ 32 | MinGW http://www.mingw.org/ 33 | Scintilla http://www.scintilla.org/ 34 | Wine http://www.winehq.com/ 35 | wxWidgets http://www.wxwidgets.org/ 36 | 37 | ---------------------------------------------------------------------- 38 | -------------------------------------------------------------------------------- /vaca/Size.h: -------------------------------------------------------------------------------- 1 | // Vaca - Visual Application Components Abstraction 2 | // Copyright (c) 2005-2010 David Capello 3 | // 4 | // This file is distributed under the terms of the MIT license, 5 | // please read LICENSE.txt for more information. 6 | 7 | #ifndef VACA_SIZE_H 8 | #define VACA_SIZE_H 9 | 10 | #include "vaca/base.h" 11 | 12 | namespace vaca { 13 | 14 | /** 15 | A 2D size. 16 | */ 17 | class VACA_DLL Size 18 | { 19 | public: 20 | 21 | int w, h; 22 | 23 | Size(); 24 | Size(int w, int h); 25 | Size(const Size& size); 26 | explicit Size(const Point& point); 27 | 28 | Size createUnion(const Size& sz) const; 29 | Size createIntersect(const Size& sz) const; 30 | 31 | const Size& operator=(const Size& sz); 32 | const Size& operator+=(const Size& sz); 33 | const Size& operator-=(const Size& sz); 34 | const Size& operator+=(int value); 35 | const Size& operator-=(int value); 36 | const Size& operator*=(int value); 37 | const Size& operator/=(int value); 38 | Size operator+(const Size& sz) const; 39 | Size operator-(const Size& sz) const; 40 | Size operator+(int value) const; 41 | Size operator-(int value) const; 42 | Size operator*(int value) const; 43 | Size operator/(int value) const; 44 | Size operator-() const; 45 | 46 | bool operator==(const Size& sz) const; 47 | bool operator!=(const Size& sz) const; 48 | 49 | }; 50 | 51 | } // namespace vaca 52 | 53 | #endif // VACA_SIZE_H 54 | -------------------------------------------------------------------------------- /vaca/ClientLayout.cpp: -------------------------------------------------------------------------------- 1 | // Vaca - Visual Application Components Abstraction 2 | // Copyright (c) 2005-2010 David Capello 3 | // 4 | // This file is distributed under the terms of the MIT license, 5 | // please read LICENSE.txt for more information. 6 | 7 | #include "vaca/ClientLayout.h" 8 | #include "vaca/Widget.h" 9 | 10 | using namespace vaca; 11 | 12 | ClientLayout::ClientLayout() 13 | { 14 | m_border = 0; 15 | } 16 | 17 | ClientLayout::ClientLayout(int border) 18 | { 19 | m_border = border; 20 | } 21 | 22 | ClientLayout::~ClientLayout() 23 | { 24 | } 25 | 26 | Size ClientLayout::getPreferredSize(Widget* parent, WidgetList& widgets, const Size& fitIn) 27 | { 28 | Size sz(0, 0); 29 | 30 | for (WidgetList::iterator it=widgets.begin(); it!=widgets.end(); ++it) { 31 | Widget* widget = *it; 32 | if (!widget->isLayoutFree()) { 33 | Size pref = widget->getPreferredSize(fitIn); 34 | if (sz.w < pref.w) sz.w = pref.w; 35 | if (sz.h < pref.h) sz.h = pref.h; 36 | } 37 | } 38 | 39 | return sz + m_border; 40 | } 41 | 42 | void ClientLayout::layout(Widget* parent, WidgetList& widgets, const Rect& rc) 43 | { 44 | Rect bounds = rc; 45 | bounds.shrink(m_border); 46 | WidgetsMovement movement(widgets); 47 | 48 | for (WidgetList::iterator it=widgets.begin(); it!=widgets.end(); ++it) { 49 | Widget* widget = *it; 50 | if (!widget->isLayoutFree()) 51 | movement.moveWidget(widget, bounds); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /doc/pages/hacking.h: -------------------------------------------------------------------------------- 1 | namespace vaca { 2 | 3 | /** 4 | 5 | @page page_hacking Hacking Vaca 6 | 7 | @li @ref page_hacking_files 8 | @li @ref page_hacking_coding_standards 9 | 10 | 11 | @section page_hacking_files Files 12 | 13 | @section page_hacking_coding_standards Coding Standards 14 | 15 | Editor configuration: 16 | @code 17 | Indent: 2 spaces (use 1 tab to replace 8 spaces) 18 | Tab size: 8 spaces 19 | @endcode 20 | 21 | Function definition: 22 | @code 23 | int function_name(int arg1, int arg2, const char* arg3, double arg4, ...) 24 | { 25 | statements... 26 | return 0; 27 | } 28 | @endcode 29 | 30 | Function definition (alternative) 31 | @code 32 | int function_name(int arg1, int arg2, 33 | const char* arg3, 34 | double arg4, ...) 35 | { 36 | statements... 37 | return 0; 38 | } 39 | @endcode 40 | 41 | Flow control structures: 42 | @code 43 | if (condition) { 44 | statements... 45 | } 46 | 47 | for (int c=0; c<10; ++c) { 48 | statements... 49 | } 50 | 51 | for (std::vector::iterator 52 | it=container.begin(); it!=container.end(); ++it) { 53 | statements... 54 | } 55 | 56 | while (condition) { 57 | statements... 58 | } 59 | 60 | switch (condition) { 61 | case 0: 62 | statements... 63 | break; 64 | case 1: { 65 | definitions... 66 | statements... 67 | break; 68 | } 69 | default: 70 | statements... 71 | break; 72 | } 73 | @endcode 74 | 75 | */ 76 | 77 | } 78 | 79 | -------------------------------------------------------------------------------- /vaca/Message.h: -------------------------------------------------------------------------------- 1 | // Vaca - Visual Application Components Abstraction 2 | // Copyright (c) 2005-2010 David Capello 3 | // 4 | // This file is distributed under the terms of the MIT license, 5 | // please read LICENSE.txt for more information. 6 | 7 | #ifndef VACA_MESSAGE_H 8 | #define VACA_MESSAGE_H 9 | 10 | #include "vaca/base.h" 11 | #include "vaca/NonCopyable.h" 12 | #include "vaca/Exception.h" 13 | 14 | namespace vaca { 15 | 16 | /** 17 | Thrown when a Message cannot be registered/created. 18 | */ 19 | class MessageException : public Exception 20 | { 21 | public: 22 | 23 | MessageException() { } 24 | MessageException(const String& message) : Exception(message) { } 25 | virtual ~MessageException() throw() { } 26 | 27 | }; 28 | 29 | /** 30 | A message that comes from the operating system. 31 | 32 | @win32 33 | This is a wrapper for a @msdn{MSG}. 34 | @endwin32 35 | */ 36 | class VACA_DLL Message 37 | { 38 | friend class Thread; 39 | friend class Widget; 40 | 41 | MSG m_msg; 42 | 43 | public: 44 | 45 | Message(); 46 | Message(const String& name); 47 | Message(const Message& msg, void* payload); 48 | virtual ~Message(); 49 | 50 | void* getPayload(); 51 | 52 | inline bool operator==(const Message& message) const { 53 | return m_msg.message == message.m_msg.message; 54 | } 55 | 56 | inline operator MSG*() { return &m_msg; } 57 | inline operator MSG const *() const { return &m_msg; } 58 | 59 | }; 60 | 61 | } // namespace vaca 62 | 63 | #endif // VACA_MESSAGE_H 64 | -------------------------------------------------------------------------------- /tests/test_widget.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "vaca/vaca.h" 4 | 5 | using namespace vaca; 6 | 7 | template 8 | void test_basic() 9 | { 10 | // create with default style 11 | { 12 | Frame parent(L"title"); 13 | T a(L"caption", &parent); 14 | T b(L"caption", &parent, T::Styles::Default); 15 | 16 | EXPECT_TRUE(a.getParent() == &parent); 17 | EXPECT_TRUE(b.getParent() == &parent); 18 | EXPECT_TRUE(a.getStyle() == b.getStyle()); 19 | EXPECT_EQ(0, a.getId()); 20 | EXPECT_EQ(0, b.getId()); 21 | 22 | // check if get/setText work 23 | a.setText(L"bbb"); 24 | EXPECT_EQ(L"bbb", a.getText()); 25 | 26 | // check if get/setId work 27 | a.setId(32); 28 | b.setId(33); 29 | EXPECT_EQ(32, a.getId()); 30 | EXPECT_EQ(33, b.getId()); 31 | } 32 | 33 | // create without parent 34 | { 35 | T a(L"caption", NULL, T::Styles::Default - Widget::Styles::Visible); 36 | EXPECT_EQ(L"caption", a.getText()); 37 | EXPECT_EQ(NULL, a.getParent()); 38 | } 39 | } 40 | 41 | TEST(Widget, BasicBehavior) 42 | { 43 | Application app; 44 | test_basic