Implement resizeable
This commit is contained in:
parent
0da7b3fceb
commit
c683190b20
|
@ -16,6 +16,7 @@ struct uiWindow {
|
||||||
BOOL suppressSizeChanged;
|
BOOL suppressSizeChanged;
|
||||||
int fullscreen;
|
int fullscreen;
|
||||||
int borderless;
|
int borderless;
|
||||||
|
int resizeable;
|
||||||
};
|
};
|
||||||
|
|
||||||
@implementation uiprivNSWindow
|
@implementation uiprivNSWindow
|
||||||
|
@ -357,6 +358,21 @@ void uiWindowSetMargined(uiWindow *w, int margined)
|
||||||
uiprivSingleChildConstraintsSetMargined(&(w->constraints), w->margined);
|
uiprivSingleChildConstraintsSetMargined(&(w->constraints), w->margined);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int uiWindowResizeable(uiWindow *w)
|
||||||
|
{
|
||||||
|
return w->resizeable;
|
||||||
|
}
|
||||||
|
|
||||||
|
void uiWindowSetResizeable(uiWindow *w, int resizeable)
|
||||||
|
{
|
||||||
|
w->resizeable = resizeable;
|
||||||
|
if(resizeable){
|
||||||
|
[w->window setStyleMask:[w->window styleMask] | NSResizableWindowMask];
|
||||||
|
} else {
|
||||||
|
[w->window setStyleMask:[w->window styleMask] & ~NSResizableWindowMask];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static int defaultOnClosing(uiWindow *w, void *data)
|
static int defaultOnClosing(uiWindow *w, void *data)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -311,6 +311,7 @@ int main(void)
|
||||||
tab = uiNewTab();
|
tab = uiNewTab();
|
||||||
uiWindowSetChild(mainwin, uiControl(tab));
|
uiWindowSetChild(mainwin, uiControl(tab));
|
||||||
uiWindowSetMargined(mainwin, 1);
|
uiWindowSetMargined(mainwin, 1);
|
||||||
|
uiWindowSetResizeable(mainwin, 0);
|
||||||
|
|
||||||
uiTabAppend(tab, "Basic Controls", makeBasicControlsPage());
|
uiTabAppend(tab, "Basic Controls", makeBasicControlsPage());
|
||||||
uiTabSetMargined(tab, 0, 1);
|
uiTabSetMargined(tab, 0, 1);
|
||||||
|
|
2
ui.h
2
ui.h
|
@ -130,6 +130,8 @@ _UI_EXTERN void uiWindowSetBorderless(uiWindow *w, int borderless);
|
||||||
_UI_EXTERN void uiWindowSetChild(uiWindow *w, uiControl *child);
|
_UI_EXTERN void uiWindowSetChild(uiWindow *w, uiControl *child);
|
||||||
_UI_EXTERN int uiWindowMargined(uiWindow *w);
|
_UI_EXTERN int uiWindowMargined(uiWindow *w);
|
||||||
_UI_EXTERN void uiWindowSetMargined(uiWindow *w, int margined);
|
_UI_EXTERN void uiWindowSetMargined(uiWindow *w, int margined);
|
||||||
|
_UI_EXTERN int uiWindowResizeable(uiWindow *w);
|
||||||
|
_UI_EXTERN void uiWindowSetResizeable(uiWindow *w, int resizeable);
|
||||||
_UI_EXTERN uiWindow *uiNewWindow(const char *title, int width, int height, int hasMenubar);
|
_UI_EXTERN uiWindow *uiNewWindow(const char *title, int width, int height, int hasMenubar);
|
||||||
|
|
||||||
typedef struct uiButton uiButton;
|
typedef struct uiButton uiButton;
|
||||||
|
|
|
@ -19,6 +19,7 @@ struct uiWindow {
|
||||||
|
|
||||||
uiControl *child;
|
uiControl *child;
|
||||||
int margined;
|
int margined;
|
||||||
|
int resizeable;
|
||||||
|
|
||||||
int (*onClosing)(uiWindow *, void *);
|
int (*onClosing)(uiWindow *, void *);
|
||||||
void *onClosingData;
|
void *onClosingData;
|
||||||
|
@ -229,6 +230,17 @@ void uiWindowSetMargined(uiWindow *w, int margined)
|
||||||
uiprivSetMargined(w->childHolderContainer, w->margined);
|
uiprivSetMargined(w->childHolderContainer, w->margined);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int uiWindowResizeable(uiWindow *w)
|
||||||
|
{
|
||||||
|
return w->resizeable;
|
||||||
|
}
|
||||||
|
|
||||||
|
void uiWindowSetResizeable(uiWindow *w, int resizeable)
|
||||||
|
{
|
||||||
|
w->resizeable = resizeable;
|
||||||
|
gtk_window_set_resizable(w->window, resizeable);
|
||||||
|
}
|
||||||
|
|
||||||
uiWindow *uiNewWindow(const char *title, int width, int height, int hasMenubar)
|
uiWindow *uiNewWindow(const char *title, int width, int height, int hasMenubar)
|
||||||
{
|
{
|
||||||
uiWindow *w;
|
uiWindow *w;
|
||||||
|
|
|
@ -13,6 +13,7 @@ struct uiWindow {
|
||||||
int (*onClosing)(uiWindow *, void *);
|
int (*onClosing)(uiWindow *, void *);
|
||||||
void *onClosingData;
|
void *onClosingData;
|
||||||
int margined;
|
int margined;
|
||||||
|
int resizeable;
|
||||||
BOOL hasMenubar;
|
BOOL hasMenubar;
|
||||||
void (*onContentSizeChanged)(uiWindow *, void *);
|
void (*onContentSizeChanged)(uiWindow *, void *);
|
||||||
void *onContentSizeChangedData;
|
void *onContentSizeChangedData;
|
||||||
|
@ -428,6 +429,21 @@ void uiWindowSetMargined(uiWindow *w, int margined)
|
||||||
windowRelayout(w);
|
windowRelayout(w);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int uiWindowResizeable(uiWindow *w)
|
||||||
|
{
|
||||||
|
return w->resizeable;
|
||||||
|
}
|
||||||
|
|
||||||
|
void uiWindowSetResizeable(uiWindow *w, int resizeable)
|
||||||
|
{
|
||||||
|
w->resizeable = resizeable;
|
||||||
|
if (w->resizeable) {
|
||||||
|
setStyle(w->hwnd, getStyle(w->hwnd) | WS_THICKFRAME);
|
||||||
|
} else {
|
||||||
|
setStyle(w->hwnd, getStyle(w->hwnd) & ~WS_THICKFRAME);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// see http://blogs.msdn.com/b/oldnewthing/archive/2003/09/11/54885.aspx and http://blogs.msdn.com/b/oldnewthing/archive/2003/09/13/54917.aspx
|
// see http://blogs.msdn.com/b/oldnewthing/archive/2003/09/11/54885.aspx and http://blogs.msdn.com/b/oldnewthing/archive/2003/09/13/54917.aspx
|
||||||
// TODO use clientSizeToWindowSize()
|
// TODO use clientSizeToWindowSize()
|
||||||
static void setClientSize(uiWindow *w, int width, int height, BOOL hasMenubar, DWORD style, DWORD exstyle)
|
static void setClientSize(uiWindow *w, int width, int height, BOOL hasMenubar, DWORD style, DWORD exstyle)
|
||||||
|
|
Loading…
Reference in New Issue