Skip to content

Commit

Permalink
Add NewWindowWithPosition function
Browse files Browse the repository at this point in the history
Fixes #89
  • Loading branch information
pwiecz committed Jun 29, 2023
1 parent 877d7fe commit 6ec5abf
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 8 deletions.
14 changes: 10 additions & 4 deletions window.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,18 @@

class GWindow : public EventHandler<Fl_Double_Window> {
public:
GWindow(int w, int h)
: EventHandler<Fl_Double_Window>(w, h) {}
GWindow(int w, int h, const char* title)
: EventHandler<Fl_Double_Window>(w, h, title) {}
GWindow(int x, int y, int w, int h, const char* title)
: EventHandler<Fl_Double_Window>(x, y, w, h, title) {}
};

GWindow *go_fltk_new_Window(int w, int h) {
return new GWindow(w, h);
GWindow *go_fltk_new_Window(int w, int h, const char* title) {
return new GWindow(w, h, title);
}

GWindow *go_fltk_new_Window_with_position(int x, int y, int w, int h, const char* title) {
return new GWindow(x, y, w, h, title);
}

int go_fltk_Window_shown(Fl_Window *w) {
Expand Down
11 changes: 8 additions & 3 deletions window.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,14 @@ type Window struct {
icons []*RgbImage
}

func NewWindow(w, h int) *Window {
func NewWindow(w, h int, title ...string) *Window {
win := &Window{}
initWidget(win, unsafe.Pointer(C.go_fltk_new_Window(C.int(w), C.int(h))))
initWidget(win, unsafe.Pointer(C.go_fltk_new_Window(C.int(w), C.int(h), cStringOpt(title))))
return win
}
func NewWindowWithPosition(x, y, w, h int, title ...string) *Window {
win := &Window{}
initWidget(win, unsafe.Pointer(C.go_fltk_new_Window_with_position(C.int(x), C.int(y), C.int(w), C.int(h), cStringOpt(title))))
return win
}
func (w *Window) IsShown() bool {
Expand Down Expand Up @@ -70,7 +75,7 @@ func (w *Window) SetSizeRange(minW, minH, maxW, maxH, deltaX, deltaY int, aspect
if aspectRatio {
ratio = 1
}
C.go_fltk_Window_size_range((*C.Fl_Window)(w.ptr()), C.int(minW), C.int(minH), C.int(maxW), C.int(maxH), C.int(deltaX), C.int(deltaY), C.int(ratio));
C.go_fltk_Window_size_range((*C.Fl_Window)(w.ptr()), C.int(minW), C.int(minH), C.int(maxW), C.int(maxH), C.int(deltaX), C.int(deltaY), C.int(ratio))
}

type Cursor int
Expand Down
3 changes: 2 additions & 1 deletion window.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ extern "C" {
typedef struct GWindow GWindow;
typedef struct Fl_RGB_Image Fl_RGB_Image;

extern GWindow *go_fltk_new_Window(int w, int h);
extern GWindow *go_fltk_new_Window(int w, int h, const char* title);
extern GWindow *go_fltk_new_Window_with_position(int x, int y, int w, int h, const char* title);

extern int go_fltk_Window_shown(Fl_Window* w);
extern void go_fltk_Window_show(Fl_Window *w);
Expand Down

0 comments on commit 6ec5abf

Please sign in to comment.