├── changelog.md ├── docs ├── autolayout.html ├── images │ ├── screenshot.png │ ├── wButton.png │ ├── wCalendarCtrl.png │ ├── wCheckBox.png │ ├── wCheckComboBox.png │ ├── wComboBox.png │ ├── wDatePickerCtrl.png │ ├── wGauge.png │ ├── wHotkeyCtrl.png │ ├── wHyperLinkCtrl.png │ ├── wIpCtrl.png │ ├── wListBox.png │ ├── wListCtrl.png │ ├── wNoteBook.png │ ├── wRadioButton.png │ ├── wScrollBar.png │ ├── wSlider.png │ ├── wSpinButton.png │ ├── wSpinCtrl.png │ ├── wSplitter.png │ ├── wStaticBitmap.png │ ├── wStaticBox.png │ ├── wStaticLine.png │ ├── wStaticText.png │ ├── wTextCtrl.png │ ├── wTimePickerCtrl.png │ ├── wTreeCtrl.png │ └── wWebView.png ├── index.html ├── nimdoc.out.css ├── pragma.html ├── wAcceleratorTable.html ├── wApp.html ├── wBitmap.html ├── wBrush.html ├── wButton.html ├── wCalendarCtrl.html ├── wCheckBox.html ├── wCheckComboBox.html ├── wClientDC.html ├── wColorDialog.html ├── wColors.html ├── wComboBox.html ├── wCommandEvent.html ├── wContextMenuEvent.html ├── wControl.html ├── wCursor.html ├── wDC.html ├── wDataObject.html ├── wDatePickerCtrl.html ├── wDialog.html ├── wDialogEvent.html ├── wDirDialog.html ├── wDragDropEvent.html ├── wEvent.html ├── wFileDialog.html ├── wFindReplaceDialog.html ├── wFont.html ├── wFontDialog.html ├── wFrame.html ├── wGauge.html ├── wGdiObject.html ├── wHotkeyCtrl.html ├── wHyperLinkEvent.html ├── wHyperlinkCtrl.html ├── wIcon.html ├── wIconImage.html ├── wImage.html ├── wImageList.html ├── wIpCtrl.html ├── wIpEvent.html ├── wKeyCodes.html ├── wKeyEvent.html ├── wListBox.html ├── wListCtrl.html ├── wListEvent.html ├── wMacros.html ├── wMemoryDC.html ├── wMenu.html ├── wMenuBar.html ├── wMenuBarCtrl.html ├── wMenuBase.html ├── wMenuItem.html ├── wMessageDialog.html ├── wMouseEvent.html ├── wMoveEvent.html ├── wNavigationEvent.html ├── wNim.html ├── wNoteBook.html ├── wPageSetupDialog.html ├── wPaintDC.html ├── wPanel.html ├── wPasswordEntryDialog.html ├── wPen.html ├── wPrintData.html ├── wPrintDialog.html ├── wPrinterDC.html ├── wRadioButton.html ├── wRebar.html ├── wRegion.html ├── wResizable.html ├── wResizer.html ├── wScreenDC.html ├── wScrollBar.html ├── wScrollEvent.html ├── wScrollWinEvent.html ├── wSetCursorEvent.html ├── wSizeEvent.html ├── wSlider.html ├── wSpinButton.html ├── wSpinCtrl.html ├── wSpinEvent.html ├── wSplitter.html ├── wStaticBitmap.html ├── wStaticBox.html ├── wStaticLine.html ├── wStaticText.html ├── wStatusBar.html ├── wStatusBarEvent.html ├── wTextCtrl.html ├── wTextEntryDialog.html ├── wTextLinkEvent.html ├── wTimePickerCtrl.html ├── wToolBar.html ├── wToolTip.html ├── wTrayEvent.html ├── wTreeCtrl.html ├── wTreeEvent.html ├── wTypes.html ├── wUtils.html ├── wWebView.html ├── wWebViewEvent.html ├── wWindow.html └── wWindowDC.html ├── examples ├── autolayoutEditor.nim ├── calendar.nim ├── colors.nim ├── config.nims ├── customdialog.nim ├── demo.nim ├── dialog.nim ├── dragdrop.nim ├── draggable.nim ├── frame.nim ├── helloworld.nim ├── html │ ├── about.html │ ├── demo.html │ └── style.css ├── images │ ├── 1.png │ ├── 2.png │ ├── 3.png │ ├── 4.png │ ├── 5.png │ ├── 6.png │ ├── black.png │ ├── board1.png │ ├── board2.png │ ├── cancel.ico │ ├── logo.png │ ├── nim.png │ ├── o.png │ ├── ok.ico │ ├── pen.png │ ├── wNim.ico │ ├── white.png │ └── x.png ├── layout1.nim ├── layout2.nim ├── layout3.nim ├── mcts │ ├── engine_nim.nim │ ├── engine_reversi.nim │ ├── engine_tictactoe.nim │ ├── gamebase.nim │ └── mcts.nim ├── menu.nim ├── nonsubclassing.nim ├── pickicondialog.nim ├── printpreview.nim ├── rebar.nim ├── resource │ ├── build.cmd │ ├── resource.nim │ ├── resource2.nim │ ├── wNim.manifest │ ├── wNim.rc │ ├── wNim32.res │ ├── wNim64.res │ ├── wNimTcc.rc │ ├── wNimTcc32.res │ ├── wNimTcc64.res │ ├── wNimVcc.res │ ├── wWebView.rc │ ├── wWebView32.res │ ├── wWebView64.res │ ├── wWebViewTcc.rc │ ├── wWebViewTcc32.res │ ├── wWebViewTcc64.res │ └── wWebViewVcc.res ├── reversi.nim ├── reversi.nims ├── scribble.nim ├── shapewin.nim ├── subclassing.nim ├── textctrl.nim ├── tictactoe.nim ├── tictactoe.nims ├── toolbar.nim ├── wHyperlink.nim ├── webView.nim └── winsdk.nim ├── license.txt ├── readme.md ├── wNim.nim ├── wNim ├── autolayout.nim ├── private │ ├── autolayout.nim │ ├── consts │ │ ├── wColors.nim │ │ └── wKeyCodes.nim │ ├── controls │ │ ├── wButton.nim │ │ ├── wCalendarCtrl.nim │ │ ├── wCheckBox.nim │ │ ├── wCheckComboBox.nim │ │ ├── wComboBox.nim │ │ ├── wControl.nim │ │ ├── wDatePickerCtrl.nim │ │ ├── wGauge.nim │ │ ├── wHotkeyCtrl.nim │ │ ├── wHyperlinkCtrl.nim │ │ ├── wIpCtrl.nim │ │ ├── wListBox.nim │ │ ├── wListCtrl.nim │ │ ├── wMenuBarCtrl.nim │ │ ├── wNoteBook.nim │ │ ├── wRadioButton.nim │ │ ├── wRebar.nim │ │ ├── wScrollBar.nim │ │ ├── wSlider.nim │ │ ├── wSpinButton.nim │ │ ├── wSpinCtrl.nim │ │ ├── wSplitter.nim │ │ ├── wStaticBitmap.nim │ │ ├── wStaticBox.nim │ │ ├── wStaticLine.nim │ │ ├── wStaticText.nim │ │ ├── wStatusBar.nim │ │ ├── wTextCtrl.nim │ │ ├── wTimePickerCtrl.nim │ │ ├── wToolBar.nim │ │ ├── wTreeCtrl.nim │ │ └── wWebView.nim │ ├── dc │ │ ├── wClientDC.nim │ │ ├── wDC.nim │ │ ├── wMemoryDC.nim │ │ ├── wPaintDC.nim │ │ ├── wPrinterDC.nim │ │ ├── wScreenDC.nim │ │ └── wWindowDC.nim │ ├── dialogs │ │ ├── wColorDialog.nim │ │ ├── wDialog.nim │ │ ├── wDirDialog.nim │ │ ├── wFileDialog.nim │ │ ├── wFindReplaceDialog.nim │ │ ├── wFontDialog.nim │ │ ├── wMessageDialog.nim │ │ ├── wPageSetupDialog.nim │ │ ├── wPasswordEntryDialog.nim │ │ ├── wPrintDialog.nim │ │ └── wTextEntryDialog.nim │ ├── events │ │ ├── wCommandEvent.nim │ │ ├── wContextMenuEvent.nim │ │ ├── wDialogEvent.nim │ │ ├── wDragDropEvent.nim │ │ ├── wHyperlinkEvent.nim │ │ ├── wIpEvent.nim │ │ ├── wKeyEvent.nim │ │ ├── wListEvent.nim │ │ ├── wMouseEvent.nim │ │ ├── wMoveEvent.nim │ │ ├── wNavigationEvent.nim │ │ ├── wScrollEvent.nim │ │ ├── wScrollWinEvent.nim │ │ ├── wSetCursorEvent.nim │ │ ├── wSizeEvent.nim │ │ ├── wSpinEvent.nim │ │ ├── wStatusBarEvent.nim │ │ ├── wTextLinkEvent.nim │ │ ├── wTrayEvent.nim │ │ ├── wTreeEvent.nim │ │ └── wWebViewEvent.nim │ ├── gdiobjects │ │ ├── wBitmap.nim │ │ ├── wBrush.nim │ │ ├── wCursor.nim │ │ ├── wFont.nim │ │ ├── wGdiObject.nim │ │ ├── wIcon.nim │ │ ├── wPen.nim │ │ └── wRegion.nim │ ├── kiwi │ │ ├── constraint.nim │ │ ├── expression.nim │ │ ├── kiwi.nim │ │ ├── row.nim │ │ ├── solver.nim │ │ ├── strength.nim │ │ ├── symbol.nim │ │ ├── symbolicints.nim │ │ ├── symbolics.nim │ │ ├── term.nim │ │ ├── util.nim │ │ └── variable.nim │ ├── menu │ │ ├── wMenu.nim │ │ ├── wMenuBar.nim │ │ ├── wMenuBase.nim │ │ └── wMenuItem.nim │ ├── nimpack.nim │ ├── pragma.nim │ ├── wAcceleratorTable.nim │ ├── wApp.nim │ ├── wBase.nim │ ├── wDataObject.nim │ ├── wEvent.nim │ ├── wFrame.nim │ ├── wHelper.nim │ ├── wIconImage.nim │ ├── wImage.nim │ ├── wImageList.nim │ ├── wMacros.nim │ ├── wPanel.nim │ ├── wPrintData.nim │ ├── wResizable.nim │ ├── wResizer.nim │ ├── wToolTip.nim │ ├── wTypes.nim │ ├── wUtils.nim │ ├── wWindow.nim │ └── winimx.nim ├── wAcceleratorTable.nim ├── wApp.nim ├── wBitmap.nim ├── wBrush.nim ├── wButton.nim ├── wCalendarCtrl.nim ├── wCheckBox.nim ├── wCheckComboBox.nim ├── wClientDC.nim ├── wColorDialog.nim ├── wComboBox.nim ├── wControl.nim ├── wCursor.nim ├── wDC.nim ├── wDataObject.nim ├── wDatePickerCtrl.nim ├── wDialog.nim ├── wDirDialog.nim ├── wEvent.nim ├── wFileDialog.nim ├── wFindReplaceDialog.nim ├── wFont.nim ├── wFontDialog.nim ├── wFrame.nim ├── wGauge.nim ├── wGdiObject.nim ├── wHotkeyCtrl.nim ├── wHyperlinkCtrl.nim ├── wIcon.nim ├── wIconImage.nim ├── wImage.nim ├── wImageList.nim ├── wIpCtrl.nim ├── wListBox.nim ├── wListCtrl.nim ├── wMacros.nim ├── wMemoryDC.nim ├── wMenu.nim ├── wMenuBar.nim ├── wMenuBarCtrl.nim ├── wMenuItem.nim ├── wMessageDialog.nim ├── wNoteBook.nim ├── wPageSetupDialog.nim ├── wPaintDC.nim ├── wPanel.nim ├── wPasswordEntryDialog.nim ├── wPen.nim ├── wPrintData.nim ├── wPrintDialog.nim ├── wPrinterDC.nim ├── wRadioButton.nim ├── wRebar.nim ├── wRegion.nim ├── wResizable.nim ├── wResizer.nim ├── wScreenDC.nim ├── wScrollBar.nim ├── wSlider.nim ├── wSpinButton.nim ├── wSpinCtrl.nim ├── wSplitter.nim ├── wStaticBitmap.nim ├── wStaticBox.nim ├── wStaticLine.nim ├── wStaticText.nim ├── wStatusBar.nim ├── wTextCtrl.nim ├── wTextEntryDialog.nim ├── wTimePickerCtrl.nim ├── wToolBar.nim ├── wToolTip.nim ├── wTreeCtrl.nim ├── wTypes.nim ├── wUtils.nim ├── wWebView.nim ├── wWindow.nim └── wWindowDC.nim └── wnim.nimble /docs/images/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khchen/wNim/16105eec911c633e3c994c879e42a43584b6d5b5/docs/images/screenshot.png -------------------------------------------------------------------------------- /docs/images/wButton.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khchen/wNim/16105eec911c633e3c994c879e42a43584b6d5b5/docs/images/wButton.png -------------------------------------------------------------------------------- /docs/images/wCalendarCtrl.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khchen/wNim/16105eec911c633e3c994c879e42a43584b6d5b5/docs/images/wCalendarCtrl.png -------------------------------------------------------------------------------- /docs/images/wCheckBox.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khchen/wNim/16105eec911c633e3c994c879e42a43584b6d5b5/docs/images/wCheckBox.png -------------------------------------------------------------------------------- /docs/images/wCheckComboBox.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khchen/wNim/16105eec911c633e3c994c879e42a43584b6d5b5/docs/images/wCheckComboBox.png -------------------------------------------------------------------------------- /docs/images/wComboBox.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khchen/wNim/16105eec911c633e3c994c879e42a43584b6d5b5/docs/images/wComboBox.png -------------------------------------------------------------------------------- /docs/images/wDatePickerCtrl.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khchen/wNim/16105eec911c633e3c994c879e42a43584b6d5b5/docs/images/wDatePickerCtrl.png -------------------------------------------------------------------------------- /docs/images/wGauge.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khchen/wNim/16105eec911c633e3c994c879e42a43584b6d5b5/docs/images/wGauge.png -------------------------------------------------------------------------------- /docs/images/wHotkeyCtrl.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khchen/wNim/16105eec911c633e3c994c879e42a43584b6d5b5/docs/images/wHotkeyCtrl.png -------------------------------------------------------------------------------- /docs/images/wHyperLinkCtrl.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khchen/wNim/16105eec911c633e3c994c879e42a43584b6d5b5/docs/images/wHyperLinkCtrl.png -------------------------------------------------------------------------------- /docs/images/wIpCtrl.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khchen/wNim/16105eec911c633e3c994c879e42a43584b6d5b5/docs/images/wIpCtrl.png -------------------------------------------------------------------------------- /docs/images/wListBox.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khchen/wNim/16105eec911c633e3c994c879e42a43584b6d5b5/docs/images/wListBox.png -------------------------------------------------------------------------------- /docs/images/wListCtrl.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khchen/wNim/16105eec911c633e3c994c879e42a43584b6d5b5/docs/images/wListCtrl.png -------------------------------------------------------------------------------- /docs/images/wNoteBook.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khchen/wNim/16105eec911c633e3c994c879e42a43584b6d5b5/docs/images/wNoteBook.png -------------------------------------------------------------------------------- /docs/images/wRadioButton.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khchen/wNim/16105eec911c633e3c994c879e42a43584b6d5b5/docs/images/wRadioButton.png -------------------------------------------------------------------------------- /docs/images/wScrollBar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khchen/wNim/16105eec911c633e3c994c879e42a43584b6d5b5/docs/images/wScrollBar.png -------------------------------------------------------------------------------- /docs/images/wSlider.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khchen/wNim/16105eec911c633e3c994c879e42a43584b6d5b5/docs/images/wSlider.png -------------------------------------------------------------------------------- /docs/images/wSpinButton.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khchen/wNim/16105eec911c633e3c994c879e42a43584b6d5b5/docs/images/wSpinButton.png -------------------------------------------------------------------------------- /docs/images/wSpinCtrl.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khchen/wNim/16105eec911c633e3c994c879e42a43584b6d5b5/docs/images/wSpinCtrl.png -------------------------------------------------------------------------------- /docs/images/wSplitter.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khchen/wNim/16105eec911c633e3c994c879e42a43584b6d5b5/docs/images/wSplitter.png -------------------------------------------------------------------------------- /docs/images/wStaticBitmap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khchen/wNim/16105eec911c633e3c994c879e42a43584b6d5b5/docs/images/wStaticBitmap.png -------------------------------------------------------------------------------- /docs/images/wStaticBox.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khchen/wNim/16105eec911c633e3c994c879e42a43584b6d5b5/docs/images/wStaticBox.png -------------------------------------------------------------------------------- /docs/images/wStaticLine.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khchen/wNim/16105eec911c633e3c994c879e42a43584b6d5b5/docs/images/wStaticLine.png -------------------------------------------------------------------------------- /docs/images/wStaticText.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khchen/wNim/16105eec911c633e3c994c879e42a43584b6d5b5/docs/images/wStaticText.png -------------------------------------------------------------------------------- /docs/images/wTextCtrl.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khchen/wNim/16105eec911c633e3c994c879e42a43584b6d5b5/docs/images/wTextCtrl.png -------------------------------------------------------------------------------- /docs/images/wTimePickerCtrl.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khchen/wNim/16105eec911c633e3c994c879e42a43584b6d5b5/docs/images/wTimePickerCtrl.png -------------------------------------------------------------------------------- /docs/images/wTreeCtrl.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khchen/wNim/16105eec911c633e3c994c879e42a43584b6d5b5/docs/images/wTreeCtrl.png -------------------------------------------------------------------------------- /docs/images/wWebView.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khchen/wNim/16105eec911c633e3c994c879e42a43584b6d5b5/docs/images/wWebView.png -------------------------------------------------------------------------------- /examples/calendar.nim: -------------------------------------------------------------------------------- 1 | #==================================================================== 2 | # 3 | # wNim - Nim's Windows GUI Framework 4 | # Copyright (c) Chen Kai-Hung, Ward 5 | # 6 | #==================================================================== 7 | 8 | import resource/resource 9 | import times 10 | import wNim/[wApp, wFrame, wCalendarCtrl, wScrollBar, wFont, wIcon] 11 | import winim/[lean, inc/uxtheme] # for SetWindowTheme() 12 | 13 | proc update(calendar: wCalendarCtrl, today: DateTime) = 14 | when compiles(dateTime(today.year, mJan, 1)): # initDateTime is deprecated 15 | var firstDay = dateTime(today.year, mJan, 1) 16 | var lastDay = dateTime(today.year, mDec, 31) 17 | else: 18 | var firstDay = initDateTime(1, mJan, today.year, 0, 0, 0, 0) 19 | var lastDay = initDateTime(31, mDec, today.year, 0, 0, 0, 0) 20 | 21 | calendar.dateRange = (firstDay.toTime, lastDay.toTime) 22 | calendar.date = today.toTime 23 | 24 | var app = App(wSystemDpiAware) 25 | var frame = Frame(title="wNim Calendar") 26 | frame.icon = Icon("", 0) # load icon from exe file. 27 | 28 | # Use wScrollBar control instead of wHScroll so that we can change the width. 29 | var scroll = ScrollBar(frame, style=wSbHorizontal) 30 | scroll.setScrollbar(100, 1, 200) 31 | 32 | var calendar = CalendarCtrl(frame, style=wCalNoToday) 33 | calendar.disable() 34 | calendar.doubleBuffered = true 35 | calendar.handle.SetWindowTheme("", "") # disable the theme to change the font 36 | calendar.font = Font(10, weight=wFontWeightBold) 37 | calendar.update(now()) 38 | 39 | frame.wEvent_Size do (): 40 | frame.autolayout """ 41 | H: |[calendar,scroll]| 42 | V: |[calendar][scroll(30)]| 43 | """ 44 | 45 | frame.wEvent_ScrollBar do (event: wEvent): 46 | var day = now() + years(event.getScrollPos() - 100) 47 | calendar.update(day) 48 | 49 | frame.wEvent_LeftDoubleClick do (): 50 | scroll.setScrollbar(100, 1, 200) 51 | calendar.update(now()) 52 | 53 | # The default size to display the whole year 54 | frame.clientSize = (calendar.bestSize.width * 4, calendar.bestSize.height * 3 + 30) 55 | 56 | frame.center() 57 | frame.show() 58 | app.mainLoop() 59 | -------------------------------------------------------------------------------- /examples/config.nims: -------------------------------------------------------------------------------- 1 | #==================================================================== 2 | # 3 | # NimPK - Pocketlang Binding for Nim Language 4 | # Copyright (c) Chen Kai-Hung, Ward 5 | # 6 | #==================================================================== 7 | 8 | switch("path", "$projectDir/..") 9 | -------------------------------------------------------------------------------- /examples/customdialog.nim: -------------------------------------------------------------------------------- 1 | #==================================================================== 2 | # 3 | # wNim - Nim's Windows GUI Framework 4 | # Copyright (c) Chen Kai-Hung, Ward 5 | # 6 | #==================================================================== 7 | 8 | import resource/resource 9 | 10 | import wNim/[wApp, wFrame, wPanel, wMenuBar, wMenu, wIcon, wBitmap, 11 | wStaticText, wTextCtrl, wToolBar, wButton, wStatusBar, wMessageDialog] 12 | 13 | proc passwordDialog(owner: wWindow): string = 14 | var password = "" 15 | let dialog = Frame(owner=owner, size=(320, 200), style=wCaption or wSystemMenu) 16 | let panel = Panel(dialog) 17 | 18 | let statictext = StaticText(panel, label="Please enter the password:", pos=(10, 10)) 19 | let textctrl = TextCtrl(panel, pos=(20, 50), size=(270, 30), 20 | style=wBorderSunken or wTePassword) 21 | let buttonOk = Button(panel, label="&OK", size=(90, 30), pos=(100, 120)) 22 | let buttonCancel = Button(panel, label="&Cancel", size=(90, 30), pos=(200, 120)) 23 | 24 | const ok = staticRead(r"images/ok.ico") 25 | const cancel = staticRead(r"images/cancel.ico") 26 | 27 | # Add a [X] button to delete the text. 28 | let toolbar = ToolBar(panel) 29 | toolbar.backgroundColor = wWhite 30 | toolbar.addTool(wIdDelete, "", Bitmap(Icon("shell32.dll,131", (16, 16)))) 31 | toolbar.undock() 32 | textctrl.setBuddy(toolbar, wRight, 24) 33 | 34 | buttonOk.setDefault() 35 | buttonOk.setIcon(Icon(ok)) 36 | buttonCancel.setIcon(Icon(cancel)) 37 | dialog.icon = Icon(ok) 38 | 39 | dialog.wIdDelete do (): 40 | textctrl.clear() 41 | 42 | dialog.wEvent_Close do (): 43 | dialog.endModal() 44 | 45 | buttonOk.wEvent_Button do (): 46 | password = textctrl.value 47 | dialog.close() 48 | 49 | buttonCancel.wEvent_Button do (): 50 | dialog.close() 51 | 52 | dialog.shortcut(wAccelNormal, wKey_Esc) do (): 53 | buttonCancel.click() 54 | 55 | dialog.center() 56 | dialog.showModal() 57 | dialog.delete() 58 | 59 | result = password 60 | 61 | when isMainModule: 62 | type 63 | MenuID = enum 64 | idOpen = wIdUser 65 | idExit 66 | idButton 67 | 68 | let app = App(wSystemDpiAware) 69 | let frame = Frame(title="wNim PasswordDialog", size=(480, 320)) 70 | frame.icon = Icon("", 0) # load icon from exe file. 71 | 72 | let statusbar = StatusBar(frame) 73 | let button = Button(frame, label="Open Dialog") 74 | let menubar = MenuBar(frame) 75 | let menu = Menu(menubar, "&File") 76 | menu.append(idOpen, "&Open", "Open the dialog.") 77 | menu.appendSeparator() 78 | menu.append(idExit, "E&xit", "Exit the program.") 79 | 80 | button.wEvent_Button do (): 81 | let password = passwordDialog(frame) 82 | if password.len != 0: 83 | MessageDialog(frame, password, "Password", wOk or wIconInformation).display() 84 | 85 | frame.idOpen do (): 86 | button.click() 87 | 88 | frame.idExit do (): 89 | frame.close() 90 | 91 | frame.center() 92 | frame.show() 93 | app.mainLoop() 94 | -------------------------------------------------------------------------------- /examples/draggable.nim: -------------------------------------------------------------------------------- 1 | #==================================================================== 2 | # 3 | # wNim - Nim's Windows GUI Framework 4 | # Copyright (c) Chen Kai-Hung, Ward 5 | # 6 | #==================================================================== 7 | 8 | import resource/resource 9 | import wNim/[wApp, wFrame, wIcon, wMenuBar, wMenu, wStatusBar, wSplitter, wButton] 10 | 11 | type 12 | MenuID = enum 13 | idLayout1 = wIdUser, idLayout2, idEnable, idExit 14 | 15 | let app = App(wSystemDpiAware) 16 | let frame = Frame(title="Draggable GUI Demo") 17 | let statusBar = StatusBar(frame) 18 | let menuBar = MenuBar(frame) 19 | frame.margin = 10 20 | frame.icon = Icon("", 0) # load icon from exe file. 21 | 22 | let menu = Menu(menuBar, "&Action") 23 | menu.appendRadioItem(idLayout1, "Layout&1", "Switch to layout 1.").check() 24 | menu.appendRadioItem(idLayout2, "Layout&2", "Switch to layout 2.") 25 | menu.appendSeparator() 26 | menu.appendCheckItem(idEnable, "&Enable", "Enable or disable the splitter.").check() 27 | menu.appendSeparator() 28 | menu.append(idExit, "E&xit", "Exit the program.") 29 | 30 | let splitter1 = Splitter(frame, 31 | style=wSpVertical or wClipChildren, 32 | pos=(100, 0), size=(10, 0)) 33 | 34 | let splitter2 = Splitter(splitter1.panel1, 35 | style=wSpHorizontal or wSpButton or wClipChildren, 36 | pos=(0, 100), size=(0, 10)) 37 | 38 | let panel1 = splitter2.getPanel1 39 | let panel2 = splitter2.getPanel2 40 | let panel3 = splitter1.getPanel2 41 | 42 | panel1.margin = 10 43 | panel2.margin = 10 44 | panel3.margin = 10 45 | 46 | panel1.backgroundColor = wWheat 47 | panel2.backgroundColor = wWheat 48 | panel3.backgroundColor = wThistle 49 | 50 | # let splitter1 invisible, but can drag by window's margin 51 | splitter1.setInvisible() 52 | splitter1.attachPanel() 53 | 54 | let button1 = Button(panel1, label="Button1") 55 | let button2 = Button(panel2, label="Button2") 56 | let button3 = Button(panel3, label="Button3") 57 | 58 | # let buttons' size can be changed by user 59 | button1.sizingBorder = (10, 10, 10, 10) 60 | button2.sizingBorder = (10, 10, 10, 10) 61 | button3.sizingBorder = (10, 10, 10, 10) 62 | 63 | # let buttons' position can be changed by user 64 | button1.setDraggable(true) 65 | button2.setDraggable(true) 66 | button3.setDraggable(true) 67 | 68 | button1.wEvent_Button do (): splitter2.swap 69 | button2.wEvent_Button do (): splitter2.swap 70 | button3.wEvent_Button do (): splitter1.swap 71 | 72 | proc layout() = 73 | button1.setSize((0, 0), panel1.clientSize) 74 | button2.setSize((0, 0), panel2.clientSize) 75 | button3.setSize((0, 0), panel3.clientSize) 76 | 77 | panel1.wEvent_Size do (): layout() 78 | panel2.wEvent_Size do (): layout() 79 | panel3.wEvent_Size do (): layout() 80 | 81 | frame.idExit do (): 82 | frame.delete() 83 | 84 | frame.idLayout1 do (): 85 | splitter1.setSplitMode(wVertical) 86 | splitter2.setSplitMode(wHorizontal) 87 | splitter1.position = (150, 0) 88 | splitter2.position = (0, 100) 89 | 90 | frame.idLayout2 do (): 91 | splitter1.setSplitMode(wHorizontal) 92 | splitter2.setSplitMode(wVertical) 93 | splitter1.position = (0, 150) 94 | splitter2.position = (100, 0) 95 | 96 | frame.idEnable do (): 97 | splitter1.enable(menuBar.isChecked(idEnable)) 98 | splitter2.enable(menuBar.isChecked(idEnable)) 99 | 100 | layout() 101 | frame.center() 102 | frame.show() 103 | app.mainLoop() 104 | -------------------------------------------------------------------------------- /examples/frame.nim: -------------------------------------------------------------------------------- 1 | #==================================================================== 2 | # 3 | # wNim - Nim's Windows GUI Framework 4 | # Copyright (c) Chen Kai-Hung, Ward 5 | # 6 | #==================================================================== 7 | 8 | import resource/resource 9 | import wNim/[wApp, wIcon, wFont, wCursor, wAcceleratorTable, wFrame, wPanel, 10 | wMenu, wMenuBar, wButton, wStatusBar, wStaticText, wTextEntryDialog, wFontDialog] 11 | 12 | let app = App(wSystemDpiAware) 13 | let frame = Frame(title="wNim Frame Demo") 14 | frame.icon = Icon("", 0) # load icon from exe file. 15 | 16 | frame.dpiAutoScale: 17 | frame.minSize = (300, 200) 18 | frame.size = (350, 200) 19 | 20 | let menuBar = MenuBar(frame) 21 | let statusBar = StatusBar(frame) 22 | 23 | let menu = Menu(menuBar, "&File") 24 | menu.append(wIdExit, "E&xit\tAlt-F4", "Close window and exit program.") 25 | 26 | let accel = AcceleratorTable(frame) 27 | accel.add(wAccelAlt, wKey_F4, wIdExit) 28 | 29 | let panel = Panel(frame) 30 | let staticText = StaticText(panel, label="Hello, World!") 31 | staticText.font = Font(14, family=wFontFamilySwiss, weight=wFontWeightBold) 32 | staticText.cursor = wHandCursor 33 | staticText.fit() 34 | 35 | let button = Button(panel, label="Font") 36 | 37 | proc layout() = 38 | panel.autolayout """ 39 | HV:|-[staticText]->[button]-| 40 | """ 41 | 42 | staticText.wEvent_CommandLeftClick do (): 43 | let textEntryDialog = TextEntryDialog(frame, value=staticText.label, 44 | caption="Change The Text") 45 | 46 | if textEntryDialog.showModal() == wIdOk: 47 | staticText.label = textEntryDialog.value 48 | staticText.fit() 49 | staticText.refresh() 50 | 51 | button.wEvent_Button do (): 52 | let fontDialog = FontDialog(frame, staticText.font) 53 | fontDialog.color = staticText.foregroundColor 54 | fontDialog.enableSymbols(false) 55 | fontDialog.range = 0..24 56 | 57 | if fontDialog.showModal() == wIdOk: 58 | staticText.font = fontDialog.chosenFont 59 | staticText.foregroundColor = fontDialog.color 60 | staticText.fit() 61 | staticText.refresh() 62 | 63 | frame.wIdExit do (): 64 | frame.close() 65 | 66 | panel.wEvent_Size do (): 67 | layout() 68 | 69 | layout() 70 | frame.center() 71 | frame.show() 72 | app.mainLoop() 73 | -------------------------------------------------------------------------------- /examples/helloworld.nim: -------------------------------------------------------------------------------- 1 | #==================================================================== 2 | # 3 | # wNim - Nim's Windows GUI Framework 4 | # Copyright (c) Chen Kai-Hung, Ward 5 | # 6 | #==================================================================== 7 | 8 | import wNim/[wApp, wFrame] 9 | 10 | let app = App(wSystemDpiAware) 11 | let frame = Frame(title="Hello World", size=(400, 300)) 12 | 13 | frame.center() 14 | frame.show() 15 | app.mainLoop() 16 | -------------------------------------------------------------------------------- /examples/html/about.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | About wNim 5 | 6 | 7 | 8 | 9 |
10 | 11 |

wNim

12 |

Windows GUI Framework

13 | 14 |
15 | 16 |
nim compiler: 0.20.2 17 |
winim: 3.2.4 18 |
wNim: 0.10.0 19 |
20 |
close
21 | 22 | 23 | -------------------------------------------------------------------------------- /examples/html/demo.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Demo Page 5 | 6 | 12 | 13 | 14 | 15 |
16 | 17 |

wWebView Demo Page

18 |

click me

19 | https://github.com/khchen/wNim/ 20 | 21 |
22 |
about
23 | 24 | 25 | -------------------------------------------------------------------------------- /examples/html/style.css: -------------------------------------------------------------------------------- 1 | body { 2 | margin: 0; 3 | color: #333; 4 | font-size: 12px; 5 | font-family: 'Helvetica', 'Arial', 'MS PGothic', sans-serif; 6 | } 7 | 8 | .about { 9 | background-color: #eee; 10 | } 11 | 12 | .logo { 13 | margin: 2em; 14 | } 15 | 16 | .title, 17 | .copyright, 18 | .description { 19 | margin: 0.4em; 20 | } 21 | 22 | .description { 23 | margin-bottom: 1em; 24 | } 25 | 26 | .versions { 27 | margin-top: 1em; 28 | } 29 | 30 | .copyright, 31 | .versions { 32 | color: #999; 33 | } 34 | 35 | .clickable { 36 | cursor: pointer; 37 | font-size: 20px; 38 | color: #80a0c0; 39 | } 40 | 41 | .button { 42 | 43 | position: absolute; 44 | right: 0.5em; 45 | bottom: 0.5em; 46 | } 47 | -------------------------------------------------------------------------------- /examples/images/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khchen/wNim/16105eec911c633e3c994c879e42a43584b6d5b5/examples/images/1.png -------------------------------------------------------------------------------- /examples/images/2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khchen/wNim/16105eec911c633e3c994c879e42a43584b6d5b5/examples/images/2.png -------------------------------------------------------------------------------- /examples/images/3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khchen/wNim/16105eec911c633e3c994c879e42a43584b6d5b5/examples/images/3.png -------------------------------------------------------------------------------- /examples/images/4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khchen/wNim/16105eec911c633e3c994c879e42a43584b6d5b5/examples/images/4.png -------------------------------------------------------------------------------- /examples/images/5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khchen/wNim/16105eec911c633e3c994c879e42a43584b6d5b5/examples/images/5.png -------------------------------------------------------------------------------- /examples/images/6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khchen/wNim/16105eec911c633e3c994c879e42a43584b6d5b5/examples/images/6.png -------------------------------------------------------------------------------- /examples/images/black.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khchen/wNim/16105eec911c633e3c994c879e42a43584b6d5b5/examples/images/black.png -------------------------------------------------------------------------------- /examples/images/board1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khchen/wNim/16105eec911c633e3c994c879e42a43584b6d5b5/examples/images/board1.png -------------------------------------------------------------------------------- /examples/images/board2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khchen/wNim/16105eec911c633e3c994c879e42a43584b6d5b5/examples/images/board2.png -------------------------------------------------------------------------------- /examples/images/cancel.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khchen/wNim/16105eec911c633e3c994c879e42a43584b6d5b5/examples/images/cancel.ico -------------------------------------------------------------------------------- /examples/images/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khchen/wNim/16105eec911c633e3c994c879e42a43584b6d5b5/examples/images/logo.png -------------------------------------------------------------------------------- /examples/images/nim.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khchen/wNim/16105eec911c633e3c994c879e42a43584b6d5b5/examples/images/nim.png -------------------------------------------------------------------------------- /examples/images/o.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khchen/wNim/16105eec911c633e3c994c879e42a43584b6d5b5/examples/images/o.png -------------------------------------------------------------------------------- /examples/images/ok.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khchen/wNim/16105eec911c633e3c994c879e42a43584b6d5b5/examples/images/ok.ico -------------------------------------------------------------------------------- /examples/images/pen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khchen/wNim/16105eec911c633e3c994c879e42a43584b6d5b5/examples/images/pen.png -------------------------------------------------------------------------------- /examples/images/wNim.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khchen/wNim/16105eec911c633e3c994c879e42a43584b6d5b5/examples/images/wNim.ico -------------------------------------------------------------------------------- /examples/images/white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khchen/wNim/16105eec911c633e3c994c879e42a43584b6d5b5/examples/images/white.png -------------------------------------------------------------------------------- /examples/images/x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khchen/wNim/16105eec911c633e3c994c879e42a43584b6d5b5/examples/images/x.png -------------------------------------------------------------------------------- /examples/layout2.nim: -------------------------------------------------------------------------------- 1 | #==================================================================== 2 | # 3 | # wNim - Nim's Windows GUI Framework 4 | # Copyright (c) Chen Kai-Hung, Ward 5 | # 6 | #==================================================================== 7 | 8 | import resource/resource 9 | import wNim/[wApp, wFrame, wIcon, wStatusBar, wPanel, wButton, wResizable, 10 | wMenuBar, wMenu] 11 | 12 | const 13 | UseAutoLayout = not defined(legacy) 14 | Title = if UseAutoLayout: "Autolayout Example 2" else: "Layout Example 2" 15 | 16 | type 17 | MenuID = enum idLayout1 = wIdUser, idLayout2, idExit 18 | 19 | let app = App(wSystemDpiAware) 20 | let frame = Frame(title=Title, size=(400, 300)) 21 | frame.icon = Icon("", 0) # load icon from exe file. 22 | 23 | let statusbar = StatusBar(frame) 24 | let panel = Panel(frame) 25 | 26 | let button1 = Button(panel, label="Buton1") 27 | let button2 = Button(panel, label="Buton2") 28 | let button3 = Button(panel, label="Buton3") 29 | let button4 = Button(panel, label="Buton4") 30 | let button5 = Button(panel, label="Buton5") 31 | let box = Resizable() 32 | 33 | let menuBar = MenuBar(frame) 34 | let menu = Menu(menuBar, "Layout") 35 | menu.appendRadioItem(idLayout1, "Vertical").check() 36 | menu.appendRadioItem(idLayout2, "Horizontal") 37 | menu.appendSeparator() 38 | menu.append(idExit, "Exit") 39 | 40 | proc layout1() = 41 | when UseAutoLayout: 42 | panel.autolayout """ 43 | spacing: 8 44 | H:|~[button1..5]~| 45 | V:|-[button1]-[button2]-[button3]-[button4]-[button5] 46 | H:[box(button1 + 8 * 2)] 47 | V:[box(button1 * 5 + 8 * 6)] 48 | """ 49 | 50 | else: 51 | panel.layout: 52 | button1: centerX = panel.centerX; top = panel.top + 8 53 | button2: centerX = panel.centerX; top = button1.bottom + 8 54 | button3: centerX = panel.centerX; top = button2.bottom + 8 55 | button4: centerX = panel.centerX; top = button3.bottom + 8 56 | button5: centerX = panel.centerX; top = button4.bottom + 8 57 | box: 58 | top = 0 59 | left = 0 60 | width = button5.width + 16 61 | bottom = button5.bottom + 8 62 | 63 | let boxSize = box.layoutSize 64 | frame.minClientSize = boxSize 65 | frame.maxClientSize = (wDefault, boxSize.height) 66 | 67 | proc layout2() = 68 | when UseAutoLayout: 69 | panel.autolayout """ 70 | spacing: 8 71 | V:|~[button1..5]~| 72 | H:|-[button1]-[button2]-[button3]-[button4]-[button5] 73 | V:[box(button1 + 8 * 2)] 74 | H:[box(button1 * 5 + 8 * 6)] 75 | """ 76 | 77 | else: 78 | panel.layout: 79 | button1: centerY = panel.centerY; left = panel.left + 8 80 | button2: centerY = panel.centerY; left = button1.right + 8 81 | button3: centerY = panel.centerY; left = button2.right + 8 82 | button4: centerY = panel.centerY; left = button3.right + 8 83 | button5: centerY = panel.centerY; left = button4.right + 8 84 | box: 85 | top = 0 86 | left = 0 87 | right = button5.right + 8 88 | height = button5.height + 16 89 | 90 | let boxSize = box.layoutSize 91 | frame.minClientSize = boxSize 92 | frame.maxClientSize = (boxSize.width, wDefault) 93 | 94 | proc layout() = 95 | if menu.isChecked(idLayout1): layout1() 96 | elif menu.isChecked(idLayout2): layout2() 97 | 98 | frame.idLayout1 do (): layout1() 99 | frame.idLayout2 do (): layout2() 100 | frame.idExit do (): frame.close() 101 | panel.wEvent_Size do (): layout() 102 | 103 | layout() 104 | frame.center() 105 | frame.show() 106 | app.mainLoop() 107 | -------------------------------------------------------------------------------- /examples/layout3.nim: -------------------------------------------------------------------------------- 1 | #==================================================================== 2 | # 3 | # wNim - Nim's Windows GUI Framework 4 | # Copyright (c) Chen Kai-Hung, Ward 5 | # 6 | #==================================================================== 7 | 8 | import resource/resource 9 | import wNim/[wApp, wFrame, wIcon, wStatusBar, wPanel, wStaticBox, wButton] 10 | 11 | const 12 | UseAutoLayout = not defined(legacy) 13 | Title = if UseAutoLayout: "Autolayout Example 3" else: "Layout Example 3" 14 | 15 | let app = App(wSystemDpiAware) 16 | let frame = Frame(title=Title, size=(400, 300)) 17 | frame.icon = Icon("", 0) # load icon from exe file. 18 | 19 | let statusbar = StatusBar(frame) 20 | let panel = Panel(frame) 21 | panel.margin = 40 22 | 23 | let staticbox1 = StaticBox(panel, label="Static Box 1") 24 | let staticbox2 = StaticBox(panel, label="Static Box 2") 25 | let staticbox3 = StaticBox(panel, label="Static Box 3") 26 | staticbox1.margin = 20 27 | staticbox2.margin = 20 28 | staticbox3.margin = 20 29 | 30 | let button1 = Button(panel, label="Buton1") 31 | let button2 = Button(panel, label="Buton2") 32 | let button3 = Button(panel, label="Buton3") 33 | let button4 = Button(panel, label="Buton4") 34 | let button5 = Button(panel, label="Buton5") 35 | 36 | proc layout() = 37 | when UseAutoLayout: 38 | panel.autolayout """ 39 | spacing: 10 40 | H:|[staticbox1(staticbox2)]-20-[staticbox2]| 41 | V:|[staticbox1..2]| 42 | 43 | outer: staticbox1 44 | H:|[button1..3]| 45 | V:|[button1(button2,button3)]-[button2]-[button3]| 46 | 47 | outer: staticbox2 48 | H:|[button4..5]| 49 | V:|[button4(button5)]-[button5]| 50 | """ 51 | 52 | else: 53 | panel.layout: 54 | staticbox1: 55 | left = panel.left 56 | right + 20 = staticbox2.left 57 | top = panel.top 58 | bottom = panel.bottom 59 | 60 | staticbox2: 61 | width = staticbox1.width 62 | right = panel.right 63 | top = panel.top 64 | bottom = panel.bottom 65 | 66 | button1: 67 | left = staticbox1.innerLeft 68 | right = staticbox1.innerRight 69 | top = staticbox1.innerTop 70 | bottom + 10 = button2.top 71 | 72 | button2: 73 | left = staticbox1.innerLeft 74 | right = staticbox1.innerRight 75 | height = button1.height 76 | bottom + 10 = button3.top 77 | 78 | button3: 79 | left = staticbox1.innerLeft 80 | right = staticbox1.innerRight 81 | height = button2.height 82 | bottom = staticbox1.innerBottom 83 | 84 | button4: 85 | left = staticbox2.innerLeft 86 | right = staticbox2.innerRight 87 | top = staticbox2.innerTop 88 | bottom + 10 = button5.top 89 | 90 | button5: 91 | left = staticbox2.innerLeft 92 | right = staticbox2.innerRight 93 | height = button4.height 94 | bottom = staticbox2.innerBottom 95 | 96 | staticbox3.contain(staticbox1, staticbox2) 97 | 98 | panel.wEvent_Size do (): layout() 99 | 100 | layout() 101 | frame.center() 102 | frame.show() 103 | app.mainLoop() 104 | -------------------------------------------------------------------------------- /examples/mcts/engine_nim.nim: -------------------------------------------------------------------------------- 1 | #==================================================================== 2 | # 3 | # wNim - Nim's Windows GUI Framework 4 | # Copyright (c) Chen Kai-Hung, Ward 5 | # 6 | #==================================================================== 7 | 8 | import sets 9 | 10 | type 11 | Player* = enum 12 | NONE 13 | P1 14 | P2 15 | Move* = tuple[heap: int, n: int] 16 | Board* = seq[int] 17 | State* = ref object 18 | move*: Move 19 | rate*: float 20 | rounds*: int 21 | playerJustMoved*: Player 22 | board*: Board 23 | 24 | proc init*(state: State) = 25 | state.playerJustMoved = P2 # P1 first 26 | state.board = @[3, 4, 5] 27 | 28 | proc doMove*(state: State, move: Move) = 29 | state.playerJustMoved = Player(3 - state.playerJustMoved.ord) 30 | state.board[move.heap] -= move.n 31 | 32 | proc getMoves*(state: State): HashSet[Move] = 33 | result.init() 34 | for i in 0.. 0: 116 | return 1 117 | elif winCount == 0: 118 | return 0.5 119 | else: 120 | return 0 121 | 122 | proc repr*(board: Board): string = 123 | result = "" 124 | for i in 1..BoardSize: 125 | for j in 1..BoardSize: 126 | result.add($board[i * Edge + j]) 127 | result.add("\n") 128 | -------------------------------------------------------------------------------- /examples/mcts/engine_tictactoe.nim: -------------------------------------------------------------------------------- 1 | #==================================================================== 2 | # 3 | # wNim - Nim's Windows GUI Framework 4 | # Copyright (c) Chen Kai-Hung, Ward 5 | # 6 | #==================================================================== 7 | 8 | import sets 9 | 10 | type 11 | Player* = enum 12 | NONE = "." 13 | P1 = "O" 14 | P2 = "X" 15 | Move* = range[0..8] 16 | Board* = array[9, Player] 17 | State* = ref object 18 | move*: Move 19 | rate*: float 20 | rounds*: int 21 | playerJustMoved*: Player 22 | board*: Board 23 | 24 | proc init*(state: State) = 25 | state.playerJustMoved = P2 # P1 first 26 | state.board = [NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE] 27 | 28 | proc doMove*(state: State, move: Move) = 29 | state.playerJustMoved = Player(3 - state.playerJustMoved.ord) 30 | state.board[move] = state.playerJustMoved 31 | 32 | proc checkBoard(state: State): Player = 33 | for tup in [(0, 1, 2), (3, 4, 5), (6, 7, 8), (0, 3, 6), (1, 4, 7), (2, 5, 8), 34 | (0, 4, 8), (2, 4, 6)]: 35 | 36 | let (x, y, z) = tup 37 | if state.board[x] != NONE and state.board[x] == state.board[y] and 38 | state.board[y] == state.board[z]: 39 | 40 | return state.board[x] 41 | return NONE 42 | 43 | proc getMoves*(state: State): HashSet[Move] = 44 | result.init() 45 | if state.checkBoard() == NONE: 46 | for i, p in state.board: 47 | if p == NONE: result.incl(i) 48 | 49 | proc getResult*(state: State, lastPlayer: Player): float = 50 | var win = state.checkBoard() 51 | if win == lastPlayer: 52 | result = 1 53 | elif win == NONE: 54 | result = 0.5 55 | else: 56 | result = 0 57 | 58 | proc repr*(board: Board): string = 59 | result = "" 60 | for i, p in board: 61 | result.add($p) 62 | if i mod 3 == 2: result.add("\n") 63 | -------------------------------------------------------------------------------- /examples/mcts/gamebase.nim: -------------------------------------------------------------------------------- 1 | #==================================================================== 2 | # 3 | # wNim - Nim's Windows GUI Framework 4 | # Copyright (c) Chen Kai-Hung, Ward 5 | # 6 | #==================================================================== 7 | 8 | import threadpool, mcts, sets 9 | 10 | type 11 | Game*[State] = ref object 12 | state: State 13 | fv: FlowVar[State] 14 | 15 | proc newGame*[State](): Game[State] = 16 | result = Game[State]() 17 | result.state = State() 18 | result.state.init() 19 | 20 | proc reset*[State](self: Game[State]) {.inline.} = 21 | self.state = State() 22 | self.state.init() 23 | 24 | proc getBoard*[State](self: Game[State]): auto {.inline.} = 25 | result = self.state.board 26 | 27 | proc getRounds*[State](self: Game[State]): int {.inline.} = 28 | result = self.state.rounds 29 | 30 | proc getRate*[State](self: Game[State]): float {.inline.} = 31 | result = self.state.rate 32 | 33 | proc isFinish*[State](self: Game[State]): bool {.inline.} = 34 | result = self.state.getMoves().card == 0 35 | 36 | proc getNextPlayer*[State](self: Game[State]): auto = 37 | type 38 | Player = self.state.playerJustMoved.type 39 | 40 | if self.isFinish(): 41 | result = Player(0) 42 | else: 43 | result = Player(3 - self.state.playerJustMoved.ord) 44 | 45 | proc getWinner*[State](self: Game[State]): auto = 46 | type 47 | Player = self.state.playerJustMoved.type 48 | 49 | var score = self.state.getResult(Player(1)) 50 | if score > 0.5: 51 | result = Player(1) 52 | elif score < 0.5: 53 | result = Player(2) 54 | else: 55 | result = Player(0) 56 | 57 | proc play*[State, Move](self: Game[State], move: Move): bool {.discardable.} = 58 | if move in self.state.getMoves(): 59 | self.state.doMove(move) 60 | result = true 61 | 62 | proc aiStart*[State](self: Game[State], timeout: float) = 63 | self.fv = spawn mcts(self.state, itermax=int.high, timeout=timeout) 64 | 65 | proc aiReady*[State](self: Game[State]): bool {.inline.} = 66 | result = isReady(self.fv) 67 | 68 | proc aiPlay*[State](self: Game[State]) = 69 | var newState = ^self.fv 70 | self.state.move = newState.move 71 | self.state.rate = newState.rate 72 | self.state.rounds = newState.rounds 73 | self.state.doMove(newState.move) 74 | 75 | when isMainModule: 76 | import os, random 77 | import engine_reversi 78 | # import engine_nim 79 | # import engine_tictactoe 80 | 81 | randomize() 82 | var game = newGame[State]() 83 | echo game.getBoard.repr 84 | 85 | while not game.isFinish(): 86 | game.aiStart(0.5) 87 | while not game.aiReady(): 88 | os.sleep(100) 89 | game.aiPlay() 90 | echo "rounds: ", game.getRounds() 91 | echo game.getBoard.repr 92 | 93 | echo game.getWinner() 94 | -------------------------------------------------------------------------------- /examples/menu.nim: -------------------------------------------------------------------------------- 1 | #==================================================================== 2 | # 3 | # wNim - Nim's Windows GUI Framework 4 | # Copyright (c) Chen Kai-Hung, Ward 5 | # 6 | #==================================================================== 7 | 8 | import 9 | strformat, 10 | resource/resource 11 | 12 | import wNim/[wApp, wFrame, wIcon, wStatusBar, wMenuBar, wMenu, wBitmap, wImage, 13 | wPanel, wMenuBarCtrl] 14 | 15 | type 16 | # A menu ID in wNim is type of wCommandID (distinct int) or any enum type. 17 | MenuID = enum 18 | idOpen = wIdUser, idExit 19 | idIcon1, idIcon2, idIcon3, idIcon4, idIcon5, idIcon6 20 | idCheck1, idCheck2, idRadio1, idRadio2, idRadio3 21 | idEnable, idDisable, idAbout 22 | 23 | const resources: array[idIcon1..idIcon6, string] = [ 24 | staticRead(r"images/1.png"), 25 | staticRead(r"images/2.png"), 26 | staticRead(r"images/3.png"), 27 | staticRead(r"images/4.png"), 28 | staticRead(r"images/5.png"), 29 | staticRead(r"images/6.png") ] 30 | 31 | let 32 | app = App(wSystemDpiAware) 33 | frame = Frame(title="wNim Menu Demo") 34 | panel = Panel(frame) 35 | statusBar = StatusBar(frame) 36 | menuBar = MenuBar(frame) 37 | 38 | frame.icon = Icon("", 0) # load icon from exe file. 39 | 40 | let menuFile = Menu(menuBar, "&File") 41 | menuFile.append(idOpen, "&Open", "Open a file.") 42 | menuFile.appendSeparator() 43 | menuFile.append(idExit, "E&xit", "Exit the program.") 44 | 45 | let menuIcon = Menu(menuBar, "&Icon") 46 | for id in idIcon1..idIcon6: 47 | let bmp = Bitmap(Image(resources[id]).scale(36, 36)) 48 | menuIcon.append(id, $id, $id & " Help", bmp) 49 | 50 | let menuTest = Menu(menuBar, "&Test") 51 | menuTest.appendCheckItem(idCheck1, "Check 1", "Check 1 Help").check() 52 | menuTest.appendCheckItem(idCheck2, "Check 2", "Check 2 Help") 53 | menuTest.appendSeparator() 54 | menuTest.appendRadioItem(idRadio1, "Radio 1", "Radio 1 help").check() 55 | menuTest.appendRadioItem(idRadio2, "Radio 2", "Radio 2 help") 56 | menuTest.appendRadioItem(idRadio3, "Radio 3", "Radio 3 help") 57 | menuTest.appendSeparator() 58 | menuTest.append(idEnable, "Enable", "Enable the icon menu and about") 59 | menuTest.append(idDisable, "Disable", "Disable the icon menu and about") 60 | menuTest.appendSeparator() 61 | menuTest.appendSubMenu(menuIcon, "&Icon", "Icon menu here.").disable() 62 | 63 | let menuAbout = Menu(menuBar, "&About") 64 | let itemAbout = menuAbout.append(idAbout, "About", "About") 65 | 66 | let menuBarCtrl = MenuBarCtrl(panel, menuBar=menuBar, statusBar=statusBar) 67 | menuBarCtrl.suit() 68 | 69 | frame.wEvent_Size do (): 70 | frame.autolayout """ 71 | HV:[panel(70%)]| 72 | """ 73 | 74 | panel.autolayout """ 75 | H:|[menuBarCtrl]| 76 | V:|[menuBarCtrl] 77 | """ 78 | 79 | # frame.connect(idExit) is syntax sugar for frame.connect(wEvent_Menu, idExit) 80 | # frame.idExit is syntax sugar for frame.connect(idExit) 81 | 82 | frame.idExit do (): 83 | frame.delete 84 | 85 | frame.idEnable do (): 86 | menuIcon.enable 87 | itemAbout.enable 88 | 89 | frame.idDisable do (): 90 | menuIcon.disable 91 | itemAbout.disable 92 | 93 | frame.wEvent_Menu do (event: wEvent): 94 | let item = menuBar.findItem(event.id) 95 | let help = menuBar.getHelp(event.id) 96 | var msg: string 97 | 98 | if item != nil and item.isCheck: 99 | msg = fmt"{item.text} is checked: {item.isChecked}" 100 | else: 101 | msg = fmt"{MenuID(event.id)} is selected, help is ""{help}""." 102 | 103 | statusBar.setStatusText(msg) 104 | event.skip # make sure idExit event pass to next handler 105 | 106 | frame.wEvent_ContextMenu do (): 107 | frame.popupMenu(menuTest) 108 | 109 | frame.center() 110 | frame.show() 111 | app.mainLoop() 112 | -------------------------------------------------------------------------------- /examples/nonsubclassing.nim: -------------------------------------------------------------------------------- 1 | #==================================================================== 2 | # 3 | # wNim - Nim's Windows GUI Framework 4 | # Copyright (c) Chen Kai-Hung, Ward 5 | # 6 | #==================================================================== 7 | 8 | import resource/resource 9 | import wNim/[wApp, wFrame, wIcon, wMessageDialog] 10 | 11 | let app = App(wSystemDpiAware) 12 | let frame = Frame(title="Hello World", size=(350, 200)) 13 | frame.icon = Icon("", 0) # load icon from exe file. 14 | 15 | frame.wEvent_Destroy do (): 16 | MessageDialog(frame, "wMyFrame is about to destroy.", 17 | "wEvent_Destroy", wOk or wStayOnTop).showModal() 18 | 19 | frame.wEvent_Close do (event: wEvent): 20 | let dlg = MessageDialog(frame, "Do you really want to close this application?", 21 | "Confirm Exit", wOkCancel or wIconQuestion) 22 | 23 | if dlg.showModal() != wIdOk: 24 | event.veto() 25 | 26 | frame.center() 27 | frame.show() 28 | app.mainLoop() 29 | -------------------------------------------------------------------------------- /examples/rebar.nim: -------------------------------------------------------------------------------- 1 | #==================================================================== 2 | # 3 | # wNim - Nim's Windows GUI Framework 4 | # Copyright (c) Chen Kai-Hung, Ward 5 | # 6 | #==================================================================== 7 | 8 | import resource/resource 9 | import wNim/[wApp, wImageList, wImage, wBitmap, wIcon, wFrame, wStatusBar, wRebar, 10 | wToolBar, wButton, wComboBox, wMenuBarCtrl, wMenuBar] 11 | 12 | type 13 | MenuID = enum 14 | idOpen = wIdUser, idExit, idCut, idCopy, idPaste, idAbout 15 | idTool1, idTool2, idTool3, idTool4 16 | 17 | const 18 | resource1 = staticRead(r"images/1.png") 19 | resource2 = staticRead(r"images/2.png") 20 | resource3 = staticRead(r"images/3.png") 21 | resource4 = staticRead(r"images/4.png") 22 | resource5 = staticRead(r"images/cancel.ico") 23 | 24 | let imageList = ImageList(24, 24) 25 | imageList.add(Image(resource1).scale(24, 24)) 26 | imageList.add(Image(resource2).scale(24, 24)) 27 | imageList.add(Image(resource3).scale(24, 24)) 28 | imageList.add(Image(resource4).scale(24, 24)) 29 | imageList.add(Image(resource5).scale(24, 24)) 30 | 31 | let 32 | img1 = Image(resource1).scale(16, 16) 33 | img2 = Image(resource2).scale(16, 16) 34 | img3 = Image(resource3).scale(16, 16) 35 | img4 = Image(resource4).scale(16, 16) 36 | 37 | let 38 | app = App(wSystemDpiAware) 39 | frame = Frame(title="Rebar Example") 40 | statusbar = StatusBar(frame) 41 | reset = Button(frame, label="Reset Layout And Freeze") 42 | rebar = Rebar(frame) 43 | 44 | frame.icon = Icon("", 0) # load icon from exe file. 45 | rebar.setImageList(imageList) 46 | 47 | let toolbar = ToolBar(rebar) 48 | toolbar.addTool(idTool1, "Tool 1", Bitmap(img1), "Tool1", "This is tool 1.") 49 | toolbar.addTool(idTool2, "Tool 2", Bitmap(img2), "Tool2", "This is tool 2.") 50 | toolbar.addTool(idTool3, "Tool 3", Bitmap(img3), "Tool3", "This is tool 3.") 51 | toolbar.addTool(idTool4, "Tool 4", Bitmap(img4), "Tool4", "This is tool 4.") 52 | 53 | let button = Button(rebar, label="Exit") 54 | 55 | let combobox = ComboBox(rebar, value="Combobox Item1", 56 | choices=["Combobox Item1", "Combobox Item2", "Combobox Item3"], 57 | style=wCB_READONLY) 58 | 59 | let menuBar = MenuBar() 60 | let menuFile = Menu(menuBar, "&File") 61 | menuFile.append(idOpen, "&Open", "Open a file.") 62 | menuFile.appendSeparator() 63 | menuFile.append(idExit, "E&xit", "Exit the program.") 64 | 65 | let menuEdit = Menu(menuBar, "E&dit") 66 | menuEdit.append(idCut, "Cut", "Cut") 67 | menuEdit.append(idCopy, "&Copy", "Copy") 68 | menuEdit.append(idPaste, "&Paste", "Paste") 69 | 70 | let menuAbout = Menu(menuBar, "A&bout") 71 | menuAbout.append(idAbout, "About", "About the program") 72 | 73 | let menuBarCtrl = MenuBarCtrl(rebar, menuBar=menuBar, statusBar=statusbar) 74 | wMenuBarCtrlEnableMenuKey() 75 | 76 | rebar.addBand(toolBar) 77 | rebar.addBand() 78 | rebar.addBand(button, 4) 79 | rebar.addBand(combobox, 2, "Combo", style=wRbBreak) 80 | rebar.addBand(menuBarCtrl) 81 | rebar.maximizeBand(1) 82 | 83 | frame.wEvent_Tool do (event: wEvent): 84 | statusbar.setStatusText($MenuID(event.id) & " clicked.") 85 | 86 | combobox.wEvent_ComboBox do (event: wEvent): 87 | statusbar.setStatusText(combobox.getValue()) 88 | 89 | button.wEvent_Button do (): 90 | frame.close() 91 | 92 | frame.idExit do (): 93 | frame.close() 94 | 95 | let layout = rebar.layout 96 | var freeze = true 97 | 98 | reset.wEvent_Button do (): 99 | if freeze: 100 | reset.label = "Unfreeze" 101 | else: 102 | reset.label = "Reset Layout And Freeze" 103 | 104 | rebar.disableMinMax(freeze) 105 | rebar.disableDrag(freeze) 106 | rebar.layout = layout 107 | freeze = not freeze 108 | 109 | frame.center() 110 | frame.show() 111 | app.mainLoop() 112 | -------------------------------------------------------------------------------- /examples/resource/build.cmd: -------------------------------------------------------------------------------- 1 | @echo off 2 | %NIMPATH%\dist\mingw32\bin\windres -O coff wNim.rc -o wNim32.res 3 | %NIMPATH%\dist\mingw64\bin\windres -O coff wNim.rc -o wNim64.res 4 | %NIMPATH%\dist\mingw32\bin\windres -O coff wNimTcc.rc -o wNimTcc32.res 5 | %NIMPATH%\dist\mingw64\bin\windres -O coff wNimTcc.rc -o wNimTcc64.res 6 | %NIMPATH%\dist\mingw32\bin\windres -O coff wWebView.rc -o wWebView32.res 7 | %NIMPATH%\dist\mingw64\bin\windres -O coff wWebView.rc -o wWebView64.res 8 | %NIMPATH%\dist\mingw32\bin\windres -O coff wWebViewTcc.rc -o wWebViewTcc32.res 9 | %NIMPATH%\dist\mingw64\bin\windres -O coff wWebViewTcc.rc -o wWebViewTcc64.res 10 | -------------------------------------------------------------------------------- /examples/resource/resource.nim: -------------------------------------------------------------------------------- 1 | {.used.} 2 | when defined(vcc): 3 | {.link: "wNimVcc.res".} 4 | 5 | elif defined(cpu64): 6 | when defined(tcc): 7 | {.link: "wNimTcc64.res".} 8 | 9 | else: 10 | {.link: "wNim64.res".} 11 | 12 | else: 13 | when defined(tcc): 14 | {.link: "wNimTcc32.res".} 15 | 16 | else: 17 | {.link: "wNim32.res".} 18 | -------------------------------------------------------------------------------- /examples/resource/resource2.nim: -------------------------------------------------------------------------------- 1 | {.used.} 2 | when defined(vcc): 3 | {.link: "wWebViewVcc.res".} 4 | 5 | elif defined(cpu64): 6 | when defined(tcc): 7 | {.link: "wWebViewTcc64.res".} 8 | 9 | else: 10 | {.link: "wWebView64.res".} 11 | 12 | else: 13 | when defined(tcc): 14 | {.link: "wWebViewTcc32.res".} 15 | 16 | else: 17 | {.link: "wWebView32.res".} 18 | -------------------------------------------------------------------------------- /examples/resource/wNim.manifest: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /examples/resource/wNim.rc: -------------------------------------------------------------------------------- 1 | 1000 ICON "..\\images\\wNim.ico" 2 | -------------------------------------------------------------------------------- /examples/resource/wNim32.res: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khchen/wNim/16105eec911c633e3c994c879e42a43584b6d5b5/examples/resource/wNim32.res -------------------------------------------------------------------------------- /examples/resource/wNim64.res: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khchen/wNim/16105eec911c633e3c994c879e42a43584b6d5b5/examples/resource/wNim64.res -------------------------------------------------------------------------------- /examples/resource/wNimTcc.rc: -------------------------------------------------------------------------------- 1 | 1 24 "wNim.manifest" 2 | 1000 ICON "..\\images\\wNim.ico" 3 | -------------------------------------------------------------------------------- /examples/resource/wNimTcc32.res: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khchen/wNim/16105eec911c633e3c994c879e42a43584b6d5b5/examples/resource/wNimTcc32.res -------------------------------------------------------------------------------- /examples/resource/wNimTcc64.res: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khchen/wNim/16105eec911c633e3c994c879e42a43584b6d5b5/examples/resource/wNimTcc64.res -------------------------------------------------------------------------------- /examples/resource/wNimVcc.res: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khchen/wNim/16105eec911c633e3c994c879e42a43584b6d5b5/examples/resource/wNimVcc.res -------------------------------------------------------------------------------- /examples/resource/wWebView.rc: -------------------------------------------------------------------------------- 1 | 1000 ICON "..\\images\\wNim.ico" 2 | wNim.ico HTML "..\\images\\wNim.ico" 3 | logo.png HTML "..\\images\\logo.png" 4 | demo.html HTML "..\\html\\demo.html" 5 | about.html HTML "..\\html\\about.html" 6 | style.css HTML "..\\html\\style.css" 7 | -------------------------------------------------------------------------------- /examples/resource/wWebView32.res: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khchen/wNim/16105eec911c633e3c994c879e42a43584b6d5b5/examples/resource/wWebView32.res -------------------------------------------------------------------------------- /examples/resource/wWebView64.res: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khchen/wNim/16105eec911c633e3c994c879e42a43584b6d5b5/examples/resource/wWebView64.res -------------------------------------------------------------------------------- /examples/resource/wWebViewTcc.rc: -------------------------------------------------------------------------------- 1 | 1 24 "wNim.manifest" 2 | 1000 ICON "..\\images\\wNim.ico" 3 | wNim.ico HTML "..\\images\\wNim.ico" 4 | logo.png HTML "..\\images\\logo.png" 5 | demo.html HTML "..\\html\\demo.html" 6 | about.html HTML "..\\html\\about.html" 7 | style.css HTML "..\\html\\style.css" 8 | -------------------------------------------------------------------------------- /examples/resource/wWebViewTcc32.res: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khchen/wNim/16105eec911c633e3c994c879e42a43584b6d5b5/examples/resource/wWebViewTcc32.res -------------------------------------------------------------------------------- /examples/resource/wWebViewTcc64.res: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khchen/wNim/16105eec911c633e3c994c879e42a43584b6d5b5/examples/resource/wWebViewTcc64.res -------------------------------------------------------------------------------- /examples/resource/wWebViewVcc.res: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khchen/wNim/16105eec911c633e3c994c879e42a43584b6d5b5/examples/resource/wWebViewVcc.res -------------------------------------------------------------------------------- /examples/reversi.nims: -------------------------------------------------------------------------------- 1 | switch("threads", "on") 2 | -------------------------------------------------------------------------------- /examples/shapewin.nim: -------------------------------------------------------------------------------- 1 | #==================================================================== 2 | # 3 | # wNim - Nim's Windows GUI Framework 4 | # Copyright (c) Chen Kai-Hung, Ward 5 | # 6 | #==================================================================== 7 | 8 | import resource/resource 9 | import wNim/[wApp, wImage, wFrame, wRegion, wMenu, wPaintDC] 10 | 11 | let app = App(wSystemDpiAware) 12 | 13 | const logo = staticRead(r"images/logo.png") 14 | let image = Image(logo) 15 | 16 | let frame = Frame(size=image.size, style=0) 17 | 18 | # The system add wCaption automatically for a top-level window, 19 | # We must clear it for a shaped window. 20 | frame.clearWindowStyle(wCaption) 21 | 22 | frame.setDraggable(true) 23 | frame.shape = Region(image) 24 | 25 | let menu = Menu() 26 | menu.append(wIdExit, "E&xit") 27 | 28 | frame.wIdExit do (): 29 | frame.close() 30 | 31 | frame.wEvent_ContextMenu do (event: wEvent): 32 | frame.popupMenu(menu) 33 | 34 | frame.wEvent_Paint do (event: wEvent): 35 | var dc = PaintDC(frame) 36 | dc.drawImage(image) 37 | 38 | frame.center() 39 | frame.show() 40 | app.mainLoop() 41 | 42 | -------------------------------------------------------------------------------- /examples/subclassing.nim: -------------------------------------------------------------------------------- 1 | #==================================================================== 2 | # 3 | # wNim - Nim's Windows GUI Framework 4 | # Copyright (c) Chen Kai-Hung, Ward 5 | # 6 | #==================================================================== 7 | 8 | import resource/resource 9 | import wNim/[wApp, wMacros, wFrame, wMessageDialog, wIcon] 10 | 11 | # wNim's class/object use following naming convention. 12 | # 1. Class name starts with 'w' and define as ref object. e.g. wObject. 13 | # 2. Every class have init(self: wObject) as initializer. 14 | # 3. Provides an Object() proc to quickly get the ref object. 15 | 16 | # wClass (defined in wMacros) provides a convenient way to define wNim class. 17 | 18 | wClass(wMyFrame of wFrame): 19 | # Constructor is generated from initializer and finalizer automatically. 20 | 21 | proc init(self: wMyFrame, title: string) = 22 | wFrame(self).init(title=title, size=(350, 200)) 23 | self.center() 24 | 25 | self.wEvent_Destroy do (): 26 | MessageDialog(self, "wMyFrame is about to destroy.", 27 | "wEvent_Destroy", wOk or wStayOnTop).showModal() 28 | 29 | self.wEvent_Close do (event: wEvent): 30 | let dlg = MessageDialog(self, "Do you really want to close this application?", 31 | "Confirm Exit", wOkCancel or wIconQuestion) 32 | 33 | if dlg.showModal() != wIdOk: 34 | event.veto() 35 | 36 | proc final(self: wMyFrame) = 37 | # Don't need to call parent's final() 38 | MessageDialog(nil, "A custom finalizer is optional.", "Finalizer").display() 39 | 40 | when isMainModule: 41 | let app = App(wSystemDpiAware) 42 | let frame = MyFrame("Hello World") 43 | frame.icon = Icon("", 0) # load icon from exe file. 44 | 45 | frame.show() 46 | app.mainLoop() 47 | -------------------------------------------------------------------------------- /examples/textctrl.nim: -------------------------------------------------------------------------------- 1 | #==================================================================== 2 | # 3 | # wNim - Nim's Windows GUI Framework 4 | # Copyright (c) Chen Kai-Hung, Ward 5 | # 6 | #==================================================================== 7 | 8 | import resource/resource 9 | import wNim/[wApp, wFrame, wTextCtrl, wFont, wImage, wIcon] 10 | import winim/winstr, winim/inc/shellapi 11 | import std/with 12 | 13 | const logo = staticRead(r"images/nim.png") 14 | 15 | let app = App(wSystemDpiAware) 16 | let frame = Frame(title="wNim wTextCtrl", size=(640, 460)) 17 | frame.icon = Icon("", 0) # load icon from exe file. 18 | 19 | let textctrl = TextCtrl(frame, style=wTeRich or wTeMultiLine) 20 | textctrl.backgroundColor = 0x2a201e 21 | 22 | let largeFont = Font(20, weight=900, faceName="Tahoma") 23 | let smallFont = Font(12, weight=900, faceName="Tahoma") 24 | 25 | with textctrl: 26 | writeText("\n") 27 | setStyle(lineSpacing=1.5, indent=288) 28 | writeImage(Image(logo), 0.6) 29 | writeText("\n") 30 | 31 | setFormat(largeFont, fgColor=0x53e9ff) 32 | setStyle(lineSpacing=1.5) 33 | writeText("Efficient, expressive, elegant\n") 34 | 35 | setFormat(smallFont, fgColor=wWhite) 36 | setStyle(lineSpacing=1) 37 | writeText("Nim is a statically typed compiled systems programming language. It combines successful concepts from mature languages like Python, Ada and Modula.\n\n") 38 | 39 | setFormat(smallFont, fgColor=wBlack, bgColor=0x53e9ff) 40 | setStyle(align=wTextAlignCenter, lineSpacing=1.5, spaceBefore=100) 41 | writeText(" ") 42 | writeLink("https://nim-lang.org/", "Install Nim") 43 | setFormat(smallFont, fgColor=wBlack, bgColor=0x53e9ff) 44 | writeText(" ") 45 | setFormat(fgColor=0x2a201e, bgColor=0x2a201e) 46 | writeText(" ") 47 | setFormat(smallFont, fgColor=wBlack, bgColor=0xb3b3b3) 48 | writeText(" ") 49 | writeLink("https://play.nim-lang.org/", "Try it online") 50 | setFormat(smallFont, fgColor=wBlack, bgColor=0xb3b3b3) 51 | writeText(" \n") 52 | resetStyle() 53 | 54 | textctrl.wEvent_TextLink do (event: wEvent): 55 | if event.mouseEvent == wEvent_LeftUp: 56 | let url = textctrl.range(event.start..) 79 | 3. Run "nimble install" 80 | 81 | ## Import 82 | The easiest way to use wNim is to import the whole package. 83 | 84 | ```nim 85 | import wNim 86 | ``` 87 | 88 | However, the modules of wNim can also be imported one by one to speed up compilation time. 89 | 90 | ```nim 91 | import wNim/[wApp, wFrame] 92 | ``` 93 | 94 | There are some simple rules: 95 | 96 | 1. For every class in wNim, there is a corresponding module. 97 | For example: wFrame, wIcon, wMenu, etc. 98 | 2. The wApp module must be imported into every wNim program. 99 | 3. Symbols in wColors and wKeyCodes modules are imported automatically with the wApp module. 100 | 4. All event classes in wNim share the same constructor: Event(), so all subclass modules 101 | of wEvent will be automatically imported with the wEvent module. 102 | 5. wMacros, wUtils, and wTypes modules are three special modules in wNim. 103 | See their documentation for more information. 104 | 105 | ## Compile 106 | To compile the examples, try the following command: 107 | 108 | nim c -d:release -d:strip --opt:size --app:gui demo.nim 109 | 110 | For Windows XP compatibility, add: 111 | 112 | -d:useWinXP 113 | 114 | To compile wNim with the [Tiny C Compiler](https://bellard.org/tcc/) or to add resource files, take a look at https://github.com/khchen/winim/tree/master/tcclib 115 | 116 | ## Q & A 117 | ### Q: Why did I start this project? 118 | At first, I just wanted to write some code to test and prove my Winim library. 119 | I wrote some event handlers, some GUI control classes, and more. Finally, it 120 | became a whole GUI framework. 121 | 122 | ### Q: Why do the class and API names look so alike wxWidgets? 123 | English is not my mother tongue. I often have no idea how to name an object or 124 | a function. So, I borrowed wxWidgets' names to develop my own framework. 125 | 126 | ### Q: Why not add Linux or macOS support? 127 | I start from winim. It is just a Windows API module. 128 | 129 | ### Q: How is wNim compare to nimx, libui, NiGui etc? 130 | They are all good GUI libraries. I think wNim is easier to use and produces smaller .exe files. 131 | However, it only supports Windows. 132 | 133 | ## Docs 134 | * https://khchen.github.io/wNim/wNim.html 135 | * https://github.com/khchen/wNim/wiki 136 | 137 | ## License 138 | Read license.txt for more details. 139 | 140 | Copyright (c) Chen Kai-Hung, Ward. All rights reserved. 141 | 142 | ## Donate 143 | If this project help you reduce time to develop, you can give me a cup of coffee :) 144 | 145 | [![paypal](https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif)](https://paypal.me/khchen0915?country.x=TW&locale.x=zh_TW) 146 | -------------------------------------------------------------------------------- /wNim/autolayout.nim: -------------------------------------------------------------------------------- 1 | #==================================================================== 2 | # 3 | # wNim - Nim's Windows GUI Framework 4 | # Copyright (c) Chen Kai-Hung, Ward 5 | # 6 | #==================================================================== 7 | 8 | import private/autolayout 9 | export autolayout 10 | -------------------------------------------------------------------------------- /wNim/private/consts/wColors.nim: -------------------------------------------------------------------------------- 1 | #==================================================================== 2 | # 3 | # wNim - Nim's Windows GUI Framework 4 | # Copyright (c) Chen Kai-Hung, Ward 5 | # 6 | #==================================================================== 7 | 8 | import ../wTypes 9 | 10 | ## The commonly used color value. 11 | 12 | const 13 | wAquamarine*: wColor = 0x093DB70 14 | wBlack*: wColor = 0x0000000 15 | wBlue*: wColor = 0x0FF0000 16 | wBlueViolet*: wColor = 0x09F5F9F 17 | wBrown*: wColor = 0x02A2AA5 18 | wCadetBlue*: wColor = 0x09F9F5F 19 | wCoral*: wColor = 0x0007FFF 20 | wCornflowerBlue*: wColor = 0x06F4242 21 | wCyan*: wColor = 0x0FFFF00 22 | wDarkGreen*: wColor = 0x02F4F2F 23 | wDarkGrey*: wColor = 0x02F2F2F 24 | wDarkOliveGreen*: wColor = 0x02F4F4F 25 | wDarkOrchid*: wColor = 0x0CC3299 26 | wDarkSlateBlue*: wColor = 0x08E236B 27 | wDarkSlateGrey*: wColor = 0x04F4F2F 28 | wDarkTurquoise*: wColor = 0x0DB9370 29 | wDimGrey*: wColor = 0x0545454 30 | wFireBrick*: wColor = 0x023238E 31 | wForestGreen*: wColor = 0x0238E23 32 | wGold*: wColor = 0x0327FCC 33 | wGoldenrod*: wColor = 0x070DBDB 34 | wGreen*: wColor = 0x000FF00 35 | wGreenYellow*: wColor = 0x070DB93 36 | wGrey*: wColor = 0x0808080 37 | wIndianRed*: wColor = 0x02F2F4F 38 | wKhaki*: wColor = 0x05F9F9F 39 | wLightBlue*: wColor = 0x0D8D8BF 40 | wLightGrey*: wColor = 0x0C0C0C0 41 | wLightMagenta*: wColor = 0x0E78BE7 42 | wLightSteelBlue*: wColor = 0x0BC8F8F 43 | wLimeGreen*: wColor = 0x032CC32 44 | wMagenta*: wColor = 0x0FF00FF 45 | wMaroon*: wColor = 0x06B238E 46 | wMediumAquamarine*: wColor = 0x099CC32 47 | wMediumBlue*: wColor = 0x0CC3232 48 | wMediumForestGreen*: wColor = 0x0238E6B 49 | wMediumGoldenrod*: wColor = 0x0ADEAEA 50 | wMediumGrey*: wColor = 0x0646464 51 | wMediumOrchid*: wColor = 0x0DB7093 52 | wMediumSeaGreen*: wColor = 0x0426F42 53 | wMediumSlateBlue*: wColor = 0x0FF007F 54 | wMediumSpringGreen*: wColor = 0x000FF7F 55 | wMediumTurquoise*: wColor = 0x0DBDB70 56 | wMediumVioletRed*: wColor = 0x09370DB 57 | wMidnightBlue*: wColor = 0x04F2F2F 58 | wNavy*: wColor = 0x08E2323 59 | wOrange*: wColor = 0x03232CC 60 | wOrangeRed*: wColor = 0x07F00FF 61 | wOrchid*: wColor = 0x0DB70DB 62 | wPaleGreen*: wColor = 0x08FBC8F 63 | wPink*: wColor = 0x0EA8FBC 64 | wPlum*: wColor = 0x0EAADEA 65 | wPurple*: wColor = 0x0FF00B0 66 | wRed*: wColor = 0x00000FF 67 | wSalmon*: wColor = 0x042426F 68 | wSeaGreen*: wColor = 0x06B8E23 69 | wSienna*: wColor = 0x0236B8E 70 | wSkyBlue*: wColor = 0x0CC9932 71 | wSlateBlue*: wColor = 0x0FF7F00 72 | wSpringGreen*: wColor = 0x07FFF00 73 | wSteelBlue*: wColor = 0x08E6B23 74 | wTan*: wColor = 0x07093DB 75 | wThistle*: wColor = 0x0D8BFD8 76 | wTurquoise*: wColor = 0x0EAEAAD 77 | wViolet*: wColor = 0x04F2F4F 78 | wVioletRed*: wColor = 0x09932CC 79 | wWheat*: wColor = 0x0BFD8D8 80 | wWhite*: wColor = 0x0FFFFFF 81 | wYellow*: wColor = 0x000FFFF 82 | wYellowGreen*: wColor = 0x032CC99 83 | -------------------------------------------------------------------------------- /wNim/private/controls/wRadioButton.nim: -------------------------------------------------------------------------------- 1 | #==================================================================== 2 | # 3 | # wNim - Nim's Windows GUI Framework 4 | # Copyright (c) Chen Kai-Hung, Ward 5 | # 6 | #==================================================================== 7 | 8 | ## A radio button item is a button which usually denotes one of several mutually 9 | ## exclusive options. 10 | # 11 | ## :Appearance: 12 | ## .. image:: images/wRadioButton.png 13 | # 14 | ## :Superclass: 15 | ## `wControl `_ 16 | # 17 | ## :Styles: 18 | ## ============================== ============================================================= 19 | ## Styles Description 20 | ## ============================== ============================================================= 21 | ## wRbGroup Marks the beginning of a new group of radio buttons. 22 | ## ============================== ============================================================= 23 | # 24 | ## :Events: 25 | ## `wCommandEvent `_ 26 | ## ============================== ============================================================= 27 | ## wCommandEvent Description 28 | ## ============================== ============================================================= 29 | ## wEvent_RadioButton The radio button is clicked. 30 | ## =============================== ============================================================= 31 | 32 | include ../pragma 33 | import ../wBase, wControl 34 | export wControl 35 | 36 | const 37 | # RadioButton styles 38 | wRbGroup* = WS_GROUP 39 | 40 | method getBestSize*(self: wRadioButton): wSize {.property.} = 41 | ## Returns the best acceptable minimal size for the control. 42 | result = getTextFontSizeWithCheckMark(self.getLabel(), self.mFont.mHandle, self.mHwnd) 43 | result.height += 2 44 | 45 | method getDefaultSize*(self: wRadioButton): wSize {.property.} = 46 | ## Returns the default size for the control. 47 | result = self.getBestSize() 48 | result.height = getLineControlDefaultHeight(self.mFont.mHandle) 49 | 50 | proc getValue*(self: wRadioButton): bool {.validate, property, inline.} = 51 | ## Returns true if the radio button is checked, false otherwise. 52 | result = SendMessage(self.mHwnd, BM_GETCHECK, 0, 0) == BST_CHECKED 53 | 54 | proc setValue*(self: wRadioButton, state: bool) {.validate, property, inline.} = 55 | ## Sets the radio button to checked or unchecked status. 56 | SendMessage(self.mHwnd, BM_SETCHECK, if state: BST_CHECKED else: BST_UNCHECKED, 0) 57 | 58 | proc click*(self: wRadioButton) {.validate, inline.} = 59 | ## Simulates the user clicking a radiobutton. 60 | SendMessage(self.mHwnd, BM_CLICK, 0, 0) 61 | 62 | wClass(wRadioButton of wControl): 63 | 64 | method release*(self: wRadioButton) = 65 | ## Release all the resources during destroying. Used internally. 66 | self.mParent.systemDisconnect(self.mCommandConn) 67 | free(self[]) 68 | 69 | proc init*(self: wRadioButton, parent: wWindow, id = wDefaultID, 70 | label: string = "", pos = wDefaultPoint, size = wDefaultSize, 71 | style: wStyle = 0) {.validate.} = 72 | ## Initializes radio button 73 | wValidate(parent) 74 | # clear last 4 bits, they indicates the button type (checkbox, radiobutton, etc) 75 | let style = (style and (not 0xF)) or BS_AUTORADIOBUTTON 76 | 77 | self.wControl.init(className=WC_BUTTON, parent=parent, id=id, label=label, 78 | pos=pos, size=size, style=style or WS_CHILD or WS_VISIBLE or WS_TABSTOP) 79 | 80 | self.mCommandConn = parent.systemConnect(WM_COMMAND) do (event: wEvent): 81 | if event.mLparam == self.mHwnd and HIWORD(event.mWparam) == BN_CLICKED: 82 | self.processMessage(wEvent_RadioButton, event.mWparam, event.mLparam) 83 | -------------------------------------------------------------------------------- /wNim/private/controls/wSpinButton.nim: -------------------------------------------------------------------------------- 1 | #==================================================================== 2 | # 3 | # wNim - Nim's Windows GUI Framework 4 | # Copyright (c) Chen Kai-Hung, Ward 5 | # 6 | #==================================================================== 7 | 8 | ## A wSpinButton has two small up and down (or left and right) arrow buttons. 9 | # 10 | ## :Appearance: 11 | ## .. image:: images/wSpinButton.png 12 | # 13 | ## :Superclass: 14 | ## `wControl `_ 15 | # 16 | ## :Styles: 17 | ## ============================== ============================================================= 18 | ## Styles Description 19 | ## ============================== ============================================================= 20 | ## wSpVertical Specifies a vertical spin button. 21 | ## wSpHorizontal Specifies a horizontal spin button. 22 | ## ============================== ============================================================= 23 | # 24 | ## :Events: 25 | ## `wSpinEvent `_ 26 | 27 | include ../pragma 28 | import ../wBase, wControl 29 | export wControl 30 | 31 | const 32 | wSpVertical* = 0 33 | wSpHorizontal* = UDS_HORZ 34 | 35 | proc isVertical*(self: wSpinButton): bool {.validate, inline.} = 36 | ## Returns true if the spin button is vertical and false otherwise. 37 | result = (GetWindowLongPtr(self.mHwnd, GWL_STYLE) and UDS_HORZ) == 0 38 | 39 | method getDefaultSize*(self: wSpinButton): wSize {.property.} = 40 | ## Returns the default size for the control. 41 | let isVert = self.isVertical() 42 | result.width = GetSystemMetrics(if isVert: SM_CXVSCROLL else: SM_CXHSCROLL) 43 | result.height = GetSystemMetrics(if isVert: SM_CYVSCROLL else: SM_CYHSCROLL) 44 | if isVert: 45 | result.height *= 2 46 | else: 47 | result.width *= 2 48 | 49 | method getBestSize*(self: wSpinButton): wSize {.property, inline.} = 50 | ## Returns the best acceptable minimal size for the control. 51 | result = self.getDefaultSize() 52 | 53 | proc wSpinButton_OnNotify(self: wSpinButton, event: wEvent) = 54 | var processed = false 55 | defer: event.skip(if processed: false else: true) 56 | 57 | let lpnmud = cast[LPNMUPDOWN](event.mLparam) 58 | if lpnmud.hdr.hwndFrom == self.mHwnd and lpnmud.hdr.code == UDN_DELTAPOS: 59 | var 60 | spinEvent = Event(window=self, msg=wEvent_Spin, wParam=event.mWparam, lParam=event.mLparam) 61 | directionMsg = 0 62 | 63 | if self.isVertical(): 64 | if lpnmud.iDelta > 0: directionMsg = wEvent_SpinDown 65 | elif lpnmud.iDelta < 0: directionMsg = wEvent_SpinUp 66 | else: 67 | if lpnmud.iDelta > 0: directionMsg = wEvent_SpinLeft 68 | elif lpnmud.iDelta < 0: directionMsg = wEvent_SpinRight 69 | 70 | if directionMsg != 0: 71 | spinEvent.mMsg = directionMsg 72 | processed = self.processEvent(spinEvent) 73 | 74 | if not processed: 75 | spinEvent.mMsg = wEvent_Spin 76 | processed = self.processEvent(spinEvent) 77 | 78 | if processed: 79 | event.mResult = spinEvent.mResult 80 | 81 | wClass(wSpinButton of wControl): 82 | 83 | method release*(self: wSpinButton) = 84 | ## Release all the resources during destroying. Used internally. 85 | self.mParent.disconnect(self.mNotifyConn) 86 | free(self[]) 87 | 88 | proc init*(self: wSpinButton, parent: wWindow, id = wDefaultID, 89 | pos = wDefaultPoint, size = wDefaultSize, style: wStyle = wSpVertical) {.validate.} = 90 | ## Initializes a spin button. 91 | wValidate(parent) 92 | # up-down control without buddy window cannot have a focus 93 | # (in fact, it do have a focus but without any visual change) 94 | # so UDS_ARROWKEYS have no use here. How to fix? 95 | # since that, just don't add WS_TAB 96 | 97 | self.wControl.init(className=UPDOWN_CLASS, parent=parent, id=id, pos=pos, size=size, 98 | style=style or UDS_HOTTRACK or WS_CHILD or WS_VISIBLE) 99 | 100 | self.mNotifyConn = parent.hardConnect(WM_NOTIFY) do (event: wEvent): 101 | wSpinButton_OnNotify(self, event) 102 | -------------------------------------------------------------------------------- /wNim/private/controls/wStaticBitmap.nim: -------------------------------------------------------------------------------- 1 | #==================================================================== 2 | # 3 | # wNim - Nim's Windows GUI Framework 4 | # Copyright (c) Chen Kai-Hung, Ward 5 | # 6 | #==================================================================== 7 | 8 | ## A static bitmap control displays a bitmap. 9 | # 10 | ## :Appearance: 11 | ## .. image:: images/wStaticBitmap.png 12 | # 13 | ## :Superclass: 14 | ## `wControl `_ 15 | # 16 | ## :Styles: 17 | ## ============================== ============================================================= 18 | ## Styles Description 19 | ## ============================== ============================================================= 20 | ## wSbAuto Automatically sizes the control to accommodate the bitmap. 21 | ## wSbFit Stretch or shrink the bitmap to fit the size. 22 | ## wSbCenter Center the bitmap and clip if needed. 23 | ## ============================== ============================================================= 24 | # 25 | ## :Events: 26 | ## `wCommandEvent `_ 27 | ## ============================== ============================================================= 28 | ## wCommandEvent Description 29 | ## ============================== ============================================================= 30 | ## wEvent_CommandLeftClick Clicked the left mouse button within the control. 31 | ## wEvent_CommandLeftDoubleClick Double-clicked the left mouse button within the control. 32 | ## =============================== ============================================================= 33 | 34 | include ../pragma 35 | import ../wBase, ../gdiobjects/wBitmap, wControl, wStaticText 36 | export wControl 37 | 38 | const 39 | # StaticBitmap styles 40 | wSbAuto* = 0 41 | wSbFit* = SS_REALSIZECONTROL 42 | wSbCenter* = SS_CENTERIMAGE 43 | 44 | method getBestSize*(self: wStaticBitmap): wSize {.property, inline.} = 45 | ## Returns the best acceptable minimal size for the control. 46 | if self.mBitmap != nil: 47 | result = self.mBitmap.getSize() 48 | 49 | method getDefaultSize*(self: wStaticBitmap): wSize {.property, inline.} = 50 | ## Returns the default size for the control. 51 | if self.mBitmap != nil: 52 | result = self.mBitmap.getSize() 53 | 54 | proc setBitmap*(self: wStaticBitmap, bitmap: wBitmap) {.validate, property.} = 55 | ## Sets the bitmap label. 56 | self.mBitmap = bitmap 57 | SendMessage(self.mHwnd, STM_SETIMAGE, IMAGE_BITMAP, 58 | if bitmap != nil: bitmap.mHandle else: 0) 59 | 60 | proc getBitmap*(self: wStaticBitmap): wBitmap {.validate, property, inline.} = 61 | ## Returns the bitmap currently used in the control. 62 | result = self.mBitmap 63 | 64 | wClass(wStaticBitmap of wControl): 65 | 66 | method release*(self: wStaticBitmap) = 67 | ## Release all the resources during destroying. Used internally. 68 | self.mParent.systemDisconnect(self.mCommandConn) 69 | free(self[]) 70 | 71 | proc init*(self: wStaticBitmap, parent: wWindow, id = wDefaultID, 72 | bitmap: wBitmap = nil, pos = wDefaultPoint, size = wDefaultSize, 73 | style: wStyle = wSbAuto) {.validate.} = 74 | ## Initializes static bitmap control. 75 | # Accepts nil bitmap for later assign. 76 | wValidate(parent) 77 | self.wControl.init(className=WC_STATIC, parent=parent, id=id, label="", 78 | pos=pos, size=size, style=style or WS_CHILD or WS_VISIBLE or SS_NOTIFY or SS_BITMAP) 79 | 80 | self.setBitmap(bitmap) 81 | self.mFocusable = false 82 | 83 | # translate wEvent_CommandLeftClick and wEvent_CommandLeftDoubleClick 84 | self.mCommandConn = parent.systemConnect(WM_COMMAND) do (event: wEvent): 85 | self.wStaticText_DoCommand(event) 86 | -------------------------------------------------------------------------------- /wNim/private/controls/wStaticBox.nim: -------------------------------------------------------------------------------- 1 | #==================================================================== 2 | # 3 | # wNim - Nim's Windows GUI Framework 4 | # Copyright (c) Chen Kai-Hung, Ward 5 | # 6 | #==================================================================== 7 | 8 | ## A static box is a rectangle drawn around other windows to denote a logical 9 | ## grouping of items. 10 | # 11 | ## :Appearance: 12 | ## .. image:: images/wStaticBox.png 13 | # 14 | ## :Superclass: 15 | ## `wControl `_ 16 | 17 | include ../pragma 18 | import ../wBase, wControl 19 | export wControl 20 | 21 | proc getLabelSize(self: wStaticBox): wSize {.property.} = 22 | result = getTextFontSize(self.getLabel() & " ", self.mFont.mHandle, self.mHwnd) 23 | 24 | method getBestSize*(self: wStaticBox): wSize {.property.} = 25 | ## Returns the best acceptable minimal size for the control. 26 | result = self.getLabelSize() 27 | result.width += 2 28 | result.height += 2 29 | 30 | method getDefaultSize*(self: wStaticBox): wSize {.property.} = 31 | ## Returns the default size for the control. 32 | result.width = 120 33 | result.height = getLineControlDefaultHeight(self.mFont.mHandle) 34 | 35 | method getClientAreaOrigin*(self: wStaticBox): wPoint {.property.} = 36 | ## Get the origin of the client area of the window relative to the window top 37 | ## left corner. 38 | result.x = self.mMargin.left 39 | result.y = self.mMargin.up 40 | let labelSize = self.getLabelSize() 41 | result.y += labelSize.height div 2 42 | 43 | method getClientSize*(self: wStaticBox): wSize {.property.} = 44 | ## Returns the size of the window 'client area' in pixels. 45 | result = procCall wWindow(self).getClientSize() 46 | let labelSize = self.getLabelSize() 47 | result.height -= labelSize.height div 2 48 | 49 | wClass(wStaticBox of wControl): 50 | 51 | method release*(self: wStaticBox) = 52 | ## Release all the resources during destroying. Used internally. 53 | free(self[]) 54 | 55 | proc init*(self: wStaticBox, parent: wWindow, id = wDefaultID, label: string = "", 56 | pos = wDefaultPoint, size = wDefaultSize, style: wStyle = 0) {.validate.} = 57 | ## Initializes a static box. 58 | wValidate(parent, label) 59 | # staticbox need WS_CLIPSIBLINGS 60 | self.wControl.init(className=WC_BUTTON, parent=parent, id=id, label=label, 61 | pos=pos, size=size, style=style or WS_CHILD or WS_VISIBLE or BS_GROUPBOX or 62 | WS_CLIPSIBLINGS) 63 | 64 | self.mFocusable = false 65 | self.setMargin(12) 66 | -------------------------------------------------------------------------------- /wNim/private/controls/wStaticLine.nim: -------------------------------------------------------------------------------- 1 | #==================================================================== 2 | # 3 | # wNim - Nim's Windows GUI Framework 4 | # Copyright (c) Chen Kai-Hung, Ward 5 | # 6 | #==================================================================== 7 | 8 | ## A static line is just a line which may be used to separate the groups of 9 | ## controls. 10 | # 11 | ## :Appearance: 12 | ## .. image:: images/wStaticLine.png 13 | # 14 | ## :Superclass: 15 | ## `wControl `_ 16 | # 17 | ## :Styles: 18 | ## ============================== ============================================================= 19 | ## Styles Description 20 | ## ============================== ============================================================= 21 | ## wLiHorizontal Creates a horizontal line. 22 | ## wLiVertical Creates a vertical line. 23 | ## ============================== ============================================================= 24 | 25 | include ../pragma 26 | import ../wBase, wControl 27 | export wControl 28 | 29 | const 30 | wLiHorizontal* = SS_LEFT # 0 31 | wLiVertical* = SS_RIGHT # 2 32 | 33 | method getDefaultSize*(self: wStaticLine): wSize {.property.} = 34 | ## Returns the default size for the control. 35 | let 36 | pos = self.getPosition() 37 | clientSize = self.mParent.getClientSize() 38 | isVertical = (GetWindowLongPtr(self.mHwnd, GWL_STYLE) and wLiVertical) != 0 39 | 40 | if isVertical: 41 | result.width = 2 42 | result.height = clientSize.height - pos.y * 2 43 | else: 44 | result.height = 2 45 | result.width = clientSize.width - pos.x * 2 46 | 47 | method getBestSize*(self: wStaticLine): wSize {.property, inline.} = 48 | ## Returns the best acceptable minimal size for the control. 49 | result = self.getDefaultSize() 50 | 51 | proc isVertical*(self: wStaticLine): bool {.validate.} = 52 | ## Returns true if the line is vertical, false if horizontal. 53 | result = (self.getWindowStyle() and wLiVertical) != 0 54 | 55 | wClass(wStaticLine of wControl): 56 | 57 | method release*(self: wStaticLine) = 58 | ## Release all the resources during destroying. Used internally. 59 | free(self[]) 60 | 61 | proc init*(self: wStaticLine, parent: wWindow, id = wDefaultID, pos = wDefaultPoint, 62 | size = wDefaultSize, style: wStyle = wLiHorizontal) {.validate.} = 63 | ## Initializes a static line 64 | wValidate(parent) 65 | var size = size 66 | if size != wDefaultSize: 67 | if (style and wLiVertical) != 0: 68 | size.width = 2 69 | else: 70 | size.height = 2 71 | 72 | self.wControl.init(className=WC_STATIC, parent=parent, id=id, 73 | pos=pos, size=size, style=style or WS_CHILD or WS_VISIBLE or SS_NOTIFY or SS_SUNKEN) 74 | 75 | self.mFocusable = false 76 | -------------------------------------------------------------------------------- /wNim/private/controls/wStaticText.nim: -------------------------------------------------------------------------------- 1 | #==================================================================== 2 | # 3 | # wNim - Nim's Windows GUI Framework 4 | # Copyright (c) Chen Kai-Hung, Ward 5 | # 6 | #==================================================================== 7 | 8 | ## A static text control displays one or more lines of read-only text. 9 | # 10 | ## :Appearance: 11 | ## .. image:: images/wStaticText.png 12 | # 13 | ## :Superclass: 14 | ## `wControl `_ 15 | ## 16 | ## :Styles: 17 | ## ============================== ============================================================= 18 | ## Styles Description 19 | ## ============================== ============================================================= 20 | ## wAlignLeft Align the text to the left. 21 | ## wAlignRight Align the text to the right. 22 | ## wAlignCentre Center the text (horizontally). 23 | ## wAlignCenter Center the text (horizontally). 24 | ## wAlignMiddle Center the text (vertically). 25 | ## wAlignLeftNoWordWrap Align the text to the left, but words are not wrapped 26 | ## ============================== ============================================================= 27 | # 28 | ## :Events: 29 | ## `wCommandEvent `_ 30 | ## ============================== ============================================================= 31 | ## wCommandEvent Description 32 | ## ============================== ============================================================= 33 | ## wEvent_CommandLeftClick Clicked the left mouse button within the control. 34 | ## wEvent_CommandLeftDoubleClick Double-clicked the left mouse button within the control. 35 | ## =============================== ============================================================= 36 | 37 | include ../pragma 38 | import ../wBase, wControl 39 | export wControl 40 | 41 | const 42 | wAlignLeft* = SS_LEFT 43 | wAlignRight* = SS_RIGHT 44 | wAlignCentre* = SS_CENTER 45 | wAlignCenter* = SS_CENTER 46 | wAlignMiddle* = SS_CENTERIMAGE 47 | wAlignLeftNoWordWrap* = SS_LEFTNOWORDWRAP 48 | 49 | method getBestSize*(self: wStaticText): wSize {.property.} = 50 | ## Returns the best acceptable minimal size for the control. 51 | result = getTextFontSize(self.getLabel(), self.mFont.mHandle, self.mHwnd) 52 | result.width += 2 53 | result.height += 2 54 | 55 | method getDefaultSize*(self: wStaticText): wSize {.property.} = 56 | ## Returns the default size for the control. 57 | result = self.getBestSize() 58 | result.height = getLineControlDefaultHeight(self.mFont.mHandle) 59 | 60 | proc wStaticText_DoCommand(self: wControl, event: wEvent) {.shield.} = 61 | # also used in wStaticBitmap 62 | if event.mLparam == self.mHwnd: 63 | case HIWORD(event.mWparam) 64 | of STN_CLICKED: 65 | self.processMessage(wEvent_CommandLeftClick, event.mWparam, event.mLparam) 66 | of STN_DBLCLK: 67 | self.processMessage(wEvent_CommandLeftDoubleClick, event.mWparam, event.mLparam) 68 | else: discard 69 | 70 | wClass(wStaticText of wControl): 71 | 72 | method release*(self: wStaticText) = 73 | ## Release all the resources during destroying. Used internally. 74 | self.mParent.systemDisconnect(self.mCommandConn) 75 | free(self[]) 76 | 77 | proc init*(self: wStaticText, parent: wWindow, id = wDefaultID, 78 | label: string = "", pos = wDefaultPoint, size = wDefaultSize, 79 | style: wStyle = wAlignLeft) {.validate.} = 80 | ## Initializes static text control. 81 | wValidate(parent) 82 | self.wControl.init(className=WC_STATIC, parent=parent, id=id, label=label, 83 | pos=pos, size=size, style=style or WS_CHILD or WS_VISIBLE or SS_NOTIFY) 84 | 85 | self.mFocusable = false 86 | 87 | self.mCommandConn = parent.systemConnect(WM_COMMAND) do (event: wEvent): 88 | self.wStaticText_DoCommand(event) 89 | 90 | self.systemConnect(WM_SIZE) do (event: wEvent): 91 | # when size change, StaticText should refresh itself, but windows system don't do it 92 | self.refresh() 93 | -------------------------------------------------------------------------------- /wNim/private/controls/wTimePickerCtrl.nim: -------------------------------------------------------------------------------- 1 | #==================================================================== 2 | # 3 | # wNim - Nim's Windows GUI Framework 4 | # Copyright (c) Chen Kai-Hung, Ward 5 | # 6 | #==================================================================== 7 | 8 | ## This control allows the user to enter time. 9 | # 10 | ## :Appearance: 11 | ## .. image:: images/wTimePickerCtrl.png 12 | # 13 | ## :Superclass: 14 | ## `wControl `_ 15 | # 16 | ## :Events: 17 | ## `wCommandEvent `_ 18 | ## ============================== ============================================================= 19 | ## wCommandEvent Description 20 | ## ============================== ============================================================= 21 | ## wEvent_TimeChanged The selected time changed. 22 | ## =============================== ============================================================= 23 | 24 | include ../pragma 25 | import ../wBase, wControl, wDatePickerCtrl 26 | export wControl 27 | 28 | proc getTime*(self: wTimePickerCtrl): tuple[hour, min, sec: int] 29 | {.validate, property.} = 30 | ## Returns the currently entered time as hours, minutes and seconds 31 | var st: SYSTEMTIME 32 | if GDT_VALID == SendMessage(self.mHwnd, DTM_GETSYSTEMTIME, 0, addr st): 33 | result.hour = st.wHour.int 34 | result.min = st.wMinute.int 35 | result.sec = st.wSecond.int 36 | 37 | proc setTime*(self: wTimePickerCtrl, hour: int, min: int, sec: int) 38 | {.validate, property.} = 39 | ## Changes the current time of the control. 40 | var st: SYSTEMTIME 41 | GetLocalTime(addr st) 42 | st.wHour = hour.WORD 43 | st.wMinute = min.WORD 44 | st.wSecond = sec.WORD 45 | SendMessage(self.mHwnd, DTM_SETSYSTEMTIME, GDT_VALID, addr st) 46 | 47 | proc setTime*(self: wTimePickerCtrl, time: tuple[hour, min, sec: int]) 48 | {.validate, property.} = 49 | ## Changes the current time of the control. 50 | self.setTime(time.hour, time.min, time.sec) 51 | 52 | wClass(wTimePickerCtrl of wDatePickerCtrl): 53 | 54 | method release*(self: wTimePickerCtrl) = 55 | ## Release all the resources during destroying. Used internally. 56 | free(self[]) 57 | 58 | proc init*(self: wTimePickerCtrl, parent: wWindow, id = wDefaultID, 59 | time = wDefaultTime, pos = wDefaultPoint, size = wDefaultSize, 60 | style: wStyle = 0) {.validate.} = 61 | ## Initializes a time picker control. 62 | ## ========== ================================================================================= 63 | ## Parameters Description 64 | ## ========== ================================================================================= 65 | ## parent Parent window. 66 | ## id The identifier for the control. 67 | ## time The initial value of the control, if an invalid date (such as the default value) is used, the control is set to current time. 68 | ## pos Initial position. 69 | ## size Initial size. If left at default value, the control chooses its own best size. 70 | ## style The window style, should be left at 0 as there are no special styles for this control. 71 | wValidate(parent) 72 | self.wDatePickerCtrl.init(parent=parent, id=id, date=time, pos=pos, 73 | size=size, style=style or DTS_TIMEFORMAT) 74 | -------------------------------------------------------------------------------- /wNim/private/dc/wClientDC.nim: -------------------------------------------------------------------------------- 1 | #==================================================================== 2 | # 3 | # wNim - Nim's Windows GUI Framework 4 | # Copyright (c) Chen Kai-Hung, Ward 5 | # 6 | #==================================================================== 7 | 8 | ## A wClientDC must be constructed if an application wishes to paint on the 9 | ## client area of a window. 10 | ## 11 | ## Like other DC object, wClientDC need nim's destructors to release the resource. 12 | # 13 | ## :Superclass: 14 | ## `wDC `_ 15 | 16 | include ../pragma 17 | import ../wBase, ../wWindow, wDC 18 | export wDC 19 | 20 | method getSize*(self: wClientDC): wSize {.property.} = 21 | ## Gets the size of the device context. 22 | result = self.mCanvas.getClientSize() 23 | 24 | proc ClientDC*(canvas: wWindow): wClientDC = 25 | ## Constructor. 26 | wValidate(canvas) 27 | result.mCanvas = canvas 28 | result.mHdc = GetDC(canvas.mHwnd) 29 | result.wDC.init(fgColor=canvas.mForegroundColor, bgColor=canvas.mBackgroundColor, 30 | background=canvas.mBackgroundColor, font=canvas.mFont) 31 | 32 | proc delete*(self: var wClientDC) = 33 | ## Nim's destructors will delete this object by default. 34 | ## However, sometimes you maybe want to do that by yourself. 35 | ## (Nim's destructors don't work in some version?) 36 | `=destroy`(self) 37 | -------------------------------------------------------------------------------- /wNim/private/dc/wMemoryDC.nim: -------------------------------------------------------------------------------- 1 | #==================================================================== 2 | # 3 | # wNim - Nim's Windows GUI Framework 4 | # Copyright (c) Chen Kai-Hung, Ward 5 | # 6 | #==================================================================== 7 | 8 | ## A memory device context provides a means to draw graphics onto a bitmap. 9 | ## Notice that the memory DC must be deleted (or the bitmap selected out of it) 10 | ## before a bitmap can be reselected into another memory DC. And, before 11 | ## performing any other operations on the bitmap data, the bitmap must be 12 | ## selected out of the memory DC: 13 | ## 14 | ## .. code-block:: Nim 15 | ## tempdc.selectObject(wNilBitmap) # here wNilBitmap is a predefined bitmap 16 | ## 17 | ## Like other DC object, wMemoryDC need nim's destructors to release the resource. 18 | # 19 | ## :Superclass: 20 | ## `wDC `_ 21 | 22 | include ../pragma 23 | import ../wBase, ../gdiobjects/wBitmap, wDC 24 | export wDC 25 | 26 | proc selectObject*(self: var wMemoryDC, bitmap: wBitmap) = 27 | ## Selects the given bitmap into the device context, to use as the memory bitmap. 28 | wValidate(bitmap) 29 | self.mBitmap = bitmap 30 | let hBmp = SelectObject(self.mHdc, bitmap.mHandle) 31 | if self.mhOldBitmap == 0: self.mhOldBitmap = hBmp 32 | 33 | method getSize*(self: wMemoryDC): wSize {.property.} = 34 | ## Gets the size of the device context. 35 | result = self.mBitmap.getSize() 36 | 37 | proc MemoryDC*(): wMemoryDC = 38 | ## Constructs a new memory device context. 39 | result.mHdc = CreateCompatibleDC(0) 40 | result.wDC.init() 41 | 42 | proc MemoryDC*(dc: wDC): wMemoryDC = 43 | ## Constructs a new memory device context compatible with the specified device. 44 | result.mHdc = CreateCompatibleDC(dc.mHdc) 45 | result.wDC.init() 46 | 47 | proc delete*(self: var wMemoryDC) = 48 | ## Nim's destructors will delete this object by default. 49 | ## However, sometimes you maybe want to do that by yourself. 50 | `=destroy`(self) 51 | -------------------------------------------------------------------------------- /wNim/private/dc/wPaintDC.nim: -------------------------------------------------------------------------------- 1 | #==================================================================== 2 | # 3 | # wNim - Nim's Windows GUI Framework 4 | # Copyright (c) Chen Kai-Hung, Ward 5 | # 6 | #==================================================================== 7 | 8 | ## A wPaintDC object must be constructed if an application wishes to paint on 9 | ## the client area of a window from within a wEvent_Paint event handler. 10 | ## To draw on a window from outside your wEvent_Paint event handler, construct 11 | ## a wClientDC object. To draw on the whole window including decorations, 12 | ## construct a wWindowDC object. A wPaintDC object is initialized to use the 13 | ## same font and colors as the window it is associated with. 14 | ## 15 | ## Like other DC object, wPaintDC need nim's destructors to release the resource. 16 | # 17 | ## :Superclass: 18 | ## `wDC `_ 19 | 20 | include ../pragma 21 | import ../wBase, ../wWindow, wDC 22 | export wDC 23 | 24 | method getSize*(self: wPaintDC): wSize {.property.} = 25 | ## Gets the size of the device context. 26 | result = self.mCanvas.getClientSize() 27 | 28 | proc PaintDC*(canvas: wWindow): wPaintDC = 29 | ## Constructor. In wEvent_Paint event handler the wWindow object usually is 30 | ## event.window. For example: 31 | ## 32 | ## .. code-block:: Nim 33 | ## frame.connect(wEvent_Paint) do (event: wEvent): 34 | ## var dc = PaintDC(event.window) 35 | wValidate(canvas) 36 | result.mCanvas = canvas 37 | result.mHdc = BeginPaint(canvas.mHwnd, result.mPs) 38 | result.wDC.init(fgColor=canvas.mForegroundColor, bgColor=canvas.mBackgroundColor, 39 | background=canvas.mBackgroundColor, font=canvas.mFont) 40 | 41 | proc getPaintRect*(self: wPaintDC): wRect {.property.} = 42 | ## Gets the rectangle in which the painting is requested. 43 | result = self.mPs.rcPaint.toWRect() 44 | 45 | proc delete*(self: var wPaintDC) = 46 | ## Nim's destructors will delete this object by default. 47 | ## However, sometimes you maybe want to do that by yourself. 48 | ## (Nim's destructors don't work in some version?) 49 | `=destroy`(self) 50 | -------------------------------------------------------------------------------- /wNim/private/dc/wPrinterDC.nim: -------------------------------------------------------------------------------- 1 | #==================================================================== 2 | # 3 | # wNim - Nim's Windows GUI Framework 4 | # Copyright (c) Chen Kai-Hung, Ward 5 | # 6 | #==================================================================== 7 | 8 | ## A printer device context allows access to any printer. 9 | ## 10 | ## Like other DC object, wPrinterDC need nim's destructors to release the resource. 11 | # 12 | ## :Superclass: 13 | ## `wDC `_ 14 | # 15 | ## :Seealso: 16 | ## `wPrintData `_ 17 | 18 | include ../pragma 19 | import ../wBase, ../wPrintData, wDC 20 | export wDC 21 | 22 | proc getPaperRect*(self: wPrinterDC): wRect {.property.} = 23 | ## Return the rectangle in device coordinates that corresponds to the full 24 | ## paper area, including the nonprinting regions of the paper. The point (0,0) 25 | ## in device coordinates is the top left corner of the page rectangle, which 26 | ## is the printable area. The coordinates of the top left corner of the paper 27 | ## rectangle will therefore have small negative values, while the bottom right 28 | ## coordinates will be somewhat larger than the values returned by wDC.GetSize(). 29 | if self.mHdc != 0: 30 | result.x = -GetDeviceCaps(self.mHdc, PHYSICALOFFSETX) 31 | result.y = -GetDeviceCaps(self.mHdc, PHYSICALOFFSETY) 32 | result.width = GetDeviceCaps(self.mHdc, PHYSICALWIDTH) 33 | result.height = GetDeviceCaps(self.mHdc, PHYSICALHEIGHT) 34 | 35 | proc startDoc*(self: wPrinterDC, message: string): bool {.discardable.} = 36 | ## Starts a document. Returns false if failed. 37 | var docinfo = DOCINFO(cbSize: sizeof(DOCINFO)) 38 | docInfo.lpszDocName = message 39 | 40 | if self.mHdc != 0 and StartDoc(self.mHdc, &docInfo) > 0: 41 | result = true 42 | 43 | proc endDoc*(self: wPrinterDC) = 44 | ## Ends a document. 45 | EndDoc(self.mHdc) 46 | 47 | proc abortDoc*(self: wPrinterDC) = 48 | ## Stops the current print job. 49 | AbortDoc(self.mHdc) 50 | 51 | proc startPage*(self: wPrinterDC) = 52 | ## Starts a document page. 53 | StartPage(self.mHdc) 54 | 55 | proc endPage*(self: wPrinterDC) = 56 | ## Ends a document page. 57 | EndPage(self.mHdc) 58 | 59 | proc PrinterDC*(printData: wPrintData): wPrinterDC = 60 | ## Create a wPrinterDC from given wPrintData object. 61 | wValidate(printData) 62 | 63 | if not printData.isOk(): 64 | raise newException(wError, "wPrinterDC creation failed") 65 | 66 | let pDevMode = cast[ptr DEVMODE](&printData.mDevModeBuffer) 67 | result.mHdc = CreateDC(nil, printData.mDevice, nil, pDevMode) 68 | if result.mHdc == 0: 69 | raise newException(wError, "wPrinterDC creation failed") 70 | 71 | result.wDC.init() 72 | 73 | proc delete*(self: var wPrinterDC) = 74 | ## Nim's destructors will delete this object by default. 75 | ## However, sometimes you maybe want to do that by yourself. 76 | ## (Nim's destructors don't work in some version?) 77 | `=destroy`(self) 78 | -------------------------------------------------------------------------------- /wNim/private/dc/wScreenDC.nim: -------------------------------------------------------------------------------- 1 | #==================================================================== 2 | # 3 | # wNim - Nim's Windows GUI Framework 4 | # Copyright (c) Chen Kai-Hung, Ward 5 | # 6 | #==================================================================== 7 | 8 | ## A screen device context can be used to paint on the screen. 9 | ## 10 | ## Like other DC object, wScreenDC need nim's destructors to release the resource. 11 | # 12 | ## :Superclass: 13 | ## `wDC `_ 14 | 15 | include ../pragma 16 | import ../wBase, wDC 17 | export wDC 18 | 19 | proc ScreenDC*(): wScreenDC = 20 | ## Constructor. 21 | result.mHdc = GetDC(0) 22 | result.wDC.init() 23 | 24 | proc delete*(self: var wScreenDC) = 25 | ## Nim's destructors will delete this object by default. 26 | ## However, sometimes you maybe want to do that by yourself. 27 | ## (Nim's destructors don't work in some version?) 28 | `=destroy`(self) 29 | -------------------------------------------------------------------------------- /wNim/private/dc/wWindowDC.nim: -------------------------------------------------------------------------------- 1 | #==================================================================== 2 | # 3 | # wNim - Nim's Windows GUI Framework 4 | # Copyright (c) Chen Kai-Hung, Ward 5 | # 6 | #==================================================================== 7 | 8 | ## A wWindowDC must be constructed if an application wishes to paint on the 9 | ## whole area of a window. 10 | ## 11 | ## Like other DC object, wWindowDC need nim's destructors to release the resource. 12 | # 13 | ## :Superclass: 14 | ## `wDC `_ 15 | 16 | include ../pragma 17 | import ../wBase, ../wWindow, wDC 18 | export wDC 19 | 20 | method getSize*(self: wWindowDC): wSize {.property.} = 21 | ## Gets the size of the device context. 22 | result = self.mCanvas.getSize() 23 | 24 | proc WindowDC*(canvas: wWindow): wWindowDC = 25 | ## Constructor. 26 | wValidate(canvas) 27 | result.mCanvas = canvas 28 | result.mHdc = GetWindowDC(canvas.mHwnd) 29 | result.wDC.init(fgColor=canvas.mForegroundColor, bgColor=canvas.mBackgroundColor, 30 | background=canvas.mBackgroundColor, font=canvas.mFont) 31 | 32 | proc delete*(self: var wWindowDC) = 33 | ## Nim's destructors will delete this object by default. 34 | ## However, sometimes you maybe want to do that by yourself. 35 | ## (Nim's destructors don't work in some version?) 36 | `=destroy`(self) 37 | -------------------------------------------------------------------------------- /wNim/private/dialogs/wDialog.nim: -------------------------------------------------------------------------------- 1 | #==================================================================== 2 | # 3 | # wNim - Nim's Windows GUI Framework 4 | # Copyright (c) Chen Kai-Hung, Ward 5 | # 6 | #==================================================================== 7 | 8 | ## This is the base class for common dialogs. 9 | # 10 | ## :Superclass: 11 | ## `wWindow `_ 12 | # 13 | ## :Subclasses: 14 | ## `wMessageDialog `_ 15 | ## `wFileDialog `_ 16 | ## `wDirDialog `_ 17 | ## `wColorDialog `_ 18 | ## `wFontDialog `_ 19 | ## `wTextEntryDialog `_ 20 | ## `wPasswordEntryDialog `_ 21 | ## `wFindReplaceDialog `_ 22 | ## `wPageSetupDialog `_ 23 | ## `wPrintDialog `_ 24 | # 25 | ## :Seealso: 26 | ## `wDialogEvent `_ 27 | 28 | include ../pragma 29 | import ../wBase, ../wWindow, ../gdiobjects/wFont 30 | export wWindow 31 | 32 | proc getOwner*(self: wDialog): wWindow {.validate, property, inline.} = 33 | ## Returns the owner window of the dialog. The result may be nil. 34 | result = self.mOwner 35 | 36 | proc dialogQuit(self: wDialog) {.shield.} = 37 | # a dialog must post wEvent_AppQuit message (just like a wWindow does in wWindow_DoDestroy) 38 | # so that the app will end correctly when a "no owner" dialog closed. 39 | 40 | if self.mOwner == nil: 41 | PostMessage(0, wEvent_AppQuit, 0, self.mHwnd) 42 | 43 | # For a dialog, clear the resource here is convenience and necessary. 44 | # Because a dialog may have the event handler that reference to itself. 45 | # If not released, the destructor for the dialog won't be called. 46 | 47 | # The drawback to clear the resource here is: after the dialog closed, 48 | # the event table need to be reset. It means a dialog object should not reuse. 49 | 50 | # Here invoke wWindow.release() only. The fields beyond wWindow should be kept, 51 | # it have information about the dialog result. 52 | procCall self.wWindow.release() 53 | 54 | proc wDialogHookProc(self: wDialog, hwnd: HWND, msg: UINT, wParam: WPARAM, 55 | lParam: LPARAM): UINT_PTR {.shield.} = 56 | 57 | case msg 58 | of WM_INITDIALOG: 59 | self.mHwnd = hwnd 60 | let event = Event(window=self, msg=wEvent_DialogCreated) 61 | self.processEvent(event) 62 | 63 | of WM_COMMAND: 64 | # handle help button here is much better than "commdlg_help" message 65 | # 1. don't need connect/disconnect to owner's event table 66 | # 2. avoid bug in PageSetupDlg (lparam don't point to TPAGESETUPDLG) 67 | # 3. don't even need a owner to work 68 | # only drawback is: wFileDialog not support becasue no way to hook 69 | if HIWORD(int32 wParam) == BN_CLICKED and LOWORD(int32 wParam) == 1038: 70 | let event = Event(self, wEvent_DialogHelp) 71 | self.processEvent(event) 72 | 73 | of WM_DESTROY: 74 | let event = Event(window=self, msg=wEvent_DialogClosed) 75 | self.processEvent(event) 76 | self.dialogQuit() 77 | 78 | else: discard 79 | 80 | # MSDN: If the hook procedure returns zero, the default dialog box procedure processes the message. 81 | # If the hook procedure returns a nonzero value, the default dialog box procedure ignores the message. 82 | if self.processMessage(msg, wParam, lParam): 83 | return TRUE 84 | 85 | proc init(self: wDialog, owner: wWindow) {.shield.} = 86 | # Initializer. 87 | self.initBase("wDialog") 88 | self.mOwner = owner # may be nil 89 | self.mBackgroundColor = wDefaultColor 90 | self.mForegroundColor = wDefaultColor 91 | self.mFont = wNormalFont 92 | -------------------------------------------------------------------------------- /wNim/private/dialogs/wPasswordEntryDialog.nim: -------------------------------------------------------------------------------- 1 | #==================================================================== 2 | # 3 | # wNim - Nim's Windows GUI Framework 4 | # Copyright (c) Chen Kai-Hung, Ward 5 | # 6 | #==================================================================== 7 | 8 | ## This class represents a dialog that requests a one-line password string 9 | ## from the user. Both modal or modaless dialog are supported. 10 | # 11 | ## :Superclass: 12 | ## `wTextEntryDialog `_ 13 | # 14 | ## :Events: 15 | ## `wDialogEvent `_ 16 | ## ============================== ============================================================= 17 | ## wDialogEvent Description 18 | ## ============================== ============================================================= 19 | ## wEvent_DialogCreated When the dialog is created but not yet shown. 20 | ## wEvent_DialogClosed When the dialog is being closed. 21 | ## =============================== ============================================================= 22 | 23 | include ../pragma 24 | import ../wBase, ../wFrame, wDialog, wTextEntryDialog 25 | export wDialog, wTextEntryDialog 26 | 27 | wClass(wPasswordEntryDialog of wTextEntryDialog): 28 | 29 | proc init*(self: wPasswordEntryDialog, owner: wWindow = nil, message = "Input password", 30 | caption = "", value = "", style: wStyle = wDefaultDialogStyle, 31 | pos = wDefaultPoint) {.validate, inline.} = 32 | ## Initializer. 33 | self.wTextEntryDialog.init(owner, message, caption, value, style, pos) 34 | -------------------------------------------------------------------------------- /wNim/private/events/wContextMenuEvent.nim: -------------------------------------------------------------------------------- 1 | #==================================================================== 2 | # 3 | # wNim - Nim's Windows GUI Framework 4 | # Copyright (c) Chen Kai-Hung, Ward 5 | # 6 | #==================================================================== 7 | 8 | ## This event is generated by wWindow when the user requests to show a 9 | ## context (popup) menu. 10 | # 11 | ## :Superclass: 12 | ## `wEvent `_ 13 | # 14 | ## :Seealso: 15 | ## `wWindow `_ 16 | # 17 | ## :Events: 18 | ## ============================== ============================================================= 19 | ## wContextMenuEvent Description 20 | ## ============================== ============================================================= 21 | ## wEvent_ContextMenu Notifies a window that the user clicked the right mouse button. 22 | ## ============================== ============================================================= 23 | 24 | include ../pragma 25 | import ../wBase 26 | 27 | wEventRegister(wContextMenuEvent): 28 | wEvent_ContextMenu = WM_CONTEXTMENU 29 | 30 | method getPosition*(self: wContextMenuEvent): wPoint {.property.} = 31 | ## Returns the position in screen coordinates at which the menu should be shown. 32 | ## If the event originated from a keyboard event, the value returned from this 33 | ## function will be wDefaultPosition. 34 | 35 | result.x = GET_X_LPARAM(self.mLparam) 36 | result.y = GET_Y_LPARAM(self.mLparam) 37 | if result.x == -1 and result.y == -1: 38 | result = wDefaultPoint 39 | -------------------------------------------------------------------------------- /wNim/private/events/wDialogEvent.nim: -------------------------------------------------------------------------------- 1 | #==================================================================== 2 | # 3 | # wNim - Nim's Windows GUI Framework 4 | # Copyright (c) Chen Kai-Hung, Ward 5 | # 6 | #==================================================================== 7 | 8 | ## These events are generated by common dialogs. 9 | # 10 | ## :Superclass: 11 | ## `wEvent `_ 12 | # 13 | ## :Seealso: 14 | ## `wDialog `_ 15 | # 16 | ## :Events: 17 | ## ============================== ============================================================= 18 | ## wDialogEvent Description 19 | ## ============================== ============================================================= 20 | ## wEvent_DialogCreated When the dialog is created but not yet shown. 21 | ## wEvent_DialogClosed When the dialog is being closed. 22 | ## wEvent_DialogHelp When the Help button is pressed. 23 | ## wEvent_DialogApply When the Apply button is pressed. 24 | ## wEvent_FindNext When find next button was pressed. 25 | ## wEvent_Replace When replace button was pressed. 26 | ## wEvent_ReplaceAll When replace all button was pressed . 27 | ## wEvent_PrinterChanged When the selected printer is changed. 28 | ## ============================== ============================================================= 29 | 30 | include ../pragma 31 | import ../wBase 32 | 33 | wEventRegister(wDialogEvent): 34 | wEvent_DialogFirst 35 | wEvent_DialogCreated 36 | wEvent_DialogClosed 37 | wEvent_DialogHelp 38 | wEvent_DialogApply 39 | wEvent_FindNext 40 | wEvent_Replace 41 | wEvent_ReplaceAll 42 | wEvent_PrinterChanged 43 | wEvent_DialogLast 44 | -------------------------------------------------------------------------------- /wNim/private/events/wDragDropEvent.nim: -------------------------------------------------------------------------------- 1 | #==================================================================== 2 | # 3 | # wNim - Nim's Windows GUI Framework 4 | # Copyright (c) Chen Kai-Hung, Ward 5 | # 6 | #==================================================================== 7 | 8 | ## These events are generated by wWindow during a drag-and-drop operation. 9 | # 10 | ## :Superclass: 11 | ## `wEvent `_ 12 | # 13 | ## :Seealso: 14 | ## `wDataObject `_ 15 | # 16 | ## :Events: 17 | ## ============================== ============================================================= 18 | ## wDragDropEvent Description 19 | ## ============================== ============================================================= 20 | ## wEvent_DragEnter When the mouse enters the drop target. 21 | ## wEvent_DragOver When the mouse is being dragged over the drop target. 22 | ## wEvent_DragLeave When the mouse leaves the drop target. 23 | ## wEvent_Drop When the user drops a data object on the target. 24 | ## ============================== ============================================================= 25 | 26 | include ../pragma 27 | import ../wBase 28 | 29 | wEventRegister(wDragDropEvent): 30 | wEvent_DragDropFirst 31 | wEvent_DragEnter 32 | wEvent_DragOver 33 | wEvent_DragLeave 34 | wEvent_Drop 35 | wEvent_DragDropLast 36 | 37 | method getDataObject*(self: wDragDropEvent): wDataObject {.property, inline.} = 38 | ## Returns the wDataObject object associated with the drop target. 39 | result = self.mDataObject 40 | 41 | method getEffect*(self: wDragDropEvent): int {.property, inline.} = 42 | ## Returns the effect for drag and drop. *effect* should be one of wDragNone, 43 | ## wDragCopy, wDragMove or wDragLink. 44 | result = self.mEffect 45 | 46 | method setEffect*(self: wDragDropEvent, effect: int) {.property, inline.} = 47 | ## Sets the effect for drag and drop. *effect* should be one of wDragNone, 48 | ## wDragCopy, wDragMove or wDragLink. 49 | self.mEffect = effect 50 | -------------------------------------------------------------------------------- /wNim/private/events/wHyperlinkEvent.nim: -------------------------------------------------------------------------------- 1 | #==================================================================== 2 | # 3 | # wNim - Nim's Windows GUI Framework 4 | # Copyright (c) Chen Kai-Hung, Ward 5 | # 6 | #==================================================================== 7 | 8 | ## This event is generated by wHyperlinkCtrl. 9 | # 10 | ## :Superclass: 11 | ## `wCommandEvent `_ 12 | # 13 | ## :Seealso: 14 | ## `wHyperlinkCtrl `_ 15 | # 16 | ## :Events: 17 | ## ============================== ============================================================= 18 | ## wHyperlinkEvent Description 19 | ## ============================== ============================================================= 20 | ## wEvent_Hyperlink The hyperlink was clicked. 21 | ## ============================== ============================================================= 22 | 23 | # forward declaration 24 | # method getEventVisited(self: wWindow, index: int): bool {.base.} 25 | 26 | include ../pragma 27 | import ../wBase 28 | 29 | wEventRegister(wHyperlinkEvent): 30 | wEvent_Hyperlink 31 | 32 | method getIndex*(self: wHyperlinkEvent): int {.property, inline.} = 33 | ## Returns the index of the hyperlink. 34 | let pnmLink = cast[PNMLINK](self.mLparam) 35 | result = pnmLink.item.iLink 36 | 37 | method getUrl*(self: wHyperlinkEvent): string {.property, inline.} = 38 | ## Returns the URL of the hyperlink. 39 | let pnmLink = cast[PNMLINK](self.mLparam) 40 | result = nullTerminated($$pnmLink.item.szUrl) 41 | 42 | method getLinkId*(self: wHyperlinkEvent): string {.property, inline.} = 43 | ## Returns the link ID of the hyperlink. 44 | let pnmLink = cast[PNMLINK](self.mLparam) 45 | result = nullTerminated($$pnmLink.item.szID) 46 | 47 | method getVisited*(self: wHyperlinkEvent): bool {.property, inline.} = 48 | ## Returns the visited state of the hyperlink. 49 | result = self.mVisited 50 | -------------------------------------------------------------------------------- /wNim/private/events/wIpEvent.nim: -------------------------------------------------------------------------------- 1 | #==================================================================== 2 | # 3 | # wNim - Nim's Windows GUI Framework 4 | # Copyright (c) Chen Kai-Hung, Ward 5 | # 6 | #==================================================================== 7 | 8 | ## This event is generated by wIpCtrl. The field value can be modified by 9 | ## setValue() in the event handler. 10 | # 11 | ## :Superclass: 12 | ## `wCommandEvent `_ 13 | # 14 | ## :Seealso: 15 | ## `wIpCtrl `_ 16 | # 17 | ## :Events: 18 | ## ============================== ============================================================= 19 | ## wIpEvent Description 20 | ## ============================== ============================================================= 21 | ## wEvent_IpChanged When the user changes a field or moves from one field to another. 22 | ## ============================== ============================================================= 23 | 24 | include ../pragma 25 | import ../wBase 26 | 27 | wEventRegister(wIpEvent): 28 | wEvent_IpChanged 29 | 30 | method getIndex*(self: wIpEvent): int {.property, inline.} = 31 | ## The zero-based number of the field that was changed. 32 | result = self.mIndex 33 | 34 | method getValue*(self: wIpEvent): int {.property, inline.} = 35 | ## Gets the new value of the field. 36 | result = self.mValue 37 | 38 | method setValue*(self: wIpEvent, value: int) {.property, inline.} = 39 | ## Sets the new value of the field. 40 | self.mValue = value 41 | -------------------------------------------------------------------------------- /wNim/private/events/wKeyEvent.nim: -------------------------------------------------------------------------------- 1 | #==================================================================== 2 | # 3 | # wNim - Nim's Windows GUI Framework 4 | # Copyright (c) Chen Kai-Hung, Ward 5 | # 6 | #==================================================================== 7 | 8 | ## These events are generated by wWindow when the user pressed the keyboard. 9 | # 10 | ## :Superclass: 11 | ## `wEvent `_ 12 | # 13 | ## :Seealso: 14 | ## `wWindow `_ 15 | # 16 | ## :Events: 17 | ## ============================== ============================================================= 18 | ## wKeyEvent Description 19 | ## ============================== ============================================================= 20 | ## wEvent_Char A focused Window receives a char. 21 | ## wEvent_KeyDown A key was pressed. 22 | ## wEvent_KeyUp A key was released. 23 | ## wEvent_SysKeyDown Presses the F10 key or holds down the ALT key and then presses another key. 24 | ## wEvent_SysKeyUp Releases a key that was pressed while the ALT key was held down. 25 | ## ============================== ============================================================= 26 | 27 | include ../pragma 28 | import ../wBase 29 | 30 | wEventRegister(wKeyEvent): 31 | wEvent_Char = WM_CHAR 32 | wEvent_KeyDown = WM_KEYDOWN 33 | wEvent_KeyUp = WM_KEYUP 34 | wEvent_SysKeyDown = WM_SYSKEYDOWN 35 | wEvent_SysKeyUp = WM_SYSKEYUP 36 | wEvent_KeyFirst = WM_KEYFIRST 37 | wEvent_KeyLast = WM_KEYLAST 38 | 39 | method getKeyCode*(self: wKeyEvent): int {.property, inline.} = 40 | ## Returns the key code of the key that generated this event. 41 | result = int self.mWparam 42 | -------------------------------------------------------------------------------- /wNim/private/events/wListEvent.nim: -------------------------------------------------------------------------------- 1 | #==================================================================== 2 | # 3 | # wNim - Nim's Windows GUI Framework 4 | # Copyright (c) Chen Kai-Hung, Ward 5 | # 6 | #==================================================================== 7 | 8 | ## These events are generated by wListCtrl. 9 | # 10 | ## :Superclass: 11 | ## `wCommandEvent `_ 12 | # 13 | ## :Seealso: 14 | ## `wListCtrl `_ 15 | # 16 | ## :Events: 17 | ## ============================== ============================================================= 18 | ## wListEvent Description 19 | ## ============================== ============================================================= 20 | ## wEvent_ListBeginDrag Begin dragging with the left mouse button. 21 | ## wEvent_ListBeginRightDrag Begin dragging with the right mouse button. 22 | ## wEvent_ListBeginLabelEdit Begin editing a label. This event can be vetoed. 23 | ## wEvent_ListEndLabelEdit Finish editing a label. This event can be vetoed. 24 | ## wEvent_ListDeleteItem An item was deleted. 25 | ## wEvent_ListDeleteAllItems All items were deleted. 26 | ## wEvent_ListItemFocused The currently focused item has changed. 27 | ## wEvent_ListItemSelected The item has been selected. 28 | ## wEvent_ListItemDeselected The item has been deselected. 29 | ## wEvent_ListItemActivated The item has been activated (ENTER or double click). 30 | ## wEvent_ListItemRightClick The right mouse button has been clicked on an item. 31 | ## wEvent_ListInsertItem An item has been inserted. 32 | ## wEvent_ListColClick A column has been left-clicked. 33 | ## wEvent_ListColRightClick A column has been right-clicked. 34 | ## wEvent_ListColBeginDrag The user started resizing a column. This event can be vetoed. 35 | ## wEvent_ListColDragging The divider between columns is being dragged. 36 | ## wEvent_ListColEndDrag A column has been resized by the user. 37 | ## wEvent_ListColBeginMove The user started moving a column. 38 | ## wEvent_ListColEndMove A column has been moved by the user. 39 | ## wEvent_ListitemChecked The item has been checked. 40 | ## wEvent_ListitemUnchecked The item has been unchecked. 41 | ## ============================== ============================================================= 42 | 43 | include ../pragma 44 | import ../wBase 45 | 46 | wEventRegister(wListEvent): 47 | wEvent_ListFirst 48 | wEvent_ListBeginDrag 49 | wEvent_ListBeginRightDrag 50 | wEvent_ListBeginLabelEdit 51 | wEvent_ListEndLabelEdit 52 | wEvent_ListDeleteItem 53 | wEvent_ListDeleteAllItems 54 | wEvent_ListItemFocused 55 | wEvent_ListItemSelected 56 | wEvent_ListItemDeselected 57 | wEvent_ListItemActivated 58 | wEvent_ListItemRightClick 59 | wEvent_ListItemChecked 60 | wEvent_ListItemUnchecked 61 | wEvent_ListInsertItem 62 | wEvent_ListColClick 63 | wEvent_ListColRightClick 64 | wEvent_ListColBeginDrag 65 | wEvent_ListColDragging 66 | wEvent_ListColEndDrag 67 | wEvent_ListColBeginMove 68 | wEvent_ListColEndMove 69 | wEvent_ListLast 70 | 71 | method getIndex*(self: wListEvent): int {.property, inline.} = 72 | ## The item index. 73 | result = self.mIndex 74 | 75 | method getColumn*(self: wListEvent): int {.property, inline.} = 76 | ## The column position. 77 | result = self.mCol 78 | 79 | method getText*(self: wListEvent): string {.property, inline.} = 80 | ## The (new) item label for wEvent_ListEndLabelEdit event. 81 | result = self.mText 82 | -------------------------------------------------------------------------------- /wNim/private/events/wMoveEvent.nim: -------------------------------------------------------------------------------- 1 | #==================================================================== 2 | # 3 | # wNim - Nim's Windows GUI Framework 4 | # Copyright (c) Chen Kai-Hung, Ward 5 | # 6 | #==================================================================== 7 | 8 | ## These events are generated by wWindow when the window is moved or about to move. 9 | # 10 | ## :Superclass: 11 | ## `wEvent `_ 12 | # 13 | ## :Seealso: 14 | ## `wWindow `_ 15 | # 16 | ## :Events: 17 | ## ============================== ============================================================= 18 | ## wMoveEvent Description 19 | ## ============================== ============================================================= 20 | ## wEvent_Move Window is moved. 21 | ## wEvent_Moving Window is moving. 22 | ## wEvent_Dragging Window is dragging by user. This event can be vetoed. 23 | ## ============================== ============================================================= 24 | 25 | include ../pragma 26 | import ../wBase 27 | 28 | wEventRegister(wMoveEvent): 29 | wEvent_Move = WM_MOVE 30 | wEvent_Moving = WM_MOVING 31 | wEvent_Dragging 32 | 33 | method getPosition*(self: wMoveEvent): wPoint {.property.} = 34 | ## Returns the entire size of the window generating the size change event. 35 | if self.mMsg in [WM_MOVE, wEvent_Dragging]: 36 | result.x = GET_X_LPARAM(self.mLparam) 37 | result.y = GET_Y_LPARAM(self.mLparam) 38 | elif self.mMsg == WM_MOVING: 39 | var rect = toWRect(cast[PRECT](self.mLparam)[]) 40 | result.x = rect.x 41 | result.y = rect.y 42 | 43 | method setPosition*(self: wMoveEvent, x: int, y: int) {.property.} = 44 | if self.mMsg == WM_MOVING: 45 | var rect = toWRect(cast[PRECT](self.mLparam)[]) 46 | rect.x = x 47 | rect.y = y 48 | cast[PRECT](self.mLparam)[] = toRect(rect) 49 | 50 | method setPosition*(self: wMoveEvent, pos: wPoint) {.property.} = 51 | self.setPosition(pos.x, pos.y) 52 | -------------------------------------------------------------------------------- /wNim/private/events/wNavigationEvent.nim: -------------------------------------------------------------------------------- 1 | #==================================================================== 2 | # 3 | # wNim - Nim's Windows GUI Framework 4 | # Copyright (c) Chen Kai-Hung, Ward 5 | # 6 | #==================================================================== 7 | 8 | ## This event is generated by wControl when it need to know a navigation key 9 | ## is used by the control or not. 10 | # 11 | ## :Superclass: 12 | ## `wEvent `_ 13 | # 14 | ## :Seealso: 15 | ## `wControl `_ 16 | # 17 | ## :Events: 18 | ## ============================== ============================================================= 19 | ## wNavigationEvent Description 20 | ## ============================== ============================================================= 21 | ## wEvent_Navigation A navigation key was pressed. 22 | ## ============================== ============================================================= 23 | 24 | include ../pragma 25 | import ../wBase 26 | 27 | wEventRegister(wNavigationEvent): 28 | wEvent_Navigation 29 | 30 | method getKeyCode*(self: wNavigationEvent): int {.property, inline.} = 31 | ## Returns the key code of the key that generated this event. 32 | result = int self.mWparam 33 | -------------------------------------------------------------------------------- /wNim/private/events/wScrollEvent.nim: -------------------------------------------------------------------------------- 1 | #==================================================================== 2 | # 3 | # wNim - Nim's Windows GUI Framework 4 | # Copyright (c) Chen Kai-Hung, Ward 5 | # 6 | #==================================================================== 7 | 8 | ## These events are generated by wScrollBar and wSlider. 9 | # 10 | ## :Superclass: 11 | ## `wCommandEvent `_ 12 | # 13 | ## :Seealso: 14 | ## `wScrollBar `_ 15 | ## `wSlider `_ 16 | # 17 | ## :Events: 18 | ## ============================== ============================================================= 19 | ## wScrollEvent Description 20 | ## ============================== ============================================================= 21 | ## wEvent_Slider Sent to wSlider before all of following event. 22 | ## Use getKind() to know what kind of type it is. 23 | ## wEvent_ScrollBar Sent to wScrollBar before all of following event. 24 | ## Use getKind() to know what kind of type it is. 25 | ## wEvent_ScrollTop Scroll to top or leftmost. 26 | ## wEvent_ScrollBottom Scroll to bottom or rightmost. 27 | ## wEvent_ScrollLineUp Scroll line up or left 28 | ## wEvent_ScrollLineDown Scroll line down or right. 29 | ## wEvent_ScrollPageUp Scroll page up or left. 30 | ## wEvent_ScrollPageDown Scroll page down or right. 31 | ## wEvent_ScrollThumbTrack Frequent events sent as the user drags the thumbtrack. 32 | ## wEvent_ScrollThumbRelease Thumb release events. 33 | ## wEvent_ScrollChanged End of scrolling events 34 | ## ============================== ============================================================= 35 | 36 | include ../pragma 37 | import ../wBase 38 | 39 | wEventRegister(wScrollEvent): 40 | wEvent_ScrollFirst 41 | wEvent_Slider 42 | wEvent_ScrollBar 43 | wEvent_ScrollTop 44 | wEvent_ScrollBottom 45 | wEvent_ScrollLineUp 46 | wEvent_ScrollLineDown 47 | wEvent_ScrollPageUp 48 | wEvent_ScrollPageDown 49 | wEvent_ScrollThumbTrack 50 | wEvent_ScrollThumbRelease 51 | wEvent_ScrollChanged 52 | wEvent_ScrollLast 53 | 54 | method getKind*(self: wScrollEvent): int {.property, inline.} = 55 | ## Returns what kind of event type this is. Basically used in wEvent_ScrollBar 56 | ## or wEvent_Slider. 57 | let dataPtr = cast[ptr wScrollData](self.mLparam) 58 | result = dataPtr.kind 59 | 60 | method getOrientation*(self: wScrollEvent): int {.property, inline.} = 61 | ## Returns wHorizontal or wVertical 62 | let dataPtr = cast[ptr wScrollData](self.mLparam) 63 | result = dataPtr.orientation 64 | 65 | method getScrollPos*(self: wScrollEvent): int {.property.} = 66 | ## Returns the position of the scrollbar. 67 | result = self.mScrollPos 68 | -------------------------------------------------------------------------------- /wNim/private/events/wScrollWinEvent.nim: -------------------------------------------------------------------------------- 1 | #==================================================================== 2 | # 3 | # wNim - Nim's Windows GUI Framework 4 | # Copyright (c) Chen Kai-Hung, Ward 5 | # 6 | #==================================================================== 7 | 8 | ## These events are generated by wWindow when the window is scrolling. Notice 9 | ## that these events are very similar to wScrollEvent but not derive from 10 | ## wCommandEvent. It means, these events won't propagate upwards by default. 11 | # 12 | ## :Superclass: 13 | ## `wEvent `_ 14 | # 15 | ## :Seealso: 16 | ## `wWindow `_ 17 | # 18 | ## :Events: 19 | ## ============================== ============================================================= 20 | ## wScrollWinEvent Description 21 | ## ============================== ============================================================= 22 | ## wEvent_ScrollWin Sent to window before all of following event. 23 | ## Use getKind() to know what kind of type it is. 24 | ## wEvent_ScrollWinTop Scroll to top or leftmost. 25 | ## wEvent_ScrollWinBottom Scroll to bottom or rightmost. 26 | ## wEvent_ScrollWinLineUp Scroll line up or left 27 | ## wEvent_ScrollWinLineDown Scroll line down or right. 28 | ## wEvent_ScrollWinPageUp Scroll page up or left. 29 | ## wEvent_ScrollWinPageDown Scroll page down or right. 30 | ## wEvent_ScrollWinThumbTrack Frequent events sent as the user drags the thumbtrack. 31 | ## wEvent_ScrollWinThumbRelease Thumb release events. 32 | ## wEvent_ScrollWinChanged End of scrolling events 33 | ## ============================== ============================================================= 34 | 35 | # forward declaration 36 | # proc getScrollPos*(self: wWindow, orientation: int): int {.inline.} 37 | 38 | include ../pragma 39 | import ../wBase 40 | 41 | wEventRegister(wScrollWinEvent): 42 | wEvent_ScrollWinFirst 43 | wEvent_ScrollWin 44 | wEvent_ScrollWinTop 45 | wEvent_ScrollWinBottom 46 | wEvent_ScrollWinLineUp 47 | wEvent_ScrollWinLineDown 48 | wEvent_ScrollWinPageUp 49 | wEvent_ScrollWinPageDown 50 | wEvent_ScrollWinThumbTrack 51 | wEvent_ScrollWinThumbRelease 52 | wEvent_ScrollWinChanged 53 | wEvent_ScrollWinLast 54 | 55 | method getKind*(self: wScrollWinEvent): int {.property, inline.} = 56 | ## Returns what kind of event type this is. Basically used in wEvent_ScrollWin. 57 | let dataPtr = cast[ptr wScrollData](self.mLparam) 58 | result = dataPtr.kind 59 | 60 | method getOrientation*(self: wScrollWinEvent): int {.property, inline.} = 61 | ## Returns wHorizontal or wVertical 62 | let dataPtr = cast[ptr wScrollData](self.mLparam) 63 | result = dataPtr.orientation 64 | 65 | method getScrollPos*(self: wScrollWinEvent): int {.property.} = 66 | ## Returns the position of the scrollbar. 67 | result = self.mScrollPos 68 | -------------------------------------------------------------------------------- /wNim/private/events/wSetCursorEvent.nim: -------------------------------------------------------------------------------- 1 | #==================================================================== 2 | # 3 | # wNim - Nim's Windows GUI Framework 4 | # Copyright (c) Chen Kai-Hung, Ward 5 | # 6 | #==================================================================== 7 | 8 | ## This event is generated by wWindow when the mouse cursor is about to be set 9 | ## as a result of mouse motion. This event gives the application the chance to 10 | ## perform specific mouse cursor processing based on the current position of the 11 | ## mouse within the window. Use setCursor() to specify the cursor you want to be 12 | ## displayed. 13 | # 14 | ## :Superclass: 15 | ## `wEvent `_ 16 | # 17 | ## :Seealso: 18 | ## `wWindow `_ 19 | # 20 | ## :Events: 21 | ## ============================== ============================================================= 22 | ## wSetCursorEvent Description 23 | ## ============================== ============================================================= 24 | ## wEvent_SetCursor The mouse cursor is about to be set. 25 | ## ============================== ============================================================= 26 | 27 | include ../pragma 28 | import ../wBase 29 | 30 | wEventRegister(wSetCursorEvent): 31 | wEvent_SetCursor 32 | 33 | method getCursor*(self: wSetCursorEvent): wCursor {.property, inline.} = 34 | ## Returns a reference to the cursor specified by this event. 35 | result = cast[wCursor](self.mLparam) 36 | 37 | method setCursor*(self: wSetCursorEvent, cursor: wCursor) {.property, inline.} = 38 | ## Sets the cursor associated with this event. 39 | wValidate(cursor) 40 | self.mLparam = cast[LPARAM](cursor) 41 | -------------------------------------------------------------------------------- /wNim/private/events/wSizeEvent.nim: -------------------------------------------------------------------------------- 1 | #==================================================================== 2 | # 3 | # wNim - Nim's Windows GUI Framework 4 | # Copyright (c) Chen Kai-Hung, Ward 5 | # 6 | #==================================================================== 7 | 8 | ## These events are generated by wWindow when the window size is changed or 9 | ## about to change. 10 | # 11 | ## :Superclass: 12 | ## `wEvent `_ 13 | # 14 | ## :Seealso: 15 | ## `wWindow `_ 16 | # 17 | ## :Events: 18 | ## ============================== ============================================================= 19 | ## wSizeEvent Description 20 | ## ============================== ============================================================= 21 | ## wEvent_Size Window size has changed. 22 | ## wEvent_Iconize Window is iconized, mostly generated from a frame. 23 | ## wEvent_Minimize Window is iconized, the same as wEvent_Iconize. 24 | ## wEvent_Maximize Window is maximized, mostly generated from a frame. 25 | ## wEvent_Sizing Window is sizing. 26 | ## ============================== ============================================================= 27 | 28 | include ../pragma 29 | import ../wBase 30 | 31 | wEventRegister(wSizeEvent): 32 | wEvent_Size 33 | wEvent_Minimize 34 | wEvent_Maximize 35 | wEvent_Sizing 36 | 37 | const 38 | wEvent_Iconize* = wEvent_Minimize 39 | 40 | method getSize*(self: wSizeEvent): wSize {.property.} = 41 | ## Returns the entire size of the window generating the size change event. 42 | result.width = GET_X_LPARAM(self.mLparam) 43 | result.height = GET_Y_LPARAM(self.mLparam) 44 | -------------------------------------------------------------------------------- /wNim/private/events/wSpinEvent.nim: -------------------------------------------------------------------------------- 1 | #==================================================================== 2 | # 3 | # wNim - Nim's Windows GUI Framework 4 | # Copyright (c) Chen Kai-Hung, Ward 5 | # 6 | #==================================================================== 7 | 8 | ## These events are generated by wSpinButton and wSpinCtrl. 9 | # 10 | ## :Superclass: 11 | ## `wCommandEvent `_ 12 | # 13 | ## :Seealso: 14 | ## `wSpinButton `_ 15 | ## `wSpinCtrl `_ 16 | # 17 | ## :Events: 18 | ## ============================== ============================================================= 19 | ## wSpinEvent Description 20 | ## ============================== ============================================================= 21 | ## wEvent_Spin Pressing an arrow. This event can be vetoed in wSpinCtrl. 22 | ## wEvent_SpinUp Pressing up arrow. This event can be vetoed in wSpinCtrl. 23 | ## wEvent_SpinDown Pressing down arrow. This event can be vetoed in wSpinCtrl. 24 | ## wEvent_SpinLeft Pressing left arrow. 25 | ## wEvent_SpinRight Pressing right arrow. 26 | ## ============================== ============================================================= 27 | 28 | include ../pragma 29 | import ../wBase 30 | 31 | wEventRegister(wSpinEvent): 32 | wEvent_SpinFirst 33 | wEvent_Spin 34 | wEvent_SpinUp 35 | wEvent_SpinDown 36 | wEvent_SpinLeft 37 | wEvent_SpinRight 38 | wEvent_SpinLast 39 | 40 | method getSpinPos*(self: wSpinEvent): int {.property, inline.} = 41 | ## Gets the current value (before change). 42 | let lpnmud = cast[LPNMUPDOWN](self.mLparam) 43 | result = lpnmud.iPos 44 | 45 | method setSpinPos*(self: wSpinEvent, pos: int) {.property, inline.} = 46 | ## Set the value associated with the event. 47 | let lpnmud = cast[LPNMUPDOWN](self.mLparam) 48 | lpnmud.iPos = pos 49 | 50 | method getSpinDelta*(self: wSpinEvent): int {.property, inline.} = 51 | ## Gets the delta value. 52 | let lpnmud = cast[LPNMUPDOWN](self.mLparam) 53 | result = lpnmud.iDelta 54 | 55 | method setSpinDelta*(self: wSpinEvent, delta: int) {.property, inline.} = 56 | ## Set the value associated with the event. 57 | let lpnmud = cast[LPNMUPDOWN](self.mLparam) 58 | lpnmud.iDelta = delta 59 | -------------------------------------------------------------------------------- /wNim/private/events/wStatusBarEvent.nim: -------------------------------------------------------------------------------- 1 | #==================================================================== 2 | # 3 | # wNim - Nim's Windows GUI Framework 4 | # Copyright (c) Chen Kai-Hung, Ward 5 | # 6 | #==================================================================== 7 | 8 | ## These events are generated by wStatusBar. 9 | # 10 | ## :Superclass: 11 | ## `wCommandEvent `_ 12 | # 13 | ## :Seealso: 14 | ## `wStatusBar `_ 15 | # 16 | ## :Events: 17 | ## ================================ ============================================================= 18 | ## wStatusBarEvent Description 19 | ## ================================ ============================================================= 20 | ## wEvent_StatusBarLeftClick Clicked the left mouse button within the control. 21 | ## wEvent_StatusBarLeftDoubleClick Double-clicked the left mouse button within the control. 22 | ## wEvent_StatusBarRightClick Clicked the right mouse button within the control. 23 | ## wEvent_StatusBarRightDoubleClick Double-clicked the right mouse button within the control. 24 | ## ================================ ============================================================= 25 | 26 | include ../pragma 27 | import ../wBase 28 | 29 | wEventRegister(wStatusBarEvent): 30 | wEvent_StatusBarFirst 31 | wEvent_StatusBarLeftClick 32 | wEvent_StatusBarLeftDoubleClick 33 | wEvent_StatusBarRightClick 34 | wEvent_StatusBarRightDoubleClick 35 | wEvent_StatusBarLast 36 | 37 | method getIndex*(self: wStatusBarEvent): int {.property.} = 38 | ## Return the index of the field that was clicked. 39 | let lpnm = cast[LPNMMOUSE](self.mLparam) 40 | result = int lpnm.dwItemSpec 41 | -------------------------------------------------------------------------------- /wNim/private/events/wTextLinkEvent.nim: -------------------------------------------------------------------------------- 1 | #==================================================================== 2 | # 3 | # wNim - Nim's Windows GUI Framework 4 | # Copyright (c) Chen Kai-Hung, Ward 5 | # 6 | #==================================================================== 7 | 8 | ## These events are generated by wTxtCtrl when mouse events occur over 9 | ## link or url. 10 | # 11 | ## :Superclass: 12 | ## `wCommandEvent `_ 13 | # 14 | ## :Seealso: 15 | ## `wTextCtrl `_ 16 | # 17 | ## :Events: 18 | ## ============================== ============================================================= 19 | ## wTextLinkEvent Description 20 | ## ============================== ============================================================= 21 | ## wEvent_TextLink When mouse events occur over link or url. 22 | ## ============================== ============================================================= 23 | 24 | include ../pragma 25 | import ../wBase 26 | 27 | wEventRegister(wTextLinkEvent): 28 | wEvent_TextLink 29 | 30 | method getStart*(self: wTextLinkEvent): int {.property, inline.} = 31 | ## Returns the start of the link. 32 | result = self.mStart 33 | 34 | method getEnd*(self: wTextLinkEvent): int {.property, inline.} = 35 | ## Returns the end of the link. 36 | result = self.mEnd 37 | 38 | method getMouseEvent*(self: wTextLinkEvent): UINT {.property, inline.} = 39 | ## Returns the mouse event. 40 | result = self.mMouseEvent 41 | -------------------------------------------------------------------------------- /wNim/private/events/wTrayEvent.nim: -------------------------------------------------------------------------------- 1 | #==================================================================== 2 | # 3 | # wNim - Nim's Windows GUI Framework 4 | # Copyright (c) Chen Kai-Hung, Ward 5 | # 6 | #==================================================================== 7 | 8 | ## These events are generated by wFrame when the mouse moves or clicks on the 9 | ## system tray icon. 10 | # 11 | ## :Superclass: 12 | ## `wEvent `_ 13 | # 14 | ## :Seealso: 15 | ## `wFrame `_ 16 | # 17 | ## :Events: 18 | ## ============================== ============================================================= 19 | ## wTrayEvent Description 20 | ## ============================== ============================================================= 21 | ## wEvent_TrayLeftDown The left button was pressed. 22 | ## wEvent_TrayLeftUp The left button was released. 23 | ## wEvent_TrayRightDown The right button was pressed. 24 | ## wEvent_TrayRightUp The right button was released. 25 | ## wEvent_TrayLeftDoubleClick The the left button was double-clicked 26 | ## wEvent_TrayRightDoubleClick The the middle button was double-clicked 27 | ## wEvent_TrayMove The cursor moves. 28 | ## wEvent_TrayBalloonTimeout The balloon is dismissed because of a timeout. 29 | ## wEvent_TrayBalloonClick The balloon is dismissed because the user clicked the mouse. 30 | ## ============================== ============================================================= 31 | 32 | include ../pragma 33 | import ../wBase 34 | 35 | wEventRegister(wTrayEvent): 36 | wEvent_TrayFirst 37 | wEvent_TrayIcon 38 | wEvent_TrayLeftDown 39 | wEvent_TrayLeftUp 40 | wEvent_TrayRightDown 41 | wEvent_TrayRightUp 42 | wEvent_TrayLeftDoubleClick 43 | wEvent_TrayRightDoubleClick 44 | wEvent_TrayMove 45 | wEvent_TrayBalloonTimeout 46 | wEvent_TrayBalloonClick 47 | wEvent_TrayLast 48 | -------------------------------------------------------------------------------- /wNim/private/events/wTreeEvent.nim: -------------------------------------------------------------------------------- 1 | #==================================================================== 2 | # 3 | # wNim - Nim's Windows GUI Framework 4 | # Copyright (c) Chen Kai-Hung, Ward 5 | # 6 | #==================================================================== 7 | 8 | ## These events are generated by wTreeCtrl. 9 | # 10 | ## :Superclass: 11 | ## `wCommandEvent `_ 12 | # 13 | ## :Seealso: 14 | ## `wTreeCtrl `_ 15 | # 16 | ## :Events: 17 | ## ============================== ============================================================= 18 | ## wTreeEvent Description 19 | ## ============================== ============================================================= 20 | ## wEvent_TreeBeginDrag Begin dragging with the left mouse button. This event is 21 | ## vetoed by default. Call allow() To enable dragging. 22 | ## wEvent_TreeBeginRdrag Begin dragging with the right mouse button. This event is 23 | ## vetoed by default. Call allow() To enable dragging. 24 | ## wEvent_TreeEndDrag End dragging with the left or right mouse button. 25 | ## wEvent_TreeBeginLabelEdit Begin editing a label. This event can be vetoed. 26 | ## wEvent_TreeEndLabelEdit Finish editing a label. This event can be vetoed. 27 | ## wEvent_TreeDeleteItem An item was deleted. 28 | ## wEvent_TreeItemActivated The item has been activated (ENTER or double click). 29 | ## wEvent_TreeItemCollapsed The item has been collapsed. 30 | ## wEvent_TreeItemCollapsing The item is being collapsed. This event can be vetoed. 31 | ## wEvent_TreeItemExpanded The item has been expanded. 32 | ## wEvent_TreeItemExpanding The item is being expanded. This event can be vetoed. 33 | ## wEvent_TreeItemRightClick The user has clicked the item with the right mouse button. 34 | ## wEvent_TreeSelChanged Selection has changed. 35 | ## wEvent_TreeSelChanging Selection is changing. This event can be vetoed. 36 | ## wEvent_TreeItemMenu The context menu for the selected item has been requested, 37 | ## either by a right click or by using the menu key. 38 | ## ============================== ============================================================= 39 | 40 | include ../pragma 41 | import ../wBase 42 | 43 | wEventRegister(wTreeEvent): 44 | wEvent_TreeFirst 45 | wEvent_TreeBeginDrag 46 | wEvent_TreeBeginRdrag 47 | wEvent_TreeEndDrag 48 | wEvent_TreeBeginLabelEdit 49 | wEvent_TreeEndLabelEdit 50 | wEvent_TreeDeleteItem 51 | wEvent_TreeItemActivated 52 | wEvent_TreeItemCollapsed 53 | wEvent_TreeItemCollapsing 54 | wEvent_TreeItemExpanded 55 | wEvent_TreeItemExpanding 56 | wEvent_TreeItemRightClick 57 | wEvent_TreeSelChanged 58 | wEvent_TreeSelChanging 59 | wEvent_TreeItemMenu 60 | wEvent_TreeLast 61 | 62 | method getItem*(self: wTreeEvent): wTreeItem {.property, inline, raises: [].} = 63 | ## Returns the item. 64 | result.mTreeCtrl = self.mTreeCtrl 65 | result.mHandle = self.mHandle 66 | 67 | method getOldItem*(self: wTreeEvent): wTreeItem {.property, inline, raises: [].} = 68 | ## Returns the old item (valid for wEvent_TreeSelChanging, wEvent_TreeSelChanged, 69 | ## and wEvent_TreeEndDrag events). 70 | result.mTreeCtrl = self.mTreeCtrl 71 | result.mHandle = self.mOldHandle 72 | 73 | method getText*(self: wTreeEvent): string {.property, inline.} = 74 | ## The (new) item label for wEvent_TreeEndLabelEdit event. 75 | result = self.mText 76 | 77 | method getInsertMark*(self: wTreeEvent): int {.property, inline.} = 78 | ## Retrun insert mark position (valid for wEvent_TreeEndDrag event). 79 | result = self.mInsertMark 80 | 81 | method getPoint*(self: wTreeEvent): wPoint {.property, inline.} = 82 | ## Returns the position of the mouse pointer if the event is a drag or menu-context event. 83 | result = self.mPoint 84 | -------------------------------------------------------------------------------- /wNim/private/events/wWebViewEvent.nim: -------------------------------------------------------------------------------- 1 | #==================================================================== 2 | # 3 | # wNim - Nim's Windows GUI Framework 4 | # Copyright (c) Chen Kai-Hung, Ward 5 | # 6 | #==================================================================== 7 | 8 | ## A navigation event holds information about events associated with 9 | ## wWebView objects. 10 | # 11 | ## :Superclass: 12 | ## `wCommandEvent `_ 13 | # 14 | ## :Seealso: 15 | ## `wWebView `_ 16 | # 17 | ## :Events: 18 | ## ============================== ============================================================= 19 | ## wWebViewEvent Description 20 | ## ============================== ============================================================= 21 | ## wEvent_WebViewNavigating Generated before trying to get a resource. This event can be vetoed. 22 | ## wEvent_WebViewContextMenu Generated before trying to show context menu. This event can be vetoed. 23 | ## wEvent_WebViewNewWindow Generated when a new window is created. This event can be vetoed. 24 | ## wEvent_WebViewLoaded Generated when the document is fully loaded and displayed. 25 | ## wEvent_WebViewError Generated when a navigation error occurs. This event can be vetoed 26 | ## (cancel navigation to an error page). 27 | ## wEvent_WebViewTitleChanged Generated when the page title changes. 28 | ## wEvent_WebViewStatusChanged Generated when the status text changes. 29 | ## wEvent_WebViewHistoryChanged Generated when the history of visited pages changes. 30 | ## ============================== ============================================================= 31 | 32 | include ../pragma 33 | import ../wBase 34 | 35 | wEventRegister(wWebViewEvent): 36 | wEvent_WebViewFirst 37 | wEvent_WebViewNavigating 38 | wEvent_WebViewContextMenu 39 | wEvent_WebViewNewWindow 40 | wEvent_WebViewLoaded 41 | wEvent_WebViewError 42 | wEvent_WebViewTitleChanged 43 | wEvent_WebViewStatusChanged 44 | wEvent_WebViewHistoryChanged 45 | wEvent_WebViewLast 46 | 47 | method getUrl*(self: wWebViewEvent): string {.property, inline.} = 48 | ## Returns the url (valid for wEvent_WebViewNavigating, wEvent_WebViewNewWindow, 49 | ## and wEvent_WebViewError). 50 | result = self.mUrl 51 | 52 | method getText*(self: wWebViewEvent): string {.property, inline.} = 53 | ## Returns the text (valid for wEvent_WebViewStatusChanged and 54 | ## wEvent_WebViewTitleChanged). 55 | result = self.mText 56 | 57 | method getErrorCode*(self: wWebViewEvent): int {.property, inline.} = 58 | ## Returns the error code (valid for wEvent_WebViewError). 59 | result = int self.mLparam 60 | -------------------------------------------------------------------------------- /wNim/private/gdiobjects/wGdiObject.nim: -------------------------------------------------------------------------------- 1 | #==================================================================== 2 | # 3 | # wNim - Nim's Windows GUI Framework 4 | # Copyright (c) Chen Kai-Hung, Ward 5 | # 6 | #==================================================================== 7 | 8 | ## wGdiObject is the superclasses of all the GDI objects, such as wPen, wBrush 9 | ## and wFont. 10 | # 11 | ## :Subclasses: 12 | ## `wPen `_ 13 | ## `wBrusn `_ 14 | ## `wFont `_ 15 | ## `wBitmap `_ 16 | ## `wIcon `_ 17 | ## `wCursor `_ 18 | ## `wRegion `_ 19 | # 20 | ## :Seealso: 21 | ## `wDC `_ 22 | 23 | include ../pragma 24 | import ../wBase 25 | 26 | type 27 | wGdiObjectError* = object of wError 28 | 29 | proc getHandle*(self: wGdiObject): HANDLE {.validate, property, inline.} = 30 | ## Gets the real resource handle in system. 31 | result = self.mHandle 32 | 33 | proc init*(self: wGdiObject) {.validate, inline.} = 34 | ## Initializer. 35 | self.mHandle = 0 36 | self.mDeletable = true 37 | 38 | method delete*(self: wGdiObject) {.base, inline.} = 39 | ## Nim's garbage collector will delete this object by default. 40 | ## However, sometimes you maybe want do that by yourself. 41 | `=destroy`(self[]) 42 | 43 | when not isMainModule: # hide from doc 44 | 45 | template wGDIStock*(typ: typedesc, sn: int, obj: wGdiObject): untyped = 46 | App() 47 | if sn > wBaseApp.mGDIStockSeq.high: 48 | wBaseApp.mGDIStockSeq.setlen(sn+1) 49 | 50 | if wBaseApp.mGDIStockSeq[sn] == nil: 51 | wBaseApp.mGDIStockSeq[sn] = obj 52 | 53 | typ(wBaseApp.mGDIStockSeq[sn]) 54 | 55 | DefineIncrement(0): 56 | NormalFont 57 | SmallFont 58 | LargeFont 59 | ItalicFont 60 | BoldFont 61 | BlackPen 62 | WhitePen 63 | TransparentPen 64 | RedPen 65 | CyanPen 66 | GreenPen 67 | GreyPen 68 | MediumGreyPen 69 | LightGreyPen 70 | BlackDashedPen 71 | BlackBrush 72 | WhiteBrush 73 | GreyBrush 74 | TransparentBrush 75 | LightGreyBrush 76 | MediumGreyBrush 77 | BlueBrush 78 | GreenBrush 79 | CyanBrush 80 | RedBrush 81 | NilBitmap 82 | NilCursor 83 | DefaultCursor 84 | ArrorCursor 85 | SizeAllCursor 86 | SizeWeCursor 87 | SizeNsCursor 88 | HandCursor 89 | NilRegion 90 | -------------------------------------------------------------------------------- /wNim/private/kiwi/constraint.nim: -------------------------------------------------------------------------------- 1 | import tables 2 | 3 | import expression, strength, variable, util, term 4 | 5 | type 6 | Constraint* = ref object 7 | expression*: Expression 8 | strength*: float 9 | op*: RelationalOperator 10 | 11 | RelationalOperator* = enum 12 | OP_LE 13 | OP_GE 14 | OP_EQ 15 | 16 | proc reduce(e: Expression): Expression = 17 | var vars = initTable[Variable, float]() 18 | for term in e.terms: 19 | let v = term.variable 20 | var value = vars.getOrDefault(v) 21 | value += term.coefficient 22 | vars[v] = value 23 | 24 | var reducedTerms = newSeqOfCap[Term](vars.len) 25 | for variable, coef in vars: 26 | reducedTerms.add(newTerm(variable, coef)) 27 | 28 | result = newExpression(reducedTerms, e.constant) 29 | 30 | proc newConstraint*(e: Expression, op: RelationalOperator, strength: float): Constraint = 31 | result.new() 32 | result.expression = reduce(e) 33 | result.op = op 34 | result.strength = clipStrength(strength) 35 | 36 | proc newConstraint*(e: Expression, op: RelationalOperator): Constraint = 37 | newConstraint(e, op, REQUIRED) 38 | 39 | proc newConstraint*(other: Constraint, strength: float): Constraint = 40 | newConstraint(other.expression, other.op, strength) 41 | 42 | proc `$`*(c: Constraint): string = 43 | "expression: (" & $c.expression & ") strength: " & $c.strength & " operator: " & $c.op 44 | -------------------------------------------------------------------------------- /wNim/private/kiwi/expression.nim: -------------------------------------------------------------------------------- 1 | import term, variable 2 | 3 | type Expression* = ref object 4 | terms*: seq[Term] 5 | constant*: float 6 | 7 | proc newExpression*(terms: seq[Term], constant: float = 0): Expression = 8 | result.new() 9 | result.terms = terms 10 | result.constant = constant 11 | 12 | proc newExpression*(constant: float = 0): Expression = 13 | newExpression(@[], constant) 14 | 15 | proc newExpression*(term: Term, constant: float = 0): Expression = 16 | newExpression(@[term], constant) 17 | 18 | proc newExpression*(v: Variable): Expression = 19 | newExpression(newTerm(v)) 20 | 21 | proc value*(e: Expression): float = 22 | result = e.constant 23 | for t in e.terms: 24 | result += t.value 25 | 26 | proc isConstant*(e: Expression): bool = e.terms.len == 0 27 | 28 | proc `$`*(e: Expression): string = 29 | result = "isConstant: " & $e.isConstant & " constant: " & $e.constant 30 | if not e.isConstant: 31 | result &= " terms: [" 32 | for term in e.terms: 33 | result &= "(" 34 | result &= $term 35 | result &= ")" 36 | result &= "]" 37 | -------------------------------------------------------------------------------- /wNim/private/kiwi/kiwi.nim: -------------------------------------------------------------------------------- 1 | import variable, constraint, term, expression, symbolics, symbolicints, solver, strength 2 | export variable, constraint, term, expression, symbolics, symbolicints, solver, strength 3 | -------------------------------------------------------------------------------- /wNim/private/kiwi/row.nim: -------------------------------------------------------------------------------- 1 | import tables 2 | 3 | import symbol, util 4 | 5 | type Row* = ref object 6 | constant*: float 7 | cells*: Table[Symbol, float] 8 | 9 | proc newRow*(constant: float = 0): Row = 10 | result.new() 11 | result.cells = initTable[Symbol, float]() 12 | result.constant = constant 13 | 14 | proc newRow*(other: Row): Row = 15 | result.new() 16 | result.cells = other.cells 17 | result.constant = other.constant 18 | 19 | proc add*(r: Row, value: float): float = 20 | ## Add a constant value to the row constant. 21 | r.constant += value 22 | result = r.constant 23 | 24 | proc insert*(r: Row, symbol: Symbol, coefficient: float = 1.0) = 25 | ## Insert a symbol into the row with a given coefficient. 26 | ## 27 | ## If the symbol already exists in the row, the coefficient will be 28 | ## added to the existing coefficient. If the resulting coefficient 29 | ## is zero, the symbol will be removed from the row 30 | 31 | let coefficient = coefficient + r.cells.getOrDefault(symbol) 32 | if nearZero(coefficient): 33 | r.cells.del(symbol) 34 | else: 35 | r.cells[symbol] = coefficient 36 | 37 | proc insert*(r, other: Row, coefficient: float = 1.0) = 38 | ## Insert a row into this row with a given coefficient. 39 | ## The constant and the cells of the other row will be multiplied by 40 | ## the coefficient and added to this row. Any cell with a resulting 41 | ## coefficient of zero will be removed from the row. 42 | 43 | r.constant += other.constant * coefficient 44 | 45 | for s, v in other.cells: 46 | let coeff = v * coefficient 47 | 48 | # r.insert(s, coeff) this line looks different than the c++ 49 | 50 | # changes start here 51 | let temp = r.cells.getOrDefault(s) + coeff 52 | if nearZero(temp): 53 | r.cells.del(s) 54 | else: 55 | r.cells[s] = temp 56 | 57 | proc remove*(r: Row, symbol: Symbol) = 58 | ## Remove the given symbol from the row. 59 | r.cells.del(symbol) 60 | 61 | proc reverseSign*(r: Row) = 62 | ## Reverse the sign of the constant and all cells in the row. 63 | r.constant = -r.constant 64 | for s, v in r.cells: 65 | r.cells[s] = -v 66 | 67 | proc solveFor*(r: Row, symbol: Symbol) = 68 | ## Solve the row for the given symbol. 69 | ## 70 | ## This method assumes the row is of the form a * x + b * y + c = 0 71 | ## and (assuming solve for x) will modify the row to represent the 72 | ## right hand side of x = -b/a * y - c / a. The target symbol will 73 | ## be removed from the row, and the constant and other cells will 74 | ## be multiplied by the negative inverse of the target coefficient. 75 | ## The given symbol *must* exist in the row. 76 | 77 | let coeff = -1.0 / r.cells[symbol] 78 | r.cells.del(symbol) 79 | r.constant *= coeff 80 | 81 | for s, v in r.cells: 82 | r.cells[s] = v * coeff 83 | 84 | proc solveFor*(r: Row, lhs, rhs: Symbol) = 85 | ## Solve the row for the given symbols. 86 | ## 87 | ## This method assumes the row is of the form x = b * y + c and will 88 | ## solve the row such that y = x / b - c / b. The rhs symbol will be 89 | ## removed from the row, the lhs added, and the result divided by the 90 | ## negative inverse of the rhs coefficient. 91 | ## The lhs symbol *must not* exist in the row, and the rhs symbol 92 | ## must* exist in the row. 93 | 94 | r.insert(lhs, -1.0) 95 | r.solveFor(rhs) 96 | 97 | proc coefficientFor*(r: Row, symbol: Symbol): float {.inline.} = 98 | ## Get the coefficient for the given symbol. 99 | ## 100 | ## If the symbol does not exist in the row, zero will be returned. 101 | r.cells.getOrDefault(symbol) 102 | 103 | proc substitute*(r: Row, symbol: Symbol, row: Row) = 104 | ## Substitute a symbol with the data from another row. 105 | ## 106 | ## Given a row of the form a * x + b and a substitution of the 107 | ## form x = 3 * y + c the row will be updated to reflect the 108 | ## expression 3 * a * y + a * c + b. 109 | ## If the symbol does not exist in the row, this is a no-op. 110 | if symbol in r.cells: 111 | let coefficient = r.cells[symbol] 112 | r.cells.del(symbol) 113 | r.insert(row, coefficient) 114 | -------------------------------------------------------------------------------- /wNim/private/kiwi/strength.nim: -------------------------------------------------------------------------------- 1 | proc createStrength*(a: float; b: float, c: float, w: float = 1.0): float = 2 | result += max(0.0, min(1000.0, a * w)) * 1000000.0; 3 | result += max(0.0, min(1000.0, b * w)) * 1000.0; 4 | result += max(0.0, min(1000.0, c * w)); 5 | 6 | const REQUIRED* = createStrength(1000.0, 1000.0, 1000.0) 7 | const STRONG* = createStrength(1.0, 0.0, 0.0) 8 | const MEDIUM* = createStrength(0.0, 1.0, 0.0) 9 | const WEAK* = createStrength(0.0, 0.0, 1.0) 10 | 11 | proc clipStrength*(value: float): float {.inline.} = clamp(value, 0, REQUIRED) 12 | -------------------------------------------------------------------------------- /wNim/private/kiwi/symbol.nim: -------------------------------------------------------------------------------- 1 | type 2 | SymbolKind* = enum 3 | EXTERNAL, 4 | SLACK, 5 | ERROR, 6 | DUMMY 7 | 8 | Symbol* = distinct uint32 9 | 10 | proc newSymbol*(uniqueId: uint32, kind: SymbolKind): Symbol {.inline.} = 11 | Symbol(uint32(uniqueId and 0x3fffffff'u32) or (ord(kind).uint32 shl 30)) 12 | 13 | proc `==`*(a, b: Symbol): bool {.borrow.} 14 | 15 | template kind*(s: Symbol): SymbolKind = SymbolKind(s.uint32 shr 30) 16 | template invalid*(s: Symbol): bool = s.uint32 == 0 17 | template valid*(s: Symbol): bool = s.uint32 != 0 18 | -------------------------------------------------------------------------------- /wNim/private/kiwi/symbolicints.nim: -------------------------------------------------------------------------------- 1 | # Let kiwi deal with int expression 2 | 3 | import term, variable, expression, constraint 4 | 5 | template `*`*(variable: Variable, coefficient: int): Term = `*`(variable, float coefficient) 6 | template `/`*(variable: Variable, denominator: int): Term = `/`(variable, float denominator) 7 | template `*`*(term: Term, coefficient: int): Term = `*`(term, float coefficient) 8 | template `/`*(term: Term, denominator: int): Term = `/`(term, float denominator) 9 | template `*`*(expression: Expression, coefficient: int): Expression = `*`(expression, float coefficient) 10 | template `/`*(expression: Expression, denominator: int): Expression = `/`(expression, float denominator) 11 | template `*`*(lhs: int, rhs: Expression): Expression = `*`(float lhs, rhs) 12 | template `*`*(lhs: int, rhs: Term | Variable): Term = `*`(float lhs, rhs) 13 | template `+`*(expression: Expression, constant: int): Expression = `+`(expression, float constant) 14 | template `-`*(lhs: Expression, rhs: int): Expression = `-`(lhs, float rhs) 15 | template `+`*(term: Term, constant: int): Expression = `+`(term, float constant) 16 | template `-`*(lhs: Term, rhs: int): Expression = `-`(lhs, float rhs) 17 | template `+`*(variable: Variable, constant: int): Expression = `+`(variable, float constant) 18 | template `-`*(lhs: Variable, rhs: int): Expression = `-`(lhs, float rhs) 19 | template `+`*(lhs: int, rhs: Expression | Term | Variable): Expression = `+`(float lhs, rhs) 20 | template `-`*(lhs: int, rhs: Expression | Term | Variable): Expression = `-`(float lhs, rhs) 21 | template `==`*(expression: Expression, constant: int): Constraint = `==`(expression, float constant) 22 | template `<=`*(expression: Expression, constant: int): Constraint = `<=`(expression, float constant) 23 | template `>=`*(expression: Expression, constant: int): Constraint = `>=`(expression, float constant) 24 | template `==`*(lhs: Term, rhs: int): Constraint = `==`(lhs, float rhs) 25 | template `<=`*(lhs: Term, rhs: int): Constraint = `<=`(lhs, float rhs) 26 | template `>=`*(lhs: Term, rhs: int): Constraint = `>=`(lhs, float rhs) 27 | template `==`*(variable: Variable, constant: int): Constraint = `==`(variable, float constant) 28 | template `<=`*(lhs: Variable, rhs: int): Constraint = `<=`(lhs, float rhs) 29 | template `>=`*(variable: Variable, constant: int): Constraint = `>=`(variable, float constant) 30 | template `==`*(lhs: int, rhs: Expression | Term | Variable): Constraint = `==`(float lhs, rhs) 31 | template `<=`*(constant: int, expression: Expression): Constraint = `<=`(float constant, expression) 32 | template `<=`*(constant: int, term: Term): Constraint = `<=`(float constant, term) 33 | template `<=`*(constant: int, variable: Variable): Constraint = `<=`(float constant, variable) 34 | template `>=`*(constant: int, term: Term): Constraint = `>=`(float constant, term) 35 | template `>=`*(constant: int, variable: Variable): Constraint = `>=`(float constant, variable) 36 | -------------------------------------------------------------------------------- /wNim/private/kiwi/term.nim: -------------------------------------------------------------------------------- 1 | import variable 2 | 3 | type Term* = object 4 | variable*: Variable 5 | coefficient*: float 6 | 7 | proc newTerm*(variable: Variable, coefficient: float = 1): Term {.inline.} = 8 | result.variable = variable 9 | result.coefficient = coefficient 10 | 11 | proc value*(t: Term): float {.inline.} = 12 | t.coefficient * t.variable.value 13 | 14 | proc `$`*(t: Term): string = 15 | "variable: (" & $t.variable & ") coefficient: " & $t.coefficient 16 | -------------------------------------------------------------------------------- /wNim/private/kiwi/util.nim: -------------------------------------------------------------------------------- 1 | import hashes 2 | 3 | const EPS = 1.0e-8; 4 | 5 | proc nearZero*(value: float): bool {.inline.} = abs(value) < EPS 6 | 7 | when defined(js): 8 | var idCounter = 0 9 | proc hash*(o: ref object): Hash = 10 | var id = 0 11 | var cnt = idCounter 12 | {.emit: """ 13 | if (`o`.__kiwi_objid === undefined) { 14 | `o`.__kiwi_objid = ++`cnt`; 15 | } 16 | `id` = `o`.__kiwi_objid; 17 | """.} 18 | idCounter = cnt 19 | hash(id) 20 | else: 21 | proc hash*(o: ref object): Hash {.inline.} = hash(cast[int](o)) 22 | -------------------------------------------------------------------------------- /wNim/private/kiwi/variable.nim: -------------------------------------------------------------------------------- 1 | type Variable* = ref object 2 | mName: string 3 | value*: float 4 | 5 | proc newVariable*(name: string, value: float = 0): Variable = 6 | result.new() 7 | result.mName = name 8 | result.value = value 9 | 10 | proc newVariable*(value: float = 0): Variable = 11 | result.new() 12 | result.mName = ":anonymous" 13 | result.value = value 14 | 15 | proc name*(v: Variable): string = v.mName 16 | 17 | proc `$`*(v: Variable): string = 18 | "name: " & v.name & " value: " & $v.value 19 | -------------------------------------------------------------------------------- /wNim/private/pragma.nim: -------------------------------------------------------------------------------- 1 | #==================================================================== 2 | # 3 | # wNim - Nim's Windows GUI Framework 4 | # Copyright (c) Chen Kai-Hung, Ward 5 | # 6 | #==================================================================== 7 | 8 | {.experimental.} 9 | 10 | {.warning[LockLevel]: off.} 11 | 12 | when compiles(block: {.warning[CastSizes]: off.}): 13 | {.warning[CastSizes]: off.} 14 | 15 | when compiles(block: {.warning[BareExcept]: off.}): 16 | {.warning[BareExcept]: off.} 17 | 18 | when defined(gcDestructors): {.push sinkInference: off.} 19 | -------------------------------------------------------------------------------- /wNim/private/wBase.nim: -------------------------------------------------------------------------------- 1 | #==================================================================== 2 | # 3 | # wNim - Nim's Windows GUI Framework 4 | # Copyright (c) Chen Kai-Hung, Ward 5 | # 6 | #==================================================================== 7 | 8 | ## Basic types definition for wNim. 9 | 10 | include pragma 11 | 12 | # Export some modules that every module in wNim depends on. 13 | import winim/[winstr, utils], winim/inc/[windef, winbase], kiwi/kiwi 14 | export winstr, utils, windef, winbase, kiwi 15 | 16 | import winimx except BITMAP 17 | export winimx except BITMAP 18 | 19 | import wTypes, wMacros, wHelper 20 | export wTypes, wMacros, wHelper 21 | 22 | import consts/[wColors, wKeyCodes] 23 | export wColors, wKeyCodes 24 | 25 | # Needs a new line so that wApp can use wEventId() in wMacros. 26 | import wApp 27 | export wApp 28 | -------------------------------------------------------------------------------- /wNim/private/wPanel.nim: -------------------------------------------------------------------------------- 1 | #==================================================================== 2 | # 3 | # wNim - Nim's Windows GUI Framework 4 | # Copyright (c) Chen Kai-Hung, Ward 5 | # 6 | #==================================================================== 7 | 8 | ## A panel is a window on which controls are placed. It is usually placed within 9 | ## a frame. 10 | # 11 | ## :Superclass: 12 | ## `wWindow `_ 13 | # 14 | ## :Seealso: 15 | ## `wControl `_ 16 | 17 | include pragma 18 | import wBase, wWindow 19 | export wWindow 20 | 21 | wClass(wPanel of wWindow): 22 | 23 | method release*(self: wPanel) = 24 | ## Release all the resources during destroying. Used internally. 25 | free(self[]) 26 | 27 | proc init*(self: wPanel, parent: wWindow, pos = wDefaultPoint, size = wDefaultSize, 28 | style: wStyle = 0, className = "wPanel") {.validate, inline.} = 29 | ## Initializer. 30 | wValidate(parent) 31 | self.wWindow.initVerbosely(parent=parent, pos=pos, size=size, 32 | style=style, className=className, bgColor=GetSysColor(COLOR_BTNFACE)) 33 | -------------------------------------------------------------------------------- /wNim/private/wToolTip.nim: -------------------------------------------------------------------------------- 1 | #==================================================================== 2 | # 3 | # wNim - Nim's Windows GUI Framework 4 | # Copyright (c) Chen Kai-Hung, Ward 5 | # 6 | #==================================================================== 7 | 8 | ## Creates a standalone tooltip anywhere on the screen. 9 | # 10 | ## :Superclass: 11 | ## `wWindow `_ 12 | 13 | include pragma 14 | import wBase, wWindow 15 | export wWindow 16 | 17 | method show*(self: wToolTip, flag = true) {.inline.} = 18 | ## Shows or hides the tooltip. 19 | SendMessage(self.mHwnd, TTM_TRACKACTIVATE, if flag: 1 else: 0, cast[LPARAM](&self.mToolInfo)) 20 | 21 | proc setBalloon*(self: wToolTip, flag = true) {.validate, property.} = 22 | ## Indicates that the tooltip control has the appearance of a cartoon "balloon". 23 | if flag: 24 | self.addWindowStyle(TTS_BALLOON) 25 | else: 26 | self.clearWindowStyle(TTS_BALLOON) 27 | 28 | proc setTip*(self: wToolTip, text = "", pos = wDefaultPoint, title = "", 29 | icon: wIcon = nil) {.validate, property.} = 30 | ## Sets the tip by given text, pos, title and icon. 31 | if text.len == 0: 32 | self.hide() 33 | 34 | else: 35 | self.setLabel(text) 36 | self.move(pos) 37 | 38 | if title.len != 0: 39 | # MSDN: When calling TTM_SETTITLE, the string pointed to by lParam must not 40 | # exceed 100 TCHARs in length 41 | if icon.isNil: 42 | SendMessage(self.mHwnd, TTM_SETTITLE, TTI_INFO, &T(title.substr(0, 99))) 43 | else: 44 | SendMessage(self.mHwnd, TTM_SETTITLE, icon.mHandle, &T(title.substr(0, 99))) 45 | 46 | self.show() 47 | 48 | if pos == wDefaultPoint: 49 | # get the default pos (near mouse cursor, count by system) 50 | self.mToolInfo.uFlags = 0 51 | SendMessage(self.mHwnd, TTM_SETTOOLINFO, 0, cast[LPARAM](&self.mToolInfo)) 52 | self.move(self.getPosition()) 53 | 54 | proc setToolTip*(self: wToolTip, maxWidth = wDefault, autoPop = wDefault, 55 | delay = wDefault, reshow = wDefault) {.validate, property.} = 56 | ## Sets the parameters of the tooltip. -1 to restore the default. 57 | if maxWidth != wDefault: 58 | SendMessage(self.mHwnd, TTM_SETMAXTIPWIDTH, 0, maxWidth) 59 | 60 | if autoPop != wDefault: 61 | SendMessage(self.mHwnd, TTM_SETDELAYTIME, TTDT_AUTOPOP, autoPop and 0xffff) 62 | 63 | if delay != wDefault: 64 | SendMessage(self.mHwnd, TTM_SETDELAYTIME, TTDT_INITIAL, delay and 0xffff) 65 | 66 | if reshow != wDefault: 67 | SendMessage(self.mHwnd, TTM_SETDELAYTIME, TTDT_RESHOW, reshow and 0xffff) 68 | 69 | wClass(wToolTip of wWindow): 70 | 71 | method release*(self: wToolTip) = 72 | ## Release all the resources during destroying. Used internally. 73 | free(self[]) 74 | 75 | proc init*(self: wToolTip, text = "", pos = wDefaultPoint, title = "", 76 | icon: wIcon = nil) {.validate.} = 77 | ## Initializer. 78 | self.mText = text 79 | self.mToolInfo = TOOLINFO(cbSize: sizeof(TOOLINFO), 80 | uFlags: 0, lpszText: self.mText) 81 | 82 | let hwnd = CreateWindowEx(WS_EX_TOPMOST, TOOLTIPS_CLASS, nil, 83 | WS_POPUP or TTS_NOPREFIX or TTS_ALWAYSTIP, CW_USEDEFAULT, CW_USEDEFAULT, 84 | CW_USEDEFAULT, CW_USEDEFAULT, 0, 0, wAppGetInstance(), nil) 85 | 86 | SendMessage(hwnd, TTM_ADDTOOL, 0, cast[LPARAM](&self.mToolInfo)) 87 | self.init(hwnd) 88 | 89 | # This handler let tooltip close. 90 | self.systemDisconnect(WM_MOUSEMOVE, wWindow_DoMouseMove) 91 | self.systemDisconnect(WM_MOUSELEAVE, wWindow_DoMouseLeave) 92 | 93 | # So that SetWindowText() and GetWindowText() work. 94 | self.systemConnect(WM_SETTEXT) do (event: wEvent): 95 | self.mText = $(cast[LPTSTR](event.mLparam)) 96 | self.mToolInfo.lpszText = self.mText 97 | SendMessage(self.mHwnd, TTM_UPDATETIPTEXT, 0, cast[LPARAM](&self.mToolInfo)) 98 | 99 | # So that move() works. 100 | var inMove = false 101 | self.systemConnect(WM_MOVE) do (event: wEvent): 102 | if not inMove: 103 | inMove = true 104 | self.mToolInfo.uFlags = TTF_TRACK 105 | SendMessage(self.mHwnd, TTM_SETTOOLINFO, 0, cast[LPARAM](&self.mToolInfo)) 106 | SendMessage(self.mHwnd, TTM_TRACKPOSITION, 0, event.mLparam) 107 | inMove = false 108 | 109 | self.setTip(text, pos, title, icon) 110 | -------------------------------------------------------------------------------- /wNim/wAcceleratorTable.nim: -------------------------------------------------------------------------------- 1 | #==================================================================== 2 | # 3 | # wNim - Nim's Windows GUI Framework 4 | # Copyright (c) Chen Kai-Hung, Ward 5 | # 6 | #==================================================================== 7 | 8 | import private/wAcceleratorTable 9 | export wAcceleratorTable 10 | -------------------------------------------------------------------------------- /wNim/wApp.nim: -------------------------------------------------------------------------------- 1 | #==================================================================== 2 | # 3 | # wNim - Nim's Windows GUI Framework 4 | # Copyright (c) Chen Kai-Hung, Ward 5 | # 6 | #==================================================================== 7 | 8 | import private/wApp 9 | export wApp 10 | -------------------------------------------------------------------------------- /wNim/wBitmap.nim: -------------------------------------------------------------------------------- 1 | #==================================================================== 2 | # 3 | # wNim - Nim's Windows GUI Framework 4 | # Copyright (c) Chen Kai-Hung, Ward 5 | # 6 | #==================================================================== 7 | 8 | import private/gdiobjects/wBitmap 9 | export wBitmap 10 | -------------------------------------------------------------------------------- /wNim/wBrush.nim: -------------------------------------------------------------------------------- 1 | #==================================================================== 2 | # 3 | # wNim - Nim's Windows GUI Framework 4 | # Copyright (c) Chen Kai-Hung, Ward 5 | # 6 | #==================================================================== 7 | 8 | import private/gdiobjects/wBrush 9 | export wBrush 10 | -------------------------------------------------------------------------------- /wNim/wButton.nim: -------------------------------------------------------------------------------- 1 | #==================================================================== 2 | # 3 | # wNim - Nim's Windows GUI Framework 4 | # Copyright (c) Chen Kai-Hung, Ward 5 | # 6 | #==================================================================== 7 | 8 | import private/controls/wButton 9 | export wButton 10 | -------------------------------------------------------------------------------- /wNim/wCalendarCtrl.nim: -------------------------------------------------------------------------------- 1 | #==================================================================== 2 | # 3 | # wNim - Nim's Windows GUI Framework 4 | # Copyright (c) Chen Kai-Hung, Ward 5 | # 6 | #==================================================================== 7 | 8 | import private/controls/wCalendarCtrl 9 | export wCalendarCtrl 10 | -------------------------------------------------------------------------------- /wNim/wCheckBox.nim: -------------------------------------------------------------------------------- 1 | #==================================================================== 2 | # 3 | # wNim - Nim's Windows GUI Framework 4 | # Copyright (c) Chen Kai-Hung, Ward 5 | # 6 | #==================================================================== 7 | 8 | import private/controls/wCheckBox 9 | export wCheckBox 10 | -------------------------------------------------------------------------------- /wNim/wCheckComboBox.nim: -------------------------------------------------------------------------------- 1 | #==================================================================== 2 | # 3 | # wNim - Nim's Windows GUI Framework 4 | # Copyright (c) Chen Kai-Hung, Ward 5 | # 6 | #==================================================================== 7 | 8 | import private/controls/wCheckComboBox 9 | export wCheckComboBox 10 | -------------------------------------------------------------------------------- /wNim/wClientDC.nim: -------------------------------------------------------------------------------- 1 | #==================================================================== 2 | # 3 | # wNim - Nim's Windows GUI Framework 4 | # Copyright (c) Chen Kai-Hung, Ward 5 | # 6 | #==================================================================== 7 | 8 | import private/dc/wClientDC 9 | export wClientDC 10 | -------------------------------------------------------------------------------- /wNim/wColorDialog.nim: -------------------------------------------------------------------------------- 1 | #==================================================================== 2 | # 3 | # wNim - Nim's Windows GUI Framework 4 | # Copyright (c) Chen Kai-Hung, Ward 5 | # 6 | #==================================================================== 7 | 8 | import private/dialogs/wColorDialog 9 | export wColorDialog 10 | -------------------------------------------------------------------------------- /wNim/wComboBox.nim: -------------------------------------------------------------------------------- 1 | #==================================================================== 2 | # 3 | # wNim - Nim's Windows GUI Framework 4 | # Copyright (c) Chen Kai-Hung, Ward 5 | # 6 | #==================================================================== 7 | 8 | import private/controls/wComboBox 9 | export wComboBox 10 | -------------------------------------------------------------------------------- /wNim/wControl.nim: -------------------------------------------------------------------------------- 1 | #==================================================================== 2 | # 3 | # wNim - Nim's Windows GUI Framework 4 | # Copyright (c) Chen Kai-Hung, Ward 5 | # 6 | #==================================================================== 7 | 8 | import private/controls/wControl 9 | export wControl 10 | -------------------------------------------------------------------------------- /wNim/wCursor.nim: -------------------------------------------------------------------------------- 1 | #==================================================================== 2 | # 3 | # wNim - Nim's Windows GUI Framework 4 | # Copyright (c) Chen Kai-Hung, Ward 5 | # 6 | #==================================================================== 7 | 8 | import private/gdiobjects/wCursor 9 | export wCursor 10 | -------------------------------------------------------------------------------- /wNim/wDC.nim: -------------------------------------------------------------------------------- 1 | #==================================================================== 2 | # 3 | # wNim - Nim's Windows GUI Framework 4 | # Copyright (c) Chen Kai-Hung, Ward 5 | # 6 | #==================================================================== 7 | 8 | import private/dc/wDC 9 | export wDC 10 | -------------------------------------------------------------------------------- /wNim/wDataObject.nim: -------------------------------------------------------------------------------- 1 | #==================================================================== 2 | # 3 | # wNim - Nim's Windows GUI Framework 4 | # Copyright (c) Chen Kai-Hung, Ward 5 | # 6 | #==================================================================== 7 | 8 | import private/wDataObject 9 | export wDataObject 10 | -------------------------------------------------------------------------------- /wNim/wDatePickerCtrl.nim: -------------------------------------------------------------------------------- 1 | #==================================================================== 2 | # 3 | # wNim - Nim's Windows GUI Framework 4 | # Copyright (c) Chen Kai-Hung, Ward 5 | # 6 | #==================================================================== 7 | 8 | import private/controls/wDatePickerCtrl 9 | export wDatePickerCtrl 10 | -------------------------------------------------------------------------------- /wNim/wDialog.nim: -------------------------------------------------------------------------------- 1 | #==================================================================== 2 | # 3 | # wNim - Nim's Windows GUI Framework 4 | # Copyright (c) Chen Kai-Hung, Ward 5 | # 6 | #==================================================================== 7 | 8 | import private/dialogs/wDialog 9 | export wDialog 10 | -------------------------------------------------------------------------------- /wNim/wDirDialog.nim: -------------------------------------------------------------------------------- 1 | #==================================================================== 2 | # 3 | # wNim - Nim's Windows GUI Framework 4 | # Copyright (c) Chen Kai-Hung, Ward 5 | # 6 | #==================================================================== 7 | 8 | import private/dialogs/wDirDialog 9 | export wDirDialog 10 | -------------------------------------------------------------------------------- /wNim/wEvent.nim: -------------------------------------------------------------------------------- 1 | #==================================================================== 2 | # 3 | # wNim - Nim's Windows GUI Framework 4 | # Copyright (c) Chen Kai-Hung, Ward 5 | # 6 | #==================================================================== 7 | 8 | import private/wEvent 9 | export wEvent 10 | -------------------------------------------------------------------------------- /wNim/wFileDialog.nim: -------------------------------------------------------------------------------- 1 | #==================================================================== 2 | # 3 | # wNim - Nim's Windows GUI Framework 4 | # Copyright (c) Chen Kai-Hung, Ward 5 | # 6 | #==================================================================== 7 | 8 | import private/dialogs/wFileDialog 9 | export wFileDialog 10 | -------------------------------------------------------------------------------- /wNim/wFindReplaceDialog.nim: -------------------------------------------------------------------------------- 1 | #==================================================================== 2 | # 3 | # wNim - Nim's Windows GUI Framework 4 | # Copyright (c) Chen Kai-Hung, Ward 5 | # 6 | #==================================================================== 7 | 8 | import private/dialogs/wFindReplaceDialog 9 | export wFindReplaceDialog 10 | -------------------------------------------------------------------------------- /wNim/wFont.nim: -------------------------------------------------------------------------------- 1 | #==================================================================== 2 | # 3 | # wNim - Nim's Windows GUI Framework 4 | # Copyright (c) Chen Kai-Hung, Ward 5 | # 6 | #==================================================================== 7 | 8 | import private/gdiobjects/wFont 9 | export wFont 10 | -------------------------------------------------------------------------------- /wNim/wFontDialog.nim: -------------------------------------------------------------------------------- 1 | #==================================================================== 2 | # 3 | # wNim - Nim's Windows GUI Framework 4 | # Copyright (c) Chen Kai-Hung, Ward 5 | # 6 | #==================================================================== 7 | 8 | import private/dialogs/wFontDialog 9 | export wFontDialog 10 | -------------------------------------------------------------------------------- /wNim/wFrame.nim: -------------------------------------------------------------------------------- 1 | #==================================================================== 2 | # 3 | # wNim - Nim's Windows GUI Framework 4 | # Copyright (c) Chen Kai-Hung, Ward 5 | # 6 | #==================================================================== 7 | 8 | import private/wFrame 9 | export wFrame 10 | -------------------------------------------------------------------------------- /wNim/wGauge.nim: -------------------------------------------------------------------------------- 1 | #==================================================================== 2 | # 3 | # wNim - Nim's Windows GUI Framework 4 | # Copyright (c) Chen Kai-Hung, Ward 5 | # 6 | #==================================================================== 7 | 8 | import private/controls/wGauge 9 | export wGauge 10 | -------------------------------------------------------------------------------- /wNim/wGdiObject.nim: -------------------------------------------------------------------------------- 1 | #==================================================================== 2 | # 3 | # wNim - Nim's Windows GUI Framework 4 | # Copyright (c) Chen Kai-Hung, Ward 5 | # 6 | #==================================================================== 7 | 8 | import private/gdiobjects/wGdiObject 9 | export wGdiObject 10 | -------------------------------------------------------------------------------- /wNim/wHotkeyCtrl.nim: -------------------------------------------------------------------------------- 1 | #==================================================================== 2 | # 3 | # wNim - Nim's Windows GUI Framework 4 | # Copyright (c) Chen Kai-Hung, Ward 5 | # 6 | #==================================================================== 7 | 8 | import private/controls/wHotkeyCtrl 9 | export wHotkeyCtrl 10 | -------------------------------------------------------------------------------- /wNim/wHyperlinkCtrl.nim: -------------------------------------------------------------------------------- 1 | #==================================================================== 2 | # 3 | # wNim - Nim's Windows GUI Framework 4 | # Copyright (c) Chen Kai-Hung, Ward 5 | # 6 | #==================================================================== 7 | 8 | import private/controls/wHyperlinkCtrl 9 | export wHyperlinkCtrl 10 | -------------------------------------------------------------------------------- /wNim/wIcon.nim: -------------------------------------------------------------------------------- 1 | #==================================================================== 2 | # 3 | # wNim - Nim's Windows GUI Framework 4 | # Copyright (c) Chen Kai-Hung, Ward 5 | # 6 | #==================================================================== 7 | 8 | import private/gdiobjects/wIcon 9 | export wIcon 10 | -------------------------------------------------------------------------------- /wNim/wIconImage.nim: -------------------------------------------------------------------------------- 1 | #==================================================================== 2 | # 3 | # wNim - Nim's Windows GUI Framework 4 | # Copyright (c) Chen Kai-Hung, Ward 5 | # 6 | #==================================================================== 7 | 8 | import private/wIconImage 9 | export wIconImage 10 | -------------------------------------------------------------------------------- /wNim/wImage.nim: -------------------------------------------------------------------------------- 1 | #==================================================================== 2 | # 3 | # wNim - Nim's Windows GUI Framework 4 | # Copyright (c) Chen Kai-Hung, Ward 5 | # 6 | #==================================================================== 7 | 8 | import private/wImage 9 | export wImage 10 | -------------------------------------------------------------------------------- /wNim/wImageList.nim: -------------------------------------------------------------------------------- 1 | #==================================================================== 2 | # 3 | # wNim - Nim's Windows GUI Framework 4 | # Copyright (c) Chen Kai-Hung, Ward 5 | # 6 | #==================================================================== 7 | 8 | import private/wImageList 9 | export wImageList 10 | -------------------------------------------------------------------------------- /wNim/wIpCtrl.nim: -------------------------------------------------------------------------------- 1 | #==================================================================== 2 | # 3 | # wNim - Nim's Windows GUI Framework 4 | # Copyright (c) Chen Kai-Hung, Ward 5 | # 6 | #==================================================================== 7 | 8 | import private/controls/wIpCtrl 9 | export wIpCtrl 10 | -------------------------------------------------------------------------------- /wNim/wListBox.nim: -------------------------------------------------------------------------------- 1 | #==================================================================== 2 | # 3 | # wNim - Nim's Windows GUI Framework 4 | # Copyright (c) Chen Kai-Hung, Ward 5 | # 6 | #==================================================================== 7 | 8 | import private/controls/wListBox 9 | export wListBox 10 | -------------------------------------------------------------------------------- /wNim/wListCtrl.nim: -------------------------------------------------------------------------------- 1 | #==================================================================== 2 | # 3 | # wNim - Nim's Windows GUI Framework 4 | # Copyright (c) Chen Kai-Hung, Ward 5 | # 6 | #==================================================================== 7 | 8 | import private/controls/wListCtrl 9 | export wListCtrl 10 | -------------------------------------------------------------------------------- /wNim/wMacros.nim: -------------------------------------------------------------------------------- 1 | #==================================================================== 2 | # 3 | # wNim - Nim's Windows GUI Framework 4 | # Copyright (c) Chen Kai-Hung, Ward 5 | # 6 | #==================================================================== 7 | 8 | import private/wMacros 9 | export wMacros 10 | -------------------------------------------------------------------------------- /wNim/wMemoryDC.nim: -------------------------------------------------------------------------------- 1 | #==================================================================== 2 | # 3 | # wNim - Nim's Windows GUI Framework 4 | # Copyright (c) Chen Kai-Hung, Ward 5 | # 6 | #==================================================================== 7 | 8 | import private/dc/wMemoryDC 9 | export wMemoryDC 10 | -------------------------------------------------------------------------------- /wNim/wMenu.nim: -------------------------------------------------------------------------------- 1 | #==================================================================== 2 | # 3 | # wNim - Nim's Windows GUI Framework 4 | # Copyright (c) Chen Kai-Hung, Ward 5 | # 6 | #==================================================================== 7 | 8 | import private/menu/[wMenuBase, wMenu, wMenuBar, wMenuItem] 9 | export wMenuBase, wMenu, wMenuBar, wMenuItem 10 | -------------------------------------------------------------------------------- /wNim/wMenuBar.nim: -------------------------------------------------------------------------------- 1 | #==================================================================== 2 | # 3 | # wNim - Nim's Windows GUI Framework 4 | # Copyright (c) Chen Kai-Hung, Ward 5 | # 6 | #==================================================================== 7 | 8 | import private/menu/[wMenuBase, wMenu, wMenuBar, wMenuItem] 9 | export wMenuBase, wMenu, wMenuBar, wMenuItem 10 | -------------------------------------------------------------------------------- /wNim/wMenuBarCtrl.nim: -------------------------------------------------------------------------------- 1 | #==================================================================== 2 | # 3 | # wNim - Nim's Windows GUI Framework 4 | # Copyright (c) Chen Kai-Hung, Ward 5 | # 6 | #==================================================================== 7 | 8 | import private/controls/wMenuBarCtrl 9 | export wMenuBarCtrl 10 | -------------------------------------------------------------------------------- /wNim/wMenuItem.nim: -------------------------------------------------------------------------------- 1 | #==================================================================== 2 | # 3 | # wNim - Nim's Windows GUI Framework 4 | # Copyright (c) Chen Kai-Hung, Ward 5 | # 6 | #==================================================================== 7 | 8 | import private/menu/[wMenuBase, wMenu, wMenuBar, wMenuItem] 9 | export wMenuBase, wMenu, wMenuBar, wMenuItem 10 | -------------------------------------------------------------------------------- /wNim/wMessageDialog.nim: -------------------------------------------------------------------------------- 1 | #==================================================================== 2 | # 3 | # wNim - Nim's Windows GUI Framework 4 | # Copyright (c) Chen Kai-Hung, Ward 5 | # 6 | #==================================================================== 7 | 8 | import private/dialogs/wMessageDialog 9 | export wMessageDialog 10 | -------------------------------------------------------------------------------- /wNim/wNoteBook.nim: -------------------------------------------------------------------------------- 1 | #==================================================================== 2 | # 3 | # wNim - Nim's Windows GUI Framework 4 | # Copyright (c) Chen Kai-Hung, Ward 5 | # 6 | #==================================================================== 7 | 8 | import private/controls/wNoteBook 9 | export wNoteBook 10 | -------------------------------------------------------------------------------- /wNim/wPageSetupDialog.nim: -------------------------------------------------------------------------------- 1 | #==================================================================== 2 | # 3 | # wNim - Nim's Windows GUI Framework 4 | # Copyright (c) Chen Kai-Hung, Ward 5 | # 6 | #==================================================================== 7 | 8 | import private/dialogs/wPageSetupDialog 9 | export wPageSetupDialog 10 | -------------------------------------------------------------------------------- /wNim/wPaintDC.nim: -------------------------------------------------------------------------------- 1 | #==================================================================== 2 | # 3 | # wNim - Nim's Windows GUI Framework 4 | # Copyright (c) Chen Kai-Hung, Ward 5 | # 6 | #==================================================================== 7 | 8 | import private/dc/wPaintDC 9 | export wPaintDC 10 | -------------------------------------------------------------------------------- /wNim/wPanel.nim: -------------------------------------------------------------------------------- 1 | #==================================================================== 2 | # 3 | # wNim - Nim's Windows GUI Framework 4 | # Copyright (c) Chen Kai-Hung, Ward 5 | # 6 | #==================================================================== 7 | 8 | import private/wPanel 9 | export wPanel 10 | -------------------------------------------------------------------------------- /wNim/wPasswordEntryDialog.nim: -------------------------------------------------------------------------------- 1 | #==================================================================== 2 | # 3 | # wNim - Nim's Windows GUI Framework 4 | # Copyright (c) Chen Kai-Hung, Ward 5 | # 6 | #==================================================================== 7 | 8 | import private/dialogs/wPasswordEntryDialog 9 | export wPasswordEntryDialog 10 | -------------------------------------------------------------------------------- /wNim/wPen.nim: -------------------------------------------------------------------------------- 1 | #==================================================================== 2 | # 3 | # wNim - Nim's Windows GUI Framework 4 | # Copyright (c) Chen Kai-Hung, Ward 5 | # 6 | #==================================================================== 7 | 8 | import private/gdiobjects/wPen 9 | export wPen 10 | -------------------------------------------------------------------------------- /wNim/wPrintData.nim: -------------------------------------------------------------------------------- 1 | #==================================================================== 2 | # 3 | # wNim - Nim's Windows GUI Framework 4 | # Copyright (c) Chen Kai-Hung, Ward 5 | # 6 | #==================================================================== 7 | 8 | import private/wPrintData 9 | export wPrintData 10 | -------------------------------------------------------------------------------- /wNim/wPrintDialog.nim: -------------------------------------------------------------------------------- 1 | #==================================================================== 2 | # 3 | # wNim - Nim's Windows GUI Framework 4 | # Copyright (c) Chen Kai-Hung, Ward 5 | # 6 | #==================================================================== 7 | 8 | import private/dialogs/wPrintDialog 9 | export wPrintDialog 10 | -------------------------------------------------------------------------------- /wNim/wPrinterDC.nim: -------------------------------------------------------------------------------- 1 | #==================================================================== 2 | # 3 | # wNim - Nim's Windows GUI Framework 4 | # Copyright (c) Chen Kai-Hung, Ward 5 | # 6 | #==================================================================== 7 | 8 | import private/dc/wPrinterDC 9 | export wPrinterDC 10 | -------------------------------------------------------------------------------- /wNim/wRadioButton.nim: -------------------------------------------------------------------------------- 1 | #==================================================================== 2 | # 3 | # wNim - Nim's Windows GUI Framework 4 | # Copyright (c) Chen Kai-Hung, Ward 5 | # 6 | #==================================================================== 7 | 8 | import private/controls/wRadioButton 9 | export wRadioButton 10 | -------------------------------------------------------------------------------- /wNim/wRebar.nim: -------------------------------------------------------------------------------- 1 | #==================================================================== 2 | # 3 | # wNim - Nim's Windows GUI Framework 4 | # Copyright (c) Chen Kai-Hung, Ward 5 | # 6 | #==================================================================== 7 | 8 | import private/controls/wRebar 9 | export wRebar 10 | -------------------------------------------------------------------------------- /wNim/wRegion.nim: -------------------------------------------------------------------------------- 1 | #==================================================================== 2 | # 3 | # wNim - Nim's Windows GUI Framework 4 | # Copyright (c) Chen Kai-Hung, Ward 5 | # 6 | #==================================================================== 7 | 8 | import private/gdiobjects/wRegion 9 | export wRegion 10 | -------------------------------------------------------------------------------- /wNim/wResizable.nim: -------------------------------------------------------------------------------- 1 | #==================================================================== 2 | # 3 | # wNim - Nim's Windows GUI Framework 4 | # Copyright (c) Chen Kai-Hung, Ward 5 | # 6 | #==================================================================== 7 | 8 | import private/wResizable 9 | export wResizable 10 | -------------------------------------------------------------------------------- /wNim/wResizer.nim: -------------------------------------------------------------------------------- 1 | #==================================================================== 2 | # 3 | # wNim - Nim's Windows GUI Framework 4 | # Copyright (c) Chen Kai-Hung, Ward 5 | # 6 | #==================================================================== 7 | 8 | import private/wResizer 9 | export wResizer 10 | -------------------------------------------------------------------------------- /wNim/wScreenDC.nim: -------------------------------------------------------------------------------- 1 | #==================================================================== 2 | # 3 | # wNim - Nim's Windows GUI Framework 4 | # Copyright (c) Chen Kai-Hung, Ward 5 | # 6 | #==================================================================== 7 | 8 | import private/dc/wScreenDC 9 | export wScreenDC 10 | -------------------------------------------------------------------------------- /wNim/wScrollBar.nim: -------------------------------------------------------------------------------- 1 | #==================================================================== 2 | # 3 | # wNim - Nim's Windows GUI Framework 4 | # Copyright (c) Chen Kai-Hung, Ward 5 | # 6 | #==================================================================== 7 | 8 | import private/controls/wScrollBar 9 | export wScrollBar 10 | -------------------------------------------------------------------------------- /wNim/wSlider.nim: -------------------------------------------------------------------------------- 1 | #==================================================================== 2 | # 3 | # wNim - Nim's Windows GUI Framework 4 | # Copyright (c) Chen Kai-Hung, Ward 5 | # 6 | #==================================================================== 7 | 8 | import private/controls/wSlider 9 | export wSlider 10 | -------------------------------------------------------------------------------- /wNim/wSpinButton.nim: -------------------------------------------------------------------------------- 1 | #==================================================================== 2 | # 3 | # wNim - Nim's Windows GUI Framework 4 | # Copyright (c) Chen Kai-Hung, Ward 5 | # 6 | #==================================================================== 7 | 8 | import private/controls/wSpinButton 9 | export wSpinButton 10 | -------------------------------------------------------------------------------- /wNim/wSpinCtrl.nim: -------------------------------------------------------------------------------- 1 | #==================================================================== 2 | # 3 | # wNim - Nim's Windows GUI Framework 4 | # Copyright (c) Chen Kai-Hung, Ward 5 | # 6 | #==================================================================== 7 | 8 | import private/controls/wSpinCtrl 9 | export wSpinCtrl 10 | -------------------------------------------------------------------------------- /wNim/wSplitter.nim: -------------------------------------------------------------------------------- 1 | #==================================================================== 2 | # 3 | # wNim - Nim's Windows GUI Framework 4 | # Copyright (c) Chen Kai-Hung, Ward 5 | # 6 | #==================================================================== 7 | 8 | import private/controls/wSplitter 9 | export wSplitter 10 | -------------------------------------------------------------------------------- /wNim/wStaticBitmap.nim: -------------------------------------------------------------------------------- 1 | #==================================================================== 2 | # 3 | # wNim - Nim's Windows GUI Framework 4 | # Copyright (c) Chen Kai-Hung, Ward 5 | # 6 | #==================================================================== 7 | 8 | import private/controls/wStaticBitmap 9 | export wStaticBitmap 10 | -------------------------------------------------------------------------------- /wNim/wStaticBox.nim: -------------------------------------------------------------------------------- 1 | #==================================================================== 2 | # 3 | # wNim - Nim's Windows GUI Framework 4 | # Copyright (c) Chen Kai-Hung, Ward 5 | # 6 | #==================================================================== 7 | 8 | import private/controls/wStaticBox 9 | export wStaticBox 10 | -------------------------------------------------------------------------------- /wNim/wStaticLine.nim: -------------------------------------------------------------------------------- 1 | #==================================================================== 2 | # 3 | # wNim - Nim's Windows GUI Framework 4 | # Copyright (c) Chen Kai-Hung, Ward 5 | # 6 | #==================================================================== 7 | 8 | import private/controls/wStaticLine 9 | export wStaticLine 10 | -------------------------------------------------------------------------------- /wNim/wStaticText.nim: -------------------------------------------------------------------------------- 1 | #==================================================================== 2 | # 3 | # wNim - Nim's Windows GUI Framework 4 | # Copyright (c) Chen Kai-Hung, Ward 5 | # 6 | #==================================================================== 7 | 8 | import private/controls/wStaticText 9 | export wStaticText 10 | -------------------------------------------------------------------------------- /wNim/wStatusBar.nim: -------------------------------------------------------------------------------- 1 | #==================================================================== 2 | # 3 | # wNim - Nim's Windows GUI Framework 4 | # Copyright (c) Chen Kai-Hung, Ward 5 | # 6 | #==================================================================== 7 | 8 | import private/controls/wStatusBar 9 | export wStatusBar 10 | -------------------------------------------------------------------------------- /wNim/wTextCtrl.nim: -------------------------------------------------------------------------------- 1 | #==================================================================== 2 | # 3 | # wNim - Nim's Windows GUI Framework 4 | # Copyright (c) Chen Kai-Hung, Ward 5 | # 6 | #==================================================================== 7 | 8 | import private/controls/wTextCtrl 9 | export wTextCtrl 10 | -------------------------------------------------------------------------------- /wNim/wTextEntryDialog.nim: -------------------------------------------------------------------------------- 1 | #==================================================================== 2 | # 3 | # wNim - Nim's Windows GUI Framework 4 | # Copyright (c) Chen Kai-Hung, Ward 5 | # 6 | #==================================================================== 7 | 8 | import private/dialogs/wTextEntryDialog 9 | export wTextEntryDialog 10 | -------------------------------------------------------------------------------- /wNim/wTimePickerCtrl.nim: -------------------------------------------------------------------------------- 1 | #==================================================================== 2 | # 3 | # wNim - Nim's Windows GUI Framework 4 | # Copyright (c) Chen Kai-Hung, Ward 5 | # 6 | #==================================================================== 7 | 8 | import private/controls/wTimePickerCtrl 9 | export wTimePickerCtrl 10 | -------------------------------------------------------------------------------- /wNim/wToolBar.nim: -------------------------------------------------------------------------------- 1 | #==================================================================== 2 | # 3 | # wNim - Nim's Windows GUI Framework 4 | # Copyright (c) Chen Kai-Hung, Ward 5 | # 6 | #==================================================================== 7 | 8 | import private/controls/wToolBar 9 | export wToolBar 10 | -------------------------------------------------------------------------------- /wNim/wToolTip.nim: -------------------------------------------------------------------------------- 1 | #==================================================================== 2 | # 3 | # wNim - Nim's Windows GUI Framework 4 | # Copyright (c) Chen Kai-Hung, Ward 5 | # 6 | #==================================================================== 7 | 8 | import private/wToolTip 9 | export wToolTip 10 | -------------------------------------------------------------------------------- /wNim/wTreeCtrl.nim: -------------------------------------------------------------------------------- 1 | #==================================================================== 2 | # 3 | # wNim - Nim's Windows GUI Framework 4 | # Copyright (c) Chen Kai-Hung, Ward 5 | # 6 | #==================================================================== 7 | 8 | import private/controls/wTreeCtrl 9 | export wTreeCtrl 10 | -------------------------------------------------------------------------------- /wNim/wTypes.nim: -------------------------------------------------------------------------------- 1 | #==================================================================== 2 | # 3 | # wNim - Nim's Windows GUI Framework 4 | # Copyright (c) Chen Kai-Hung, Ward 5 | # 6 | #==================================================================== 7 | 8 | import private/wTypes 9 | export wTypes 10 | -------------------------------------------------------------------------------- /wNim/wUtils.nim: -------------------------------------------------------------------------------- 1 | #==================================================================== 2 | # 3 | # wNim - Nim's Windows GUI Framework 4 | # Copyright (c) Chen Kai-Hung, Ward 5 | # 6 | #==================================================================== 7 | 8 | import private/wUtils 9 | export wUtils 10 | -------------------------------------------------------------------------------- /wNim/wWebView.nim: -------------------------------------------------------------------------------- 1 | #==================================================================== 2 | # 3 | # wNim - Nim's Windows GUI Framework 4 | # Copyright (c) Chen Kai-Hung, Ward 5 | # 6 | #==================================================================== 7 | 8 | import private/controls/wWebView 9 | export wWebView 10 | -------------------------------------------------------------------------------- /wNim/wWindow.nim: -------------------------------------------------------------------------------- 1 | #==================================================================== 2 | # 3 | # wNim - Nim's Windows GUI Framework 4 | # Copyright (c) Chen Kai-Hung, Ward 5 | # 6 | #==================================================================== 7 | 8 | import private/wWindow 9 | export wWindow 10 | -------------------------------------------------------------------------------- /wNim/wWindowDC.nim: -------------------------------------------------------------------------------- 1 | #==================================================================== 2 | # 3 | # wNim - Nim's Windows GUI Framework 4 | # Copyright (c) Chen Kai-Hung, Ward 5 | # 6 | #==================================================================== 7 | 8 | import private/dc/wWindowDC 9 | export wWindowDC 10 | --------------------------------------------------------------------------------