From b2b3ccc524ad5024fac46a40cd3639ebe7cc0de4 Mon Sep 17 00:00:00 2001 From: Robert Roebling Date: Fri, 4 Dec 1998 07:43:56 +0000 Subject: [PATCH] Added wxMiniFrame git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1106 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/gtk/frame.h | 3 +- include/wx/gtk/minifram.h | 69 ++++++++++++ include/wx/gtk/notebook.h | 2 +- include/wx/gtk1/frame.h | 3 +- include/wx/gtk1/minifram.h | 69 ++++++++++++ include/wx/gtk1/notebook.h | 2 +- samples/minifram/Makefile | 1 + samples/minifram/Makefile.in | 26 +++++ samples/minifram/bitmaps/copy.bmp | Bin 0 -> 238 bytes samples/minifram/bitmaps/copy.xpm | 25 +++++ samples/minifram/bitmaps/cut.bmp | Bin 0 -> 238 bytes samples/minifram/bitmaps/cut.xpm | 24 +++++ samples/minifram/bitmaps/help.bmp | Bin 0 -> 238 bytes samples/minifram/bitmaps/help.xpm | 25 +++++ samples/minifram/bitmaps/new.bmp | Bin 0 -> 238 bytes samples/minifram/bitmaps/new.xpm | 24 +++++ samples/minifram/bitmaps/open.bmp | Bin 0 -> 238 bytes samples/minifram/bitmaps/open.xpm | 26 +++++ samples/minifram/bitmaps/page.bmp | Bin 0 -> 714 bytes samples/minifram/bitmaps/paste.bmp | Bin 0 -> 238 bytes samples/minifram/bitmaps/preview.bmp | Bin 0 -> 238 bytes samples/minifram/bitmaps/preview.xpm | 26 +++++ samples/minifram/bitmaps/print.bmp | Bin 0 -> 238 bytes samples/minifram/bitmaps/print.xpm | 26 +++++ samples/minifram/bitmaps/save.bmp | Bin 0 -> 238 bytes samples/minifram/bitmaps/save.xpm | 25 +++++ samples/minifram/makefile.b32 | 63 +++++++++++ samples/minifram/makefile.dos | 87 +++++++++++++++ samples/minifram/makefile.g95 | 40 +++++++ samples/minifram/makefile.nt | 62 +++++++++++ samples/minifram/makefile.unx | 18 ++++ samples/minifram/mondrian.ico | Bin 0 -> 766 bytes samples/minifram/mondrian.xpm | 44 ++++++++ samples/minifram/test.cpp | 147 +++++++++++++++++++++++++ samples/minifram/test.def | 8 ++ samples/minifram/test.h | 35 ++++++ samples/minifram/test.rc | 13 +++ src/gtk.inc | 1 + src/gtk/frame.cpp | 74 +++++++++---- src/gtk/minifram.cpp | 153 +++++++++++++++++++++++++++ src/gtk1/frame.cpp | 74 +++++++++---- src/gtk1/minifram.cpp | 153 +++++++++++++++++++++++++++ 42 files changed, 1298 insertions(+), 50 deletions(-) create mode 100644 include/wx/gtk/minifram.h create mode 100644 include/wx/gtk1/minifram.h create mode 100644 samples/minifram/Makefile create mode 100644 samples/minifram/Makefile.in create mode 100644 samples/minifram/bitmaps/copy.bmp create mode 100644 samples/minifram/bitmaps/copy.xpm create mode 100644 samples/minifram/bitmaps/cut.bmp create mode 100644 samples/minifram/bitmaps/cut.xpm create mode 100644 samples/minifram/bitmaps/help.bmp create mode 100644 samples/minifram/bitmaps/help.xpm create mode 100644 samples/minifram/bitmaps/new.bmp create mode 100644 samples/minifram/bitmaps/new.xpm create mode 100644 samples/minifram/bitmaps/open.bmp create mode 100644 samples/minifram/bitmaps/open.xpm create mode 100644 samples/minifram/bitmaps/page.bmp create mode 100644 samples/minifram/bitmaps/paste.bmp create mode 100644 samples/minifram/bitmaps/preview.bmp create mode 100644 samples/minifram/bitmaps/preview.xpm create mode 100644 samples/minifram/bitmaps/print.bmp create mode 100644 samples/minifram/bitmaps/print.xpm create mode 100644 samples/minifram/bitmaps/save.bmp create mode 100644 samples/minifram/bitmaps/save.xpm create mode 100644 samples/minifram/makefile.b32 create mode 100644 samples/minifram/makefile.dos create mode 100644 samples/minifram/makefile.g95 create mode 100644 samples/minifram/makefile.nt create mode 100644 samples/minifram/makefile.unx create mode 100644 samples/minifram/mondrian.ico create mode 100644 samples/minifram/mondrian.xpm create mode 100644 samples/minifram/test.cpp create mode 100644 samples/minifram/test.def create mode 100644 samples/minifram/test.h create mode 100644 samples/minifram/test.rc create mode 100644 src/gtk/minifram.cpp create mode 100644 src/gtk1/minifram.cpp diff --git a/include/wx/gtk/frame.h b/include/wx/gtk/frame.h index c87f59f47c..3c235d2171 100644 --- a/include/wx/gtk/frame.h +++ b/include/wx/gtk/frame.h @@ -99,7 +99,7 @@ public: void OnActivate( wxActivateEvent &WXUNUSED(event) ) { } // called from docview.cpp void OnSize( wxSizeEvent &event ); void OnCloseWindow( wxCloseEvent& event ); - void OnIdle(wxIdleEvent& event); + void OnIdle(wxIdleEvent& event ); // implementation @@ -113,6 +113,7 @@ public: wxToolBar *m_frameToolBar; wxString m_title; wxIcon m_icon; + int m_miniEdge,m_miniTitle; DECLARE_EVENT_TABLE() }; diff --git a/include/wx/gtk/minifram.h b/include/wx/gtk/minifram.h new file mode 100644 index 0000000000..9f1ebaa345 --- /dev/null +++ b/include/wx/gtk/minifram.h @@ -0,0 +1,69 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: minifram.h +// Purpose: wxMiniFrame class +// Author: Robert Roebling +// RCS-ID: $Id$ +// Copyright: (c) Robert Roebling +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifndef __GTKMINIFRAMEH__ +#define __GTKMINIFRAMEH__ + +#ifdef __GNUG__ +#pragma interface +#endif + +#include "wx/defs.h" +#include "wx/object.h" +#include "wx/frame.h" + +//----------------------------------------------------------------------------- +// classes +//----------------------------------------------------------------------------- + +class wxMiniFrame; + +//----------------------------------------------------------------------------- +// wxMiniFrame +//----------------------------------------------------------------------------- + +class wxMiniFrame: public wxFrame +{ + DECLARE_DYNAMIC_CLASS(wxMiniFrame) + +public: + inline wxMiniFrame(void) {} + inline wxMiniFrame(wxWindow *parent, + wxWindowID id, + const wxString& title, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + long style = wxDEFAULT_FRAME|wxTINY_CAPTION_HORIZ, + const wxString& name = wxFrameNameStr) + { + Create(parent, id, title, pos, size, style, name); + } + bool Create(wxWindow *parent, + wxWindowID id, + const wxString& title, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + long style = wxDEFAULT_FRAME|wxTINY_CAPTION_HORIZ, + const wxString& name = wxFrameNameStr); + + // implementation + + bool m_isDragging; + int m_oldX,m_oldY; + int m_diffX,m_diffY; + + void DrawFrame( int x, int y ); + void OnPaint( wxPaintEvent &event ); + void OnMouse( wxMouseEvent &event ); + + DECLARE_EVENT_TABLE() +}; + +#endif + // __GTKMINIFRAMEH__ diff --git a/include/wx/gtk/notebook.h b/include/wx/gtk/notebook.h index 8cfa171f7e..d61603dd8f 100644 --- a/include/wx/gtk/notebook.h +++ b/include/wx/gtk/notebook.h @@ -4,7 +4,7 @@ // Author: Robert Roebling // Modified by: // RCS-ID: $Id$ -// Copyright: (c) Julian Smart and Markus Holzem +// Copyright: (c) Julian Smart and Robert Roebling // Licence: wxWindows license ///////////////////////////////////////////////////////////////////////////// diff --git a/include/wx/gtk1/frame.h b/include/wx/gtk1/frame.h index c87f59f47c..3c235d2171 100644 --- a/include/wx/gtk1/frame.h +++ b/include/wx/gtk1/frame.h @@ -99,7 +99,7 @@ public: void OnActivate( wxActivateEvent &WXUNUSED(event) ) { } // called from docview.cpp void OnSize( wxSizeEvent &event ); void OnCloseWindow( wxCloseEvent& event ); - void OnIdle(wxIdleEvent& event); + void OnIdle(wxIdleEvent& event ); // implementation @@ -113,6 +113,7 @@ public: wxToolBar *m_frameToolBar; wxString m_title; wxIcon m_icon; + int m_miniEdge,m_miniTitle; DECLARE_EVENT_TABLE() }; diff --git a/include/wx/gtk1/minifram.h b/include/wx/gtk1/minifram.h new file mode 100644 index 0000000000..9f1ebaa345 --- /dev/null +++ b/include/wx/gtk1/minifram.h @@ -0,0 +1,69 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: minifram.h +// Purpose: wxMiniFrame class +// Author: Robert Roebling +// RCS-ID: $Id$ +// Copyright: (c) Robert Roebling +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifndef __GTKMINIFRAMEH__ +#define __GTKMINIFRAMEH__ + +#ifdef __GNUG__ +#pragma interface +#endif + +#include "wx/defs.h" +#include "wx/object.h" +#include "wx/frame.h" + +//----------------------------------------------------------------------------- +// classes +//----------------------------------------------------------------------------- + +class wxMiniFrame; + +//----------------------------------------------------------------------------- +// wxMiniFrame +//----------------------------------------------------------------------------- + +class wxMiniFrame: public wxFrame +{ + DECLARE_DYNAMIC_CLASS(wxMiniFrame) + +public: + inline wxMiniFrame(void) {} + inline wxMiniFrame(wxWindow *parent, + wxWindowID id, + const wxString& title, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + long style = wxDEFAULT_FRAME|wxTINY_CAPTION_HORIZ, + const wxString& name = wxFrameNameStr) + { + Create(parent, id, title, pos, size, style, name); + } + bool Create(wxWindow *parent, + wxWindowID id, + const wxString& title, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + long style = wxDEFAULT_FRAME|wxTINY_CAPTION_HORIZ, + const wxString& name = wxFrameNameStr); + + // implementation + + bool m_isDragging; + int m_oldX,m_oldY; + int m_diffX,m_diffY; + + void DrawFrame( int x, int y ); + void OnPaint( wxPaintEvent &event ); + void OnMouse( wxMouseEvent &event ); + + DECLARE_EVENT_TABLE() +}; + +#endif + // __GTKMINIFRAMEH__ diff --git a/include/wx/gtk1/notebook.h b/include/wx/gtk1/notebook.h index 8cfa171f7e..d61603dd8f 100644 --- a/include/wx/gtk1/notebook.h +++ b/include/wx/gtk1/notebook.h @@ -4,7 +4,7 @@ // Author: Robert Roebling // Modified by: // RCS-ID: $Id$ -// Copyright: (c) Julian Smart and Markus Holzem +// Copyright: (c) Julian Smart and Robert Roebling // Licence: wxWindows license ///////////////////////////////////////////////////////////////////////////// diff --git a/samples/minifram/Makefile b/samples/minifram/Makefile new file mode 100644 index 0000000000..bccce53f76 --- /dev/null +++ b/samples/minifram/Makefile @@ -0,0 +1 @@ +include ../../setup/general/makeapp diff --git a/samples/minifram/Makefile.in b/samples/minifram/Makefile.in new file mode 100644 index 0000000000..9e9b1b68eb --- /dev/null +++ b/samples/minifram/Makefile.in @@ -0,0 +1,26 @@ +# WXXT base directory +WXBASEDIR=@WXBASEDIR@ + +# set the OS type for compilation +OS=@OS@ +# compile a library only +RULE=bin + +# define library name +BIN_TARGET=toolbar +# define library sources +BIN_SRC=\ +test.cpp + +#define library objects +BIN_OBJ=\ +test.o + +# additional things needed to link +BIN_LINK= + +# additional things needed to compile +ADD_COMPILE= + +# include the definitions now +include ../../../template.mak diff --git a/samples/minifram/bitmaps/copy.bmp b/samples/minifram/bitmaps/copy.bmp new file mode 100644 index 0000000000000000000000000000000000000000..4551a06bfa79e0a42c1ffb7cdbb90fd4f699dce2 GIT binary patch literal 238 zcmZvVK?*`K3`9pLxU9$U91{2|@hV+>tjiv)Cz3AyzP{vxy7<$~OeTT!c7JQf6T89- z%?kmn<${;(P#uFN<0A#FuUo(qgT{&F@ekspii W=d@ZzPG(Cb=QBs}_=7thzxV(viB<;y literal 0 HcmV?d00001 diff --git a/samples/minifram/bitmaps/copy.xpm b/samples/minifram/bitmaps/copy.xpm new file mode 100644 index 0000000000..47565c1cae --- /dev/null +++ b/samples/minifram/bitmaps/copy.xpm @@ -0,0 +1,25 @@ +/* XPM */ +static char *copy_xpm[] = { +/* columns rows colors chars-per-pixel */ +"16 15 4 1", +" c None", +". c Black", +"X c Gray100", +"o c #000080", +/* pixels */ +" ", +" ...... ", +" .XXXX.. ", +" .XXXX.X. ", +" .X..X.oooooo ", +" .XXXXXoXXXXoo ", +" .X....oXXXXoXo ", +" .XXXXXoX..Xoooo", +" .X....oXXXXXXXo", +" .XXXXXoX.....Xo", +" ......oXXXXXXXo", +" oX.....Xo", +" oXXXXXXXo", +" ooooooooo", +" " +}; diff --git a/samples/minifram/bitmaps/cut.bmp b/samples/minifram/bitmaps/cut.bmp new file mode 100644 index 0000000000000000000000000000000000000000..15554338a01bc4d8f0a501c32237e84200e64583 GIT binary patch literal 238 zcmZvU!3}^Q5Cqr6gr}Ba8OD(CvKJo2^+{<|WDB@(K8*2TclNjo+kV075Ef~cCTYMZ z2hQ$)mH}PlY>+FWlp?l4?H9GSBqTFi~p=nI%+}YJ={H-mN0|?29BK#fUL#erbtT(lh^R?4vYy(d-6AGn1|j$rr}v KbDqI%Xjd+{i$y;G literal 0 HcmV?d00001 diff --git a/samples/minifram/bitmaps/help.xpm b/samples/minifram/bitmaps/help.xpm new file mode 100644 index 0000000000..50fdb4157e --- /dev/null +++ b/samples/minifram/bitmaps/help.xpm @@ -0,0 +1,25 @@ +/* XPM */ +static char *help_xpm[] = { +/* columns rows colors chars-per-pixel */ +"16 15 4 1", +" c None", +". c Black", +"X c Blue", +"o c #000080", +/* pixels */ +" ", +" ...... ", +" .XXXXX.. ", +" .XX...oX.. ", +" .X.. .X.. ", +" .X.. .XX.. ", +" .. .XX.. ", +" .XX.. ", +" .X.. ", +" .X.. ", +" .o.. ", +" .. ", +" .XX.. ", +" .XX.. ", +" ... " +}; diff --git a/samples/minifram/bitmaps/new.bmp b/samples/minifram/bitmaps/new.bmp new file mode 100644 index 0000000000000000000000000000000000000000..d66feb2384ad4c626a078c995c1a3e49af78ec3c GIT binary patch literal 238 zcmbu2yA6Oa5JQcGL>b0l4tjP;1(ew=nJ8j|<6WY3bU0`GK9aK^RUId`!4(ELX-1{H u>6c`QQqJ8_T9s0iQsQ8(Wab^@`3kuPA_p->w)Xt4Pkz>06 literal 0 HcmV?d00001 diff --git a/samples/minifram/bitmaps/new.xpm b/samples/minifram/bitmaps/new.xpm new file mode 100644 index 0000000000..754d2d20a2 --- /dev/null +++ b/samples/minifram/bitmaps/new.xpm @@ -0,0 +1,24 @@ +/* XPM */ +static char *new_xpm[] = { +/* columns rows colors chars-per-pixel */ +"16 15 3 1", +" c None", +". c Black", +"X c Gray100", +/* pixels */ +" ", +" ........ ", +" .XXXXXX.. ", +" .XXXXXX.X. ", +" .XXXXXX.... ", +" .XXXXXXXXX. ", +" .XXXXXXXXX. ", +" .XXXXXXXXX. ", +" .XXXXXXXXX. ", +" .XXXXXXXXX. ", +" .XXXXXXXXX. ", +" .XXXXXXXXX. ", +" .XXXXXXXXX. ", +" ........... ", +" " +}; diff --git a/samples/minifram/bitmaps/open.bmp b/samples/minifram/bitmaps/open.bmp new file mode 100644 index 0000000000000000000000000000000000000000..bbf93fe03364e63f3e18a3507a0e85ab8ea2f87d GIT binary patch literal 238 zcmXv{u@M3>3=;=;U&0ua+_3>YyQsonW~6N3OvKTr2(k@|B{{YeKb~(CUb3rr5zpcQ zCn>O}mP9XDa6kd~GO1FGG0<95V`X5i$V8neN$dxz4&8XX3!AZr-;ApY^eS-9oTLj~ Y^Hcc9z2|$wrXTtLH=Rc2n(WoWFRhqJ00000 literal 0 HcmV?d00001 diff --git a/samples/minifram/bitmaps/open.xpm b/samples/minifram/bitmaps/open.xpm new file mode 100644 index 0000000000..54748e910d --- /dev/null +++ b/samples/minifram/bitmaps/open.xpm @@ -0,0 +1,26 @@ +/* XPM */ +static char *open_xpm[] = { +/* columns rows colors chars-per-pixel */ +"16 15 5 1", +" c None", +". c Black", +"X c Yellow", +"o c Gray100", +"O c #bfbf00", +/* pixels */ +" ", +" ... ", +" . . .", +" ..", +" ... ...", +" .XoX....... ", +" .oXoXoXoXo. ", +" .XoXoXoXoX. ", +" .oXoX..........", +" .XoX.OOOOOOOOO.", +" .oo.OOOOOOOOO. ", +" .X.OOOOOOOOO. ", +" ..OOOOOOOOO. ", +" ........... ", +" " +}; diff --git a/samples/minifram/bitmaps/page.bmp b/samples/minifram/bitmaps/page.bmp new file mode 100644 index 0000000000000000000000000000000000000000..3dbd4b05b4c2d1a4f046141d450caf34c1a3d470 GIT binary patch literal 714 zcmaJk)fu{chJ-2TT-iZmtVS?uc5roS;-EuD8k*^vaH9hj_d6X ziQgC358^U$kRpEdIqzx8X~Jz0i&xCtBKWwA%eHOw^mwIrw+KG&;&N&1L*Q{1Xmx8p zxBo0O*pac2@{B`!>-fgLdSDP(C2}M>_DcBv60g*0UKyHhy!Oc8UYD-XBeIyOWTry_ zTA4Yuua#Ixm?vFMcI3@F*>XSp02Lyo AJ^%m! literal 0 HcmV?d00001 diff --git a/samples/minifram/bitmaps/paste.bmp b/samples/minifram/bitmaps/paste.bmp new file mode 100644 index 0000000000000000000000000000000000000000..564f514e0df7225f0a7adbe8457b41af537813bd GIT binary patch literal 238 zcmZvVF%Ci@5Jbns$83OZ*I;# co}I%%@f6>ra3+S=gC69}eM%GII+SAI4J;x>B>(^b literal 0 HcmV?d00001 diff --git a/samples/minifram/bitmaps/preview.bmp b/samples/minifram/bitmaps/preview.bmp new file mode 100644 index 0000000000000000000000000000000000000000..da1f4dbc4be6c2dd8fb9d7cb71cc48a4a7c139ca GIT binary patch literal 238 zcmZvVu?@p83pv2yNo4mlT?N_pr2ISnd1NHDM5O^cFcMc59&^> z)PfrwsOeYM05)2ipmU4fJIss+o(=cdQCu+!%TlZiKDH!a!aP2;C|UGpLD9M;zmsLJ XIp;lzIUm!ckI6HO{IjaYcZ_-fA4^nl literal 0 HcmV?d00001 diff --git a/samples/minifram/bitmaps/preview.xpm b/samples/minifram/bitmaps/preview.xpm new file mode 100644 index 0000000000..0dfdca46e1 --- /dev/null +++ b/samples/minifram/bitmaps/preview.xpm @@ -0,0 +1,26 @@ +/* XPM */ +static char *preview_xpm[] = { +/* columns rows colors chars-per-pixel */ +"16 15 5 1", +" c Black", +". c None", +"X c Gray100", +"o c #808080", +"O c Cyan", +/* pixels */ +" .......", +" XXXXXXX ......", +" XXXXXXX . .....", +" XXXXXXX ....", +" XXXXXXXXXX ....", +" XXXXXXX ....", +" XXXXXX o..o ...", +" XXXXX oOO.oo ..", +" XXXXX .O..o. ..", +" XXXXX ....o. ..", +" XXXXX o..Ooo ..", +" XXXXXX o..o o..", +" XXXXXXX o .", +" XXXXXXXXXX . ", +" .. " +}; diff --git a/samples/minifram/bitmaps/print.bmp b/samples/minifram/bitmaps/print.bmp new file mode 100644 index 0000000000000000000000000000000000000000..00319b55bb23c3c69cc051144d80e5275747c53e GIT binary patch literal 238 zcmZur!3_d23^Ni^o@EUFY`~vgA|YX<`*bfpod|VizM>j+f}Fx~Q7! zgtHKM7yg3|DAD^Sp<0YF#C}+nSj(MC$5#Ss27*aN<{l9dYV3`7rsq)3!X>4ws(){6V0MX5FKAjcylGXqN-n#XsS=YhW0WogZT{L^_i_GT%*k@+ph E1NJ~MtpET3 literal 0 HcmV?d00001 diff --git a/samples/minifram/bitmaps/save.xpm b/samples/minifram/bitmaps/save.xpm new file mode 100644 index 0000000000..01b18f9340 --- /dev/null +++ b/samples/minifram/bitmaps/save.xpm @@ -0,0 +1,25 @@ +/* XPM */ +static char *save_xpm[] = { +/* columns rows colors chars-per-pixel */ +"16 15 4 1", +" c None", +". c Black", +"X c #808000", +"o c #808080", +/* pixels */ +" ", +" .............. ", +" .X. . . ", +" .X. ... ", +" .X. .X. ", +" .X. .X. ", +" .X. .X. ", +" .X. .X. ", +" .XX........oX. ", +" .XXXXXXXXXXXX. ", +" .XX.........X. ", +" .XX...... .X. ", +" .XX...... .X. ", +" .XX...... .X. ", +" ............. " +}; diff --git a/samples/minifram/makefile.b32 b/samples/minifram/makefile.b32 new file mode 100644 index 0000000000..9f32c974ba --- /dev/null +++ b/samples/minifram/makefile.b32 @@ -0,0 +1,63 @@ +# +# File: makefile.b32 +# Author: Patrick Halke +# Created: 1995 +# Updated: +# Copyright: (c) 1993, AIAI, University of Edinburgh +# +# "%W% %G%" +# +# Makefile : Builds 32bit buttonbar example. + +# WXWIN and BCCDIR are set by parent make + +WXDIR = $(WXWIN) +!include $(WXDIR)\src\makeb32.env + +WXLIBDIR = $(WXDIR)\lib +WXLIB = $(WXLIBDIR)\wx32.lib +LIBS=$(WXLIB) cw32 import32 + +TARGET=test + +!if "$(FINAL)" == "0" +LINKFLAGS=/v /Tpe /L$(WXLIBDIR);$(BCCDIR)\lib +OPT = -Od +DEBUG_FLAGS= -v +!else +LINKFLAGS=/Tpe /L$(WXLIBDIR);$(BCCDIR)\lib +OPT = -Od +DEBUG_FLAGS = +!endif +CPPFLAGS=$(DEBUG_FLAGS) $(OPT) @$(CFG) + +OBJECTS = test.obj + +$(TARGET).exe: $(OBJECTS) $(TARGET).def $(TARGET).res + tlink32 $(LINKFLAGS) @&&! +c0w32.obj $(OBJECTS) +$(TARGET) +nul +$(LIBS) +$(TARGET).def +$(TARGET).res +! + +.$(SRCSUFF).obj: + bcc32 $(CPPFLAGS) -c {$< } + +.c.obj: + bcc32 $(CPPFLAGS) -P- -c {$< } + +test.obj: test.$(SRCSUFF) test.h + +$(TARGET).res : $(TARGET).rc $(WXDIR)\include\wx\msw\wx.rc + brc32 -r /i$(BCCDIR)\include /i$(WXDIR)\include $(TARGET) + +clean: + -erase *.obj + -erase *.exe + -erase *.res + -erase *.map + -erase *.rws + diff --git a/samples/minifram/makefile.dos b/samples/minifram/makefile.dos new file mode 100644 index 0000000000..98f93ab7bb --- /dev/null +++ b/samples/minifram/makefile.dos @@ -0,0 +1,87 @@ +# +# File: makefile.dos +# Author: Julian Smart +# Created: 1993 +# Updated: +# Copyright: (c) 1993, AIAI, University of Edinburgh +# +# "%W% %G%" +# +# Makefile : Builds wxToolbar sample +# Use FINAL=1 argument to nmake to build final version with no debugging +# info + +# Set WXDIR for your system +WXDIR = $(WXWIN) + +!include $(WXDIR)\src\makemsc.env + +BBARDIR = $(WXDIR)\samples\toolbar + +INC = /I$(WXDIR)\include\base /I$(WXDIR)\include\msw + +THISDIR = $(BBARDIR) + +!ifndef FINAL +FINAL=0 +!endif + +# Default is to output RTF for WinHelp +!ifndef WINHELP +WINHELP=-winhelp +!endif + +# Set this to nothing if using MS C++ 7 +ZOPTION=/Z7 + +!if "$(FINAL)" == "0" +CPPFLAGS=/AL /Gt8 /W3 /Zi $(ZOPTION) /G2sw /Od /YuWX_PREC.H $(INC) /Dwx_msw /Fp$(WXDIR)\src\msw\wx.pch +CFLAGS=/AL /Gt8 /W3 /Zi $(ZOPTION) /G2sw /Od $(INC) /Dwx_msw +LINKFLAGS=/NOD /CO /SEG:512 /ONERROR:NOEXE +!else +CPPFLAGS=/AL /Gt8 /W3 /G2sw /Os /YuWX_PREC.H $(INC) /Dwx_msw /Fp$(WXDIR)\src\msw\wx.pch +CFLAGS=/AL /Gt8 /W3 /Zi $(ZOPTION) /G2sw /Od $(INC) /Dwx_msw +LINKFLAGS=/NOD /SEG:512 /ONERROR:NOEXE +!endif + +OBJECTS = test.obj + +all: test.exe + +wx: + cd $(WXDIR)\src\msw + nmake -f makefile.dos FINAL=$(FINAL) + cd $(THISDIR) + +wxclean: + cd $(WXDIR)\src\msw + nmake -f makefile.dos clean + cd $(THISDIR) + +test.exe: $(WXDIR)\src\msw\dummy.obj $(WXLIB) test.obj test.def test.res + link $(LINKFLAGS) @<< +$(WXDIR)\src\msw\dummy.obj test.obj, +test, +NUL, +$(LIBS), +test.def +; +<< + rc -30 -K test.res + +test.obj: test.h test.$(SRCSUFF) + cl @<< +$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) +<< + +test.res : test.rc $(WXDIR)\include\msw\wx.rc + rc -r /dFAFA_LIB /i$(WXDIR)\contrib\fafa /i$(WXDIR)\include\msw test + +clean: + -erase *.obj + -erase *.exe + -erase *.res + -erase *.map + -erase *.sbr + -erase *.pdb + diff --git a/samples/minifram/makefile.g95 b/samples/minifram/makefile.g95 new file mode 100644 index 0000000000..a16ac0faec --- /dev/null +++ b/samples/minifram/makefile.g95 @@ -0,0 +1,40 @@ +# +# File: makefile.unx +# Author: Julian Smart +# Created: 1993 +# Updated: +# Copyright: (c) 1993, AIAI, University of Edinburgh +# +# "%W% %G%" +# +# Makefile for Buttonbar example (UNIX). +# Change the WXDIR directory, and CPPFLAGS and LDFLAGS, for your system. + +WXDIR = ../.. + +# All common UNIX compiler flags and options are now in +# this central makefile. +include $(WXDIR)/src/makeg95.env + +TESTOBJECTS = $(OBJDIR)/test.$(OBJSUFF) $(OBJDIR)/test_resources.$(OBJSUFF) +TESTPROGRAM = test$(GUISUFFIX) + +all: $(OBJDIR) $(TESTPROGRAM) + +demo: $(TESTPROGRAM) + +$(OBJDIR): + mkdir $(OBJDIR) + +$(OBJDIR)/test.$(OBJSUFF): test.h test.$(SRCSUFF) + $(CC) -c $(CPPFLAGS) -o $@ test.$(SRCSUFF) + +$(TESTPROGRAM): $(TESTOBJECTS) $(WXLIB) + $(CC) $(LDFLAGS) -o test$(GUISUFFIX)$(EXESUFF) $(TESTOBJECTS) $(LDLIBS) + +$(OBJDIR)/test_resources.o: test.rc + $(RESCOMP) -i test.rc -o $(OBJDIR)/test_resources.o $(RESFLAGS) + +clean: + rm -f $(OBJECTS) test$(GUISUFFIX).exe $(TESTOBJECTS) core *.res *.rsc + diff --git a/samples/minifram/makefile.nt b/samples/minifram/makefile.nt new file mode 100644 index 0000000000..64f2260de2 --- /dev/null +++ b/samples/minifram/makefile.nt @@ -0,0 +1,62 @@ +# +# File: makefile.nt +# Author: Julian Smart +# Created: 1993 +# Updated: +# Copyright: (c) 1993, AIAI, University of Edinburgh +# +# "%W% %G%" +# +# Makefile : Builds buttnbar example (MS VC++). +# Use FINAL=1 argument to nmake to build final version with no debugging +# info + +# Set WXDIR for your system +WXDIR = $(WXWIN) + +!include $(WXDIR)\src\ntwxwin.mak + +THISDIR = $(WXDIR)\samples\toolbar +PROGRAM=test + +OBJECTS = $(PROGRAM).obj + +$(PROGRAM): $(PROGRAM).exe + +all: wx $(PROGRAM).exe + +wx: + cd $(WXDIR)\src\msw + nmake -f makefile.nt FINAL=$(FINAL) + cd $(THISDIR) + +wxclean: + cd $(WXDIR)\src\msw + nmake -f makefile.nt clean + cd $(THISDIR) + +$(PROGRAM).exe: $(DUMMYOBJ) $(WXLIB) $(OBJECTS) $(PROGRAM).res + $(link) @<< +-out:$(PROGRAM).exe +$(LINKFLAGS) +$(DUMMYOBJ) $(OBJECTS) $(PROGRAM).res +$(LIBS) +<< + + +$(PROGRAM).obj: $(PROGRAM).h $(PROGRAM).$(SRCSUFF) $(DUMMYOBJ) + $(cc) @<< +$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) +<< + +$(PROGRAM).res : $(PROGRAM).rc $(WXDIR)\include\wx\msw\wx.rc + $(rc) -r /i$(WXDIR)\include -fo$@ $(PROGRAM).rc + + +clean: + -erase *.obj + -erase *.sbr + -erase *.exe + -erase *.res + -erase *.map + -erase *.pdb diff --git a/samples/minifram/makefile.unx b/samples/minifram/makefile.unx new file mode 100644 index 0000000000..0b249d4c88 --- /dev/null +++ b/samples/minifram/makefile.unx @@ -0,0 +1,18 @@ +# +# File: makefile.unx +# Author: Julian Smart +# Created: 1998 +# Updated: +# Copyright: (c) 1998 Julian Smart +# +# "%W% %G%" +# +# Makefile for toolbar example (UNIX). + +PROGRAM=test + +OBJECTS=$(PROGRAM).o + +include ../../src/makeprog.env + + diff --git a/samples/minifram/mondrian.ico b/samples/minifram/mondrian.ico new file mode 100644 index 0000000000000000000000000000000000000000..2310c5d275a87af295d5ea8dc79ea417a5e74c53 GIT binary patch literal 766 zcmZQzU<5)11px*Sc)`TLAO@s0fLH;D9e|jTfdxnc0ZSetIcon(wxIcon("mondrian")); +#else + frame->SetIcon( wxIcon(mondrian_xpm) ); +#endif + + // Create the toolbar + frame->CreateToolBar(wxNO_BORDER|wxHORIZONTAL|wxTB_FLAT, ID_TOOLBAR); + + InitToolbar(frame->GetToolBar()); + + frame->Show(TRUE); + SetTopWindow(frame); + + return TRUE; +} + +bool MyApp::InitToolbar(wxToolBar* toolBar) +{ + toolBar->SetMargins(5, 5); + + // Set up toolbar + wxBitmap* toolBarBitmaps[8]; + +#ifdef __WXMSW__ + toolBarBitmaps[0] = new wxBitmap("icon1"); + toolBarBitmaps[1] = new wxBitmap("icon2"); + toolBarBitmaps[2] = new wxBitmap("icon3"); + toolBarBitmaps[3] = new wxBitmap("icon4"); + toolBarBitmaps[4] = new wxBitmap("icon5"); + toolBarBitmaps[5] = new wxBitmap("icon6"); + toolBarBitmaps[6] = new wxBitmap("icon7"); + toolBarBitmaps[7] = new wxBitmap("icon8"); +#else + toolBarBitmaps[0] = new wxBitmap( new_xpm ); + toolBarBitmaps[1] = new wxBitmap( open_xpm ); + toolBarBitmaps[2] = new wxBitmap( save_xpm ); + toolBarBitmaps[3] = new wxBitmap( copy_xpm ); + toolBarBitmaps[4] = new wxBitmap( cut_xpm ); +// toolBarBitmaps[5] = new wxBitmap( paste_xpm ); + toolBarBitmaps[5] = new wxBitmap( preview_xpm ); + toolBarBitmaps[6] = new wxBitmap( print_xpm ); + toolBarBitmaps[7] = new wxBitmap( help_xpm ); +#endif + +#ifdef __WXMSW__ + int width = 24; +#else + int width = 16; +#endif + int currentX = 5; + + toolBar->AddTool(wxID_NEW, *(toolBarBitmaps[0]), wxNullBitmap, FALSE, currentX, -1, (wxObject *) NULL, "New file"); + currentX += width + 5; + toolBar->AddTool(wxID_OPEN, *(toolBarBitmaps[1]), wxNullBitmap, FALSE, currentX, -1, (wxObject *) NULL, "Open file"); + currentX += width + 5; + toolBar->AddTool(wxID_SAVE, *(toolBarBitmaps[2]), wxNullBitmap, FALSE, currentX, -1, (wxObject *) NULL, "Save file"); + currentX += width + 5; + toolBar->AddSeparator(); + toolBar->AddTool(wxID_COPY, *(toolBarBitmaps[3]), wxNullBitmap, FALSE, currentX, -1, (wxObject *) NULL, "Copy"); + currentX += width + 5; + toolBar->AddTool(wxID_CUT, *(toolBarBitmaps[4]), wxNullBitmap, FALSE, currentX, -1, (wxObject *) NULL, "Cut"); + currentX += width + 5; + toolBar->AddTool(wxID_PASTE, *(toolBarBitmaps[5]), wxNullBitmap, FALSE, currentX, -1, (wxObject *) NULL, "Paste"); + currentX += width + 5; + toolBar->AddSeparator(); + toolBar->AddTool(wxID_PRINT, *(toolBarBitmaps[6]), wxNullBitmap, FALSE, currentX, -1, (wxObject *) NULL, "Print"); + currentX += width + 5; + toolBar->AddSeparator(); + toolBar->AddTool(wxID_HELP, *(toolBarBitmaps[7]), wxNullBitmap, FALSE, currentX, -1, (wxObject *) NULL, "Help"); + + toolBar->Realize(); + + // Can delete the bitmaps since they're reference counted + int i; + for (i = 0; i < 8; i++) + delete toolBarBitmaps[i]; + + return TRUE; +} + +BEGIN_EVENT_TABLE(MyFrame, wxMiniFrame) + EVT_CLOSE(MyFrame::OnCloseWindow) +END_EVENT_TABLE() + +// Define my frame constructor +MyFrame::MyFrame(wxFrame* parent, wxWindowID id, const wxString& title, const wxPoint& pos, + const wxSize& size ) : + wxMiniFrame(parent, id, title, pos, size ) +{ +} + +// - must delete all frames except for the main one. +void MyFrame::OnCloseWindow(wxCloseEvent& WXUNUSED(event)) +{ + Destroy(); +} + diff --git a/samples/minifram/test.def b/samples/minifram/test.def new file mode 100644 index 0000000000..897b9dacbb --- /dev/null +++ b/samples/minifram/test.def @@ -0,0 +1,8 @@ +NAME ToolTest +DESCRIPTION 'wxToolBar Sample' +EXETYPE WINDOWS +STUB 'WINSTUB.EXE' +CODE PRELOAD MOVEABLE DISCARDABLE +DATA PRELOAD MOVEABLE MULTIPLE +HEAPSIZE 1024 +STACKSIZE 8192 diff --git a/samples/minifram/test.h b/samples/minifram/test.h new file mode 100644 index 0000000000..db0f7dc5da --- /dev/null +++ b/samples/minifram/test.h @@ -0,0 +1,35 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: test.h +// Purpose: wxToolBar sample +// Author: Julian Smart +// Modified by: +// Created: 23/07/98 +// RCS-ID: $Id$ +// Copyright: (c) Julian Smart and Robert Roebling +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#include "wx/minifram.h" + +// Define a new application +class MyApp: public wxApp +{ + public: + bool OnInit(void); + bool InitToolbar(wxToolBar* toolBar); +}; + +// Define a new frame +class MyFrame: public wxMiniFrame +{ +public: + MyFrame(wxFrame *parent, wxWindowID id = -1, const wxString& title = "wxToolBar Sample", + const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize ); + + void OnCloseWindow(wxCloseEvent& event); + +DECLARE_EVENT_TABLE() +}; + +#define ID_TOOLBAR 500 + diff --git a/samples/minifram/test.rc b/samples/minifram/test.rc new file mode 100644 index 0000000000..6c9086d0c6 --- /dev/null +++ b/samples/minifram/test.rc @@ -0,0 +1,13 @@ +mondrian ICON "mondrian.ico" +#include "wx/msw/wx.rc" + +icon1 BITMAP "bitmaps/new.bmp" +icon2 BITMAP "bitmaps/open.bmp" +icon3 BITMAP "bitmaps/save.bmp" +icon4 BITMAP "bitmaps/copy.bmp" +icon5 BITMAP "bitmaps/cut.bmp" +icon6 BITMAP "bitmaps/paste.bmp" +icon7 BITMAP "bitmaps/print.bmp" + +icon8 BITMAP "bitmaps/help.bmp" + diff --git a/src/gtk.inc b/src/gtk.inc index c68b58eae4..ce2f89c181 100644 --- a/src/gtk.inc +++ b/src/gtk.inc @@ -95,6 +95,7 @@ LIB_CPP_SRC=\ gtk/listbox.cpp \ gtk/mdi.cpp \ gtk/menu.cpp \ + gtk/minifram.cpp \ gtk/notebook.cpp \ gtk/palette.cpp \ gtk/pen.cpp \ diff --git a/src/gtk/frame.cpp b/src/gtk/frame.cpp index bfbbda8e30..a80ffe0666 100644 --- a/src/gtk/frame.cpp +++ b/src/gtk/frame.cpp @@ -108,6 +108,8 @@ wxFrame::wxFrame() m_frameStatusBar = (wxStatusBar *) NULL; m_frameToolBar = (wxToolBar *) NULL; m_sizeSet = FALSE; + m_miniEdge = 0; + m_miniTitle = 0; } wxFrame::wxFrame( wxWindow *parent, wxWindowID id, const wxString &title, @@ -118,6 +120,8 @@ wxFrame::wxFrame( wxWindow *parent, wxWindowID id, const wxString &title, m_frameStatusBar = (wxStatusBar *) NULL; m_frameToolBar = (wxToolBar *) NULL; m_sizeSet = FALSE; + m_miniEdge = 0; + m_miniTitle = 0; Create( parent, id, title, pos, size, style, name ); } @@ -213,7 +217,7 @@ bool wxFrame::Destroy() wxPoint wxFrame::GetClientAreaOrigin() const { - wxPoint pt(0, 0); + wxPoint pt( m_miniEdge, m_miniEdge + m_miniTitle ); if (m_frameMenuBar) { int h = 0; @@ -325,6 +329,11 @@ void wxFrame::GetClientSize( int *width, int *height ) const m_frameToolBar->GetSize( (int *) NULL, &y ); (*height) -= y; } + (*height) -= m_miniEdge*2 + m_miniTitle; + } + if (width) + { + (*width) -= m_miniEdge*2; } } @@ -341,7 +350,7 @@ void wxFrame::SetClientSize( int const width, int const height ) m_frameToolBar->GetSize( (int *) NULL, &y ); h += y; } - wxWindow::SetClientSize( width, h ); + wxWindow::SetClientSize( width + m_miniEdge*2, h + m_miniEdge*2 + m_miniTitle ); } void wxFrame::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y), int width, int height ) @@ -365,39 +374,57 @@ void wxFrame::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y), int width, int height gtk_widget_set_usize( m_widget, m_width, m_height ); - // This emulates the new wxMSW behaviour + // this emulates the new wxMSW behaviour of placing all + // frame-subwindows (menu, toolbar..) on one native window + // OK, this hurts in the eye, but I don't want to call SetSize() + // because I don't want to call any non-native functions here. if (m_frameMenuBar) { - m_frameMenuBar->m_x = 1; - m_frameMenuBar->m_y = 1; - m_frameMenuBar->m_width = m_width-2; - m_frameMenuBar->m_height = wxMENU_HEIGHT-2; - gtk_myfixed_move( GTK_MYFIXED(m_wxwindow), m_frameMenuBar->m_widget, 1, 1 ); - gtk_widget_set_usize( m_frameMenuBar->m_widget, m_width-2, wxMENU_HEIGHT-2 ); + int xx = 1 + m_miniEdge; + int yy = 1 + m_miniEdge + m_miniTitle; + int ww = m_width - 2 - 2*m_miniEdge; + int hh = wxMENU_HEIGHT-2; + m_frameMenuBar->m_x = xx; + m_frameMenuBar->m_y = yy; + m_frameMenuBar->m_width = ww; + m_frameMenuBar->m_height = hh; + + gtk_myfixed_move( GTK_MYFIXED(m_wxwindow), m_frameMenuBar->m_widget, xx, yy ); + gtk_widget_set_usize( m_frameMenuBar->m_widget, ww, hh ); } if (m_frameToolBar) { - int y = 0; - if (m_frameMenuBar) y = wxMENU_HEIGHT; - int h = m_frameToolBar->m_height; + int xx = 1 + m_miniEdge; + int yy = m_miniEdge + m_miniTitle; + if (m_frameMenuBar) yy += wxMENU_HEIGHT; + int ww = m_width -2 - 2*m_miniEdge; + int hh = m_frameToolBar->m_height; - m_frameToolBar->m_x = 2; - gtk_myfixed_move( GTK_MYFIXED(m_wxwindow), m_frameToolBar->m_widget, 2, y ); - gtk_widget_set_usize( m_frameToolBar->m_widget, m_width-3, h ); + m_frameToolBar->m_x = xx; + m_frameToolBar->m_y = yy; + m_frameToolBar->m_height = hh; + m_frameToolBar->m_width = ww; + + gtk_myfixed_move( GTK_MYFIXED(m_wxwindow), m_frameToolBar->m_widget, xx, yy ); + gtk_widget_set_usize( m_frameToolBar->m_widget, ww, hh ); } if (m_frameStatusBar) { - // OK, this hurts in the eye, but I don't want to call SetSize() - // because I don't want to call any non-native functions here. - m_frameStatusBar->m_x = 0; - m_frameStatusBar->m_y = m_height-wxSTATUS_HEIGHT; - m_frameStatusBar->m_width = m_width; - m_frameStatusBar->m_height = wxSTATUS_HEIGHT; - gtk_myfixed_move( GTK_MYFIXED(m_wxwindow), m_frameStatusBar->m_widget, 0, m_height-wxSTATUS_HEIGHT ); - gtk_widget_set_usize( m_frameStatusBar->m_widget, m_width, wxSTATUS_HEIGHT ); + int xx = 0 + m_miniEdge; + int yy = m_height - wxSTATUS_HEIGHT - m_miniEdge; + int ww = m_width - 2*m_miniEdge; + int hh = wxSTATUS_HEIGHT; + + m_frameStatusBar->m_x = xx; + m_frameStatusBar->m_y = yy; + m_frameStatusBar->m_width = ww; + m_frameStatusBar->m_height = hh; + + gtk_myfixed_move( GTK_MYFIXED(m_wxwindow), m_frameStatusBar->m_widget, xx, yy ); + gtk_widget_set_usize( m_frameStatusBar->m_widget, ww, hh ); } m_sizeSet = TRUE; @@ -606,3 +633,4 @@ void wxFrame::SetIcon( const wxIcon &icon ) gdk_window_set_icon( m_widget->window, (GdkWindow *) NULL, icon.GetPixmap(), bm ); } + diff --git a/src/gtk/minifram.cpp b/src/gtk/minifram.cpp new file mode 100644 index 0000000000..d2e750c04a --- /dev/null +++ b/src/gtk/minifram.cpp @@ -0,0 +1,153 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: minifram.cpp +// Purpose: +// Author: Robert Roebling +// Id: $Id$ +// Copyright: (c) 1998 Robert Roebling +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifdef __GNUG__ +#pragma implementation "minifram.h" +#endif + +#include "wx/minifram.h" +#include "wx/dcscreen.h" + +//----------------------------------------------------------------------------- +// "clicked" +//----------------------------------------------------------------------------- + +static void gtk_button_clicked_callback( GtkWidget *WXUNUSED(widget), wxMiniFrame *mf ) +{ + mf->Close(); +} + +//----------------------------------------------------------------------------- +// wxMiniFrame +//----------------------------------------------------------------------------- + +BEGIN_EVENT_TABLE(wxMiniFrame,wxFrame) + EVT_PAINT(wxMiniFrame::OnPaint) + EVT_MOUSE_EVENTS(wxMiniFrame::OnMouse) +END_EVENT_TABLE() + +IMPLEMENT_DYNAMIC_CLASS(wxMiniFrame,wxFrame) + +bool wxMiniFrame::Create( wxWindow *parent, wxWindowID id, const wxString &title, + const wxPoint &pos, const wxSize &size, + long style, const wxString &name ) +{ + style = style | wxSIMPLE_BORDER; + + m_miniEdge = 3; + m_miniTitle = 13; + m_isDragging = FALSE; + m_oldX = -1; + m_oldY = -1; + m_diffX = 0; + m_diffY = 0; + + wxFrame::Create( parent, id, title, pos, size, style, name ); + + GtkWidget *close_button = gtk_button_new_with_label( "x" ); + + gtk_myfixed_put( GTK_MYFIXED(m_wxwindow), close_button, 4, 4 ); + gtk_widget_set_usize( close_button, 12, 11 ); + + gtk_widget_show( close_button ); + + gtk_signal_connect( GTK_OBJECT(close_button), "clicked", + GTK_SIGNAL_FUNC(gtk_button_clicked_callback), (gpointer*)this ); + + return TRUE; +} + +void wxMiniFrame::OnPaint( wxPaintEvent &WXUNUSED(event) ) +{ + if (m_miniTitle == 0) return; + if (m_title.IsEmpty()) return; + + wxPaintDC dc(this); + + dc.SetBrush( *wxTRANSPARENT_BRUSH ); + dc.DrawRectangle( 0, 0, m_width, m_height ); + + dc.SetPen( *wxWHITE_PEN ); + dc.DrawLine( 1, 1, m_width-2, 1 ); + dc.DrawLine( 1, 1, 1, m_height-2 ); + + dc.SetPen( *wxMEDIUM_GREY_PEN ); + dc.DrawLine( 1, m_height-1, m_width-2, m_height-1 ); + dc.DrawLine( m_width-1, 1, m_width-1, m_height-2 ); + + dc.SetBrush( *wxBLUE_BRUSH ); + dc.SetPen( *wxTRANSPARENT_PEN ); + dc.DrawRectangle( m_miniEdge, m_miniEdge, m_width - 2*m_miniEdge, m_miniTitle ); + + dc.SetTextForeground( *wxWHITE ); + dc.SetFont( *wxSMALL_FONT ); + dc.DrawText( m_title, 14 + m_miniEdge, 1 + m_miniEdge ); +} + +void wxMiniFrame::DrawFrame( int x, int y ) +{ + int org_x = 0; + int org_y = 0; + gdk_window_get_origin( m_wxwindow->window, &org_x, &org_y ); + x += org_x; + y += org_y; + + wxScreenDC dc; + dc.SetLogicalFunction( wxXOR ); + + dc.DrawRectangle( x, y, m_width, m_height ); +} + +void wxMiniFrame::OnMouse( wxMouseEvent &event ) +{ + int x = event.GetX(); + int y = event.GetY(); + + if (event.LeftDown()) + { + CaptureMouse(); + m_diffX = x; + m_diffY = y; + DrawFrame( 0, 0 ); + m_oldX = 0; + m_oldY = 0; + m_isDragging = TRUE; + return; + } + + if (event.Dragging() && m_isDragging) + { + DrawFrame( m_oldX, m_oldY ); + m_oldX = x - m_diffX; + m_oldY = y - m_diffY; + DrawFrame( m_oldX, m_oldY ); + return; + } + + if (event.LeftUp() && m_isDragging) + { + m_isDragging = FALSE; + DrawFrame( m_oldX, m_oldY ); + ReleaseMouse(); + + int org_x = 0; + int org_y = 0; + gdk_window_get_origin( m_wxwindow->window, &org_x, &org_y ); + x += org_x - m_diffX; + y += org_y - m_diffY; + m_x = x; + m_y = y; + gtk_widget_set_uposition( m_widget, x, y ); + + return; + } + + event.Skip(); +} + diff --git a/src/gtk1/frame.cpp b/src/gtk1/frame.cpp index bfbbda8e30..a80ffe0666 100644 --- a/src/gtk1/frame.cpp +++ b/src/gtk1/frame.cpp @@ -108,6 +108,8 @@ wxFrame::wxFrame() m_frameStatusBar = (wxStatusBar *) NULL; m_frameToolBar = (wxToolBar *) NULL; m_sizeSet = FALSE; + m_miniEdge = 0; + m_miniTitle = 0; } wxFrame::wxFrame( wxWindow *parent, wxWindowID id, const wxString &title, @@ -118,6 +120,8 @@ wxFrame::wxFrame( wxWindow *parent, wxWindowID id, const wxString &title, m_frameStatusBar = (wxStatusBar *) NULL; m_frameToolBar = (wxToolBar *) NULL; m_sizeSet = FALSE; + m_miniEdge = 0; + m_miniTitle = 0; Create( parent, id, title, pos, size, style, name ); } @@ -213,7 +217,7 @@ bool wxFrame::Destroy() wxPoint wxFrame::GetClientAreaOrigin() const { - wxPoint pt(0, 0); + wxPoint pt( m_miniEdge, m_miniEdge + m_miniTitle ); if (m_frameMenuBar) { int h = 0; @@ -325,6 +329,11 @@ void wxFrame::GetClientSize( int *width, int *height ) const m_frameToolBar->GetSize( (int *) NULL, &y ); (*height) -= y; } + (*height) -= m_miniEdge*2 + m_miniTitle; + } + if (width) + { + (*width) -= m_miniEdge*2; } } @@ -341,7 +350,7 @@ void wxFrame::SetClientSize( int const width, int const height ) m_frameToolBar->GetSize( (int *) NULL, &y ); h += y; } - wxWindow::SetClientSize( width, h ); + wxWindow::SetClientSize( width + m_miniEdge*2, h + m_miniEdge*2 + m_miniTitle ); } void wxFrame::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y), int width, int height ) @@ -365,39 +374,57 @@ void wxFrame::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y), int width, int height gtk_widget_set_usize( m_widget, m_width, m_height ); - // This emulates the new wxMSW behaviour + // this emulates the new wxMSW behaviour of placing all + // frame-subwindows (menu, toolbar..) on one native window + // OK, this hurts in the eye, but I don't want to call SetSize() + // because I don't want to call any non-native functions here. if (m_frameMenuBar) { - m_frameMenuBar->m_x = 1; - m_frameMenuBar->m_y = 1; - m_frameMenuBar->m_width = m_width-2; - m_frameMenuBar->m_height = wxMENU_HEIGHT-2; - gtk_myfixed_move( GTK_MYFIXED(m_wxwindow), m_frameMenuBar->m_widget, 1, 1 ); - gtk_widget_set_usize( m_frameMenuBar->m_widget, m_width-2, wxMENU_HEIGHT-2 ); + int xx = 1 + m_miniEdge; + int yy = 1 + m_miniEdge + m_miniTitle; + int ww = m_width - 2 - 2*m_miniEdge; + int hh = wxMENU_HEIGHT-2; + m_frameMenuBar->m_x = xx; + m_frameMenuBar->m_y = yy; + m_frameMenuBar->m_width = ww; + m_frameMenuBar->m_height = hh; + + gtk_myfixed_move( GTK_MYFIXED(m_wxwindow), m_frameMenuBar->m_widget, xx, yy ); + gtk_widget_set_usize( m_frameMenuBar->m_widget, ww, hh ); } if (m_frameToolBar) { - int y = 0; - if (m_frameMenuBar) y = wxMENU_HEIGHT; - int h = m_frameToolBar->m_height; + int xx = 1 + m_miniEdge; + int yy = m_miniEdge + m_miniTitle; + if (m_frameMenuBar) yy += wxMENU_HEIGHT; + int ww = m_width -2 - 2*m_miniEdge; + int hh = m_frameToolBar->m_height; - m_frameToolBar->m_x = 2; - gtk_myfixed_move( GTK_MYFIXED(m_wxwindow), m_frameToolBar->m_widget, 2, y ); - gtk_widget_set_usize( m_frameToolBar->m_widget, m_width-3, h ); + m_frameToolBar->m_x = xx; + m_frameToolBar->m_y = yy; + m_frameToolBar->m_height = hh; + m_frameToolBar->m_width = ww; + + gtk_myfixed_move( GTK_MYFIXED(m_wxwindow), m_frameToolBar->m_widget, xx, yy ); + gtk_widget_set_usize( m_frameToolBar->m_widget, ww, hh ); } if (m_frameStatusBar) { - // OK, this hurts in the eye, but I don't want to call SetSize() - // because I don't want to call any non-native functions here. - m_frameStatusBar->m_x = 0; - m_frameStatusBar->m_y = m_height-wxSTATUS_HEIGHT; - m_frameStatusBar->m_width = m_width; - m_frameStatusBar->m_height = wxSTATUS_HEIGHT; - gtk_myfixed_move( GTK_MYFIXED(m_wxwindow), m_frameStatusBar->m_widget, 0, m_height-wxSTATUS_HEIGHT ); - gtk_widget_set_usize( m_frameStatusBar->m_widget, m_width, wxSTATUS_HEIGHT ); + int xx = 0 + m_miniEdge; + int yy = m_height - wxSTATUS_HEIGHT - m_miniEdge; + int ww = m_width - 2*m_miniEdge; + int hh = wxSTATUS_HEIGHT; + + m_frameStatusBar->m_x = xx; + m_frameStatusBar->m_y = yy; + m_frameStatusBar->m_width = ww; + m_frameStatusBar->m_height = hh; + + gtk_myfixed_move( GTK_MYFIXED(m_wxwindow), m_frameStatusBar->m_widget, xx, yy ); + gtk_widget_set_usize( m_frameStatusBar->m_widget, ww, hh ); } m_sizeSet = TRUE; @@ -606,3 +633,4 @@ void wxFrame::SetIcon( const wxIcon &icon ) gdk_window_set_icon( m_widget->window, (GdkWindow *) NULL, icon.GetPixmap(), bm ); } + diff --git a/src/gtk1/minifram.cpp b/src/gtk1/minifram.cpp new file mode 100644 index 0000000000..d2e750c04a --- /dev/null +++ b/src/gtk1/minifram.cpp @@ -0,0 +1,153 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: minifram.cpp +// Purpose: +// Author: Robert Roebling +// Id: $Id$ +// Copyright: (c) 1998 Robert Roebling +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifdef __GNUG__ +#pragma implementation "minifram.h" +#endif + +#include "wx/minifram.h" +#include "wx/dcscreen.h" + +//----------------------------------------------------------------------------- +// "clicked" +//----------------------------------------------------------------------------- + +static void gtk_button_clicked_callback( GtkWidget *WXUNUSED(widget), wxMiniFrame *mf ) +{ + mf->Close(); +} + +//----------------------------------------------------------------------------- +// wxMiniFrame +//----------------------------------------------------------------------------- + +BEGIN_EVENT_TABLE(wxMiniFrame,wxFrame) + EVT_PAINT(wxMiniFrame::OnPaint) + EVT_MOUSE_EVENTS(wxMiniFrame::OnMouse) +END_EVENT_TABLE() + +IMPLEMENT_DYNAMIC_CLASS(wxMiniFrame,wxFrame) + +bool wxMiniFrame::Create( wxWindow *parent, wxWindowID id, const wxString &title, + const wxPoint &pos, const wxSize &size, + long style, const wxString &name ) +{ + style = style | wxSIMPLE_BORDER; + + m_miniEdge = 3; + m_miniTitle = 13; + m_isDragging = FALSE; + m_oldX = -1; + m_oldY = -1; + m_diffX = 0; + m_diffY = 0; + + wxFrame::Create( parent, id, title, pos, size, style, name ); + + GtkWidget *close_button = gtk_button_new_with_label( "x" ); + + gtk_myfixed_put( GTK_MYFIXED(m_wxwindow), close_button, 4, 4 ); + gtk_widget_set_usize( close_button, 12, 11 ); + + gtk_widget_show( close_button ); + + gtk_signal_connect( GTK_OBJECT(close_button), "clicked", + GTK_SIGNAL_FUNC(gtk_button_clicked_callback), (gpointer*)this ); + + return TRUE; +} + +void wxMiniFrame::OnPaint( wxPaintEvent &WXUNUSED(event) ) +{ + if (m_miniTitle == 0) return; + if (m_title.IsEmpty()) return; + + wxPaintDC dc(this); + + dc.SetBrush( *wxTRANSPARENT_BRUSH ); + dc.DrawRectangle( 0, 0, m_width, m_height ); + + dc.SetPen( *wxWHITE_PEN ); + dc.DrawLine( 1, 1, m_width-2, 1 ); + dc.DrawLine( 1, 1, 1, m_height-2 ); + + dc.SetPen( *wxMEDIUM_GREY_PEN ); + dc.DrawLine( 1, m_height-1, m_width-2, m_height-1 ); + dc.DrawLine( m_width-1, 1, m_width-1, m_height-2 ); + + dc.SetBrush( *wxBLUE_BRUSH ); + dc.SetPen( *wxTRANSPARENT_PEN ); + dc.DrawRectangle( m_miniEdge, m_miniEdge, m_width - 2*m_miniEdge, m_miniTitle ); + + dc.SetTextForeground( *wxWHITE ); + dc.SetFont( *wxSMALL_FONT ); + dc.DrawText( m_title, 14 + m_miniEdge, 1 + m_miniEdge ); +} + +void wxMiniFrame::DrawFrame( int x, int y ) +{ + int org_x = 0; + int org_y = 0; + gdk_window_get_origin( m_wxwindow->window, &org_x, &org_y ); + x += org_x; + y += org_y; + + wxScreenDC dc; + dc.SetLogicalFunction( wxXOR ); + + dc.DrawRectangle( x, y, m_width, m_height ); +} + +void wxMiniFrame::OnMouse( wxMouseEvent &event ) +{ + int x = event.GetX(); + int y = event.GetY(); + + if (event.LeftDown()) + { + CaptureMouse(); + m_diffX = x; + m_diffY = y; + DrawFrame( 0, 0 ); + m_oldX = 0; + m_oldY = 0; + m_isDragging = TRUE; + return; + } + + if (event.Dragging() && m_isDragging) + { + DrawFrame( m_oldX, m_oldY ); + m_oldX = x - m_diffX; + m_oldY = y - m_diffY; + DrawFrame( m_oldX, m_oldY ); + return; + } + + if (event.LeftUp() && m_isDragging) + { + m_isDragging = FALSE; + DrawFrame( m_oldX, m_oldY ); + ReleaseMouse(); + + int org_x = 0; + int org_y = 0; + gdk_window_get_origin( m_wxwindow->window, &org_x, &org_y ); + x += org_x - m_diffX; + y += org_y - m_diffY; + m_x = x; + m_y = y; + gtk_widget_set_uposition( m_widget, x, y ); + + return; + } + + event.Skip(); +} + -- 2.45.2