class WXDLLEXPORT wxPanel : public wxWindow
{
public:
- wxPanel();
+ wxPanel();
+
+ // Old-style constructor (no default values for coordinates to avoid
+ // ambiguity with the new one)
+ wxPanel(wxWindow *parent,
+ int x, int y, int width, int height,
+ long style = wxTAB_TRAVERSAL | wxNO_BORDER,
+ const wxString& name = wxPanelNameStr)
+ {
+ Create(parent, -1, wxPoint(x, y), wxSize(width, height), style, name);
+ }
+
+ // Constructor
+ wxPanel(wxWindow *parent,
+ wxWindowID id = -1,
+ const wxPoint& pos = wxDefaultPosition,
+ const wxSize& size = wxDefaultSize,
+ long style = wxTAB_TRAVERSAL | wxNO_BORDER,
+ const wxString& name = wxPanelNameStr)
+ {
+ Create(parent, id, pos, size, style, name);
+ }
- // Old-style constructor (no default values for coordinates to avoid ambiguity
- // with the new one)
- wxPanel(wxWindow *parent,
- int x, int y, int width, int height,
- long style = wxTAB_TRAVERSAL | wxNO_BORDER,
- const wxString& name = wxPanelNameStr)
- {
- Create(parent, -1, wxPoint(x, y), wxSize(width, height), style, name);
- }
+ // Pseudo ctor
+ bool Create(wxWindow *parent, wxWindowID id,
+ const wxPoint& pos = wxDefaultPosition,
+ const wxSize& size = wxDefaultSize,
+ long style = wxTAB_TRAVERSAL | wxNO_BORDER,
+ const wxString& name = wxPanelNameStr);
+
+ // Sends an OnInitDialog event, which in turns transfers data to
+ // to the dialog via validators.
+ virtual void InitDialog();
- // Constructor
- wxPanel(wxWindow *parent,
- wxWindowID id = -1,
- const wxPoint& pos = wxDefaultPosition,
- const wxSize& size = wxDefaultSize,
- long style = wxTAB_TRAVERSAL | wxNO_BORDER,
- const wxString& name = wxPanelNameStr)
- {
- Create(parent, id, pos, size, style, name);
- }
+ // implementation
+ // responds to colour changes
+ void OnSysColourChanged(wxSysColourChangedEvent& event);
+
+ // process a keyboard navigation message (Tab traversal)
+ void OnNavigationKey(wxNavigationKeyEvent& event);
+
+ // set the focus to the first child if we get it
+ void OnFocus(wxFocusEvent& event);
- bool Create(wxWindow *parent, wxWindowID id,
- const wxPoint& pos = wxDefaultPosition,
- const wxSize& size = wxDefaultSize,
- long style = wxTAB_TRAVERSAL | wxNO_BORDER,
- const wxString& name = wxPanelNameStr);
+ // called by wxWindow whenever it gets focus
+ void SetLastFocus(wxWindow *focus) { m_lastFocus = focus; }
- // Sends an OnInitDialog event, which in turns transfers data to
- // to the dialog via validators.
- virtual void InitDialog();
-
- // Responds to colour changes
- void OnSysColourChanged(wxSysColourChangedEvent& event);
-
- // Process a keyboard navigation message (Tab traversal)
- void OnNavigationKey(wxNavigationKeyEvent& event);
-
- // override base class virtuals
- // we don't want focus for ourselves
- virtual bool AcceptsFocus() const { return FALSE; }
+protected:
+ // the child which had the focus last time this panel was activated
+ wxWindow *m_lastFocus;
private:
DECLARE_DYNAMIC_CLASS(wxPanel)
#define _WX_CONTROL_H_
#ifdef __GNUG__
-#pragma interface "control.h"
+ #pragma interface "control.h"
#endif
#include "wx/window.h"
#include "wx/list.h"
-#include "wx/validate.h"
// General item class
-class WXDLLEXPORT wxControl: public wxWindow
+class WXDLLEXPORT wxControl : public wxWindow
{
- DECLARE_ABSTRACT_CLASS(wxControl)
+ DECLARE_ABSTRACT_CLASS(wxControl)
+
public:
- wxControl(void);
- ~wxControl(void);
+ wxControl();
+ virtual ~wxControl();
+
+ // Simulates an event
+ virtual void Command(wxCommandEvent& WXUNUSED(event)) { }
+ // Calls the callback and appropriate event handlers
+ virtual void ProcessCommand(wxCommandEvent& event);
- virtual void Command(wxCommandEvent& WXUNUSED(event)) {}; // Simulates an event
- virtual void ProcessCommand(wxCommandEvent& event); // Calls the callback and
- // appropriate event handlers
virtual void SetClientSize(int width, int height);
virtual void SetClientSize(const wxSize& sz) { wxWindow::SetClientSize(sz); }
virtual void SetLabel(const wxString& label);
- virtual wxString GetLabel(void) const ;
+ virtual wxString GetLabel() const;
#if WXWIN_COMPATIBILITY
- inline virtual void SetButtonColour(const wxColour& WXUNUSED(col)) { }
- inline wxColour*GetButtonColour(void) const { return NULL; }
+ virtual void SetButtonColour(const wxColour& WXUNUSED(col)) { }
+ wxColour* GetButtonColour() const { return NULL; }
inline virtual void SetLabelFont(const wxFont& font);
inline virtual void SetButtonFont(const wxFont& font);
- inline wxFont& GetLabelFont(void) const ;
- inline wxFont& GetButtonFont(void) const ;
+ inline wxFont& GetLabelFont() const;
+ inline wxFont& GetButtonFont() const;
#endif
// Places item in centre of panel - so can't be used BEFORE panel->Fit()
void Centre(int direction = wxHORIZONTAL);
- inline void Callback(const wxFunction function); // Adds callback
+
+ // Adds callback
+ inline void Callback(const wxFunction function);
// MSW-specific
// Window procedure
- virtual long MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
virtual void MSWOnMouseMove(int x, int y, WXUINT flags);
virtual bool MSWNotify(WXWPARAM wParam, WXLPARAM lParam, WXLPARAM *result);
virtual bool MSWOnDraw(WXDRAWITEMSTRUCT *WXUNUSED(item)) { return FALSE; };
virtual bool MSWOnMeasure(WXMEASUREITEMSTRUCT *WXUNUSED(item)) { return FALSE; };
- inline wxFunction GetCallback(void) { return m_callback; }
- inline wxList& GetSubcontrols(void) { return m_subControls; }
+ wxFunction GetCallback() { return m_callback; }
+ wxList& GetSubcontrols() { return m_subControls; }
+
protected:
wxFunction m_callback; // Callback associated with the window
// MSW implementation
wxList m_subControls; // For controls like radiobuttons which are really composite
-DECLARE_EVENT_TABLE()
+private:
+ DECLARE_EVENT_TABLE()
};
-inline void wxControl::Callback(const wxFunction function) { m_callback = function; }; // Adds callback
+// Adds callback
+inline void wxControl::Callback(const wxFunction function)
+{
+ m_callback = function;
+};
#if WXWIN_COMPATIBILITY
-inline wxFont& wxControl::GetLabelFont(void) const { return GetFont() ; }
-inline wxFont& wxControl::GetButtonFont(void) const { return GetFont() ; }
-inline void wxControl::SetLabelFont(const wxFont& font) { SetFont(font); }
-inline void wxControl::SetButtonFont(const wxFont& font) { SetFont(font); }
+ inline wxFont& wxControl::GetLabelFont() const { return GetFont() ; }
+ inline wxFont& wxControl::GetButtonFont() const { return GetFont() ; }
+ inline void wxControl::SetLabelFont(const wxFont& font) { SetFont(font); }
+ inline void wxControl::SetButtonFont(const wxFont& font) { SetFont(font); }
#endif
#endif
panel = new wxPanel(m_notebook);
m_textentry = new MyTextCtrl( panel, -1, "Write text here.", wxPoint(10,10), wxSize(320,28),
-// wxTE_PROCESS_ENTER);
-0);
-
+ 0);//wxTE_PROCESS_ENTER);
(*m_textentry) << " More text."; // this text is appended
m_textentry->SetInsertionPoint(0);
m_textentry->WriteText("Less text."); // this text is prepended
(void)new wxButton( panel, ID_MOVE_END_ZONE, "Text &zone", wxPoint(370, 60), wxSize(110, 30) );
(void)new wxStaticBox( panel, -1, "wx&Clipboard", wxPoint(345,110), wxSize(160,100) );
(void)new wxButton( panel, ID_COPY_TEXT, "C&opy line 1", wxPoint(375,130), wxSize(110,30) );
- (void)new wxButton( panel, ID_PASTE_TEXT, "&Paste text", wxPoint(375,170), wxSize(110,30) );
+ (new wxButton( panel, ID_PASTE_TEXT, "&Paste text", wxPoint(375,170), wxSize(110,30) ))
+ ->SetDefault();
m_notebook->AddPage( panel, "wxTextCtrl" , FALSE, Image_Text );
wxString choices2[] =
wxTheClipboard->Close();
*m_text << "Closed the clipboard." << "\n";
-
+#else
+ wxLogError("Clipboard API is not yet implemented for this platform.");
#endif
}
SetStatusText(msg);
}
-}
\ No newline at end of file
+}
case 's':
// '%s' expands into file name (quoted because it might
// contain spaces) - except if there are already quotes
- // there because otherwise some programs may get confused by
- // double double quotes
+ // there because otherwise some programs may get confused
+ // by double double quotes
#if 0
if ( *(pc - 2) == '"' )
str << params.GetFileName();
BEGIN_EVENT_TABLE(wxPanel, wxWindow)
EVT_SYS_COLOUR_CHANGED(wxPanel::OnSysColourChanged)
+ EVT_SET_FOCUS(wxPanel::OnFocus)
EVT_NAVIGATION_KEY(wxPanel::OnNavigationKey)
END_EVENT_TABLE()
wxPanel::wxPanel()
{
+ m_lastFocus = NULL;
}
bool wxPanel::Create(wxWindow *parent, wxWindowID id,
long style,
const wxString& name)
{
+ m_lastFocus = NULL;
+
bool ret = wxWindow::Create(parent, id, pos, size, style, name);
if ( ret )
{
if (!node)
{
-#if 0
+//#if 0 // FIXME seems to enter in an infinite loop - how is this possible?
+ // we arrived at the last/first of our children - but may be this
+ // panel is inside another panel, so make focus go to the next/prev
+ // control in the parent (if we have one)
if (GetParent() != NULL)
{
wxNavigationKeyEvent new_event;
return;
}
}
-#endif // 0
+//#endif // 0
node = event.GetDirection() ? GetChildren().First()
: GetChildren().Last();
+
+ continue;
}
wxWindow *child = (wxWindow *)node->Data();
event.Skip();
}
+void wxPanel::OnFocus(wxFocusEvent& event)
+{
+ if ( m_lastFocus )
+ m_lastFocus->SetFocus();
+ else
+ event.Skip();
+}
Default();
}
-long wxControl::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam)
-{
- return wxWindow::MSWWindowProc(nMsg, wParam, lParam);
-}
-
bool wxControl::MSWNotify(WXWPARAM wParam, WXLPARAM lParam,
WXLPARAM* result)
{
int linesToScroll = specifiedLineLineNo - currentLineLineNo;
-/*
- wxDebugMsg("Caret line: %d; Current visible line: %d; Specified line: %d; lines to scroll: %d\n",
- currentLineLineNo1, currentLineLineNo, specifiedLineLineNo, linesToScroll);
-*/
-
if (linesToScroll != 0)
(void)SendMessage(hWnd, EM_LINESCROLL, (WPARAM)0, (LPARAM)MAKELPARAM(linesToScroll, 0));
}
if ( GetEventHandler()->ProcessEvent(eventNav) )
return;
}
+ break;
}
// don't just call event.Skip() because this will cause TABs and ENTERs
// be passed upwards and we don't always want this - instead process it
// right here
- Default();
+ //Default();
+ event.Skip();
}
long wxTextCtrl::MSWGetDlgCode()
#endif
#ifndef WX_PRECOMP
- #include <stdio.h>
#include "wx/setup.h"
#include "wx/menu.h"
#include "wx/dc.h"
#include "wx/button.h"
#include "wx/settings.h"
#include "wx/msgdlg.h"
+
+ #include <stdio.h>
#endif
#if wxUSE_OWNER_DRAWN
wnd->m_hWnd = (WXHWND) hWnd;
}
- // Stop right here if we don't have a valid handle
- // in our wxWnd object.
+ // Stop right here if we don't have a valid handle in our wxWindow object.
if (wnd && !wnd->m_hWnd) {
- // wxDebugMsg("Warning: could not find a valid handle, wx_win.cc/wxWndProc.\n");
wnd->m_hWnd = (WXHWND) hWnd;
long res = wnd->MSWDefWindowProc(message, wParam, lParam );
wnd->m_hWnd = 0;
}
case WM_KEYDOWN:
- {
MSWOnKeyDown((WORD) wParam, lParam);
// we consider these message "not interesting"
if ( wParam == VK_SHIFT || wParam == VK_CONTROL )
return Default();
- // Avoid duplicate messages to OnChar
- if ( (wParam != VK_ESCAPE) && (wParam != VK_SPACE) &&
- (wParam != VK_RETURN) && (wParam != VK_BACK) &&
- (wParam != VK_TAB) )
+ // Avoid duplicate messages to OnChar for these special keys
+ switch ( wParam )
{
- MSWOnChar((WORD)wParam, lParam);
- if ( ::GetKeyState(VK_CONTROL) & 0x100 )
- return Default();
+ case VK_ESCAPE:
+ case VK_SPACE:
+ case VK_RETURN:
+ case VK_BACK:
+ case VK_TAB:
+ case VK_LEFT:
+ case VK_RIGHT:
+ case VK_DOWN:
+ case VK_UP:
+ if ( ::GetKeyState(VK_CONTROL) & 0x100 )
+ MSWOnChar((WORD)wParam, lParam);
+ break;
+
+ default:
+ MSWOnChar((WORD)wParam, lParam);
+ if ( ::GetKeyState(VK_CONTROL) & 0x100 )
+ return Default();
+ break;
}
- else if ( ::GetKeyState(VK_CONTROL) & 0x100 )
- MSWOnChar((WORD)wParam, lParam);
- else
- return Default();
+
break;
- }
case WM_KEYUP:
{
default:
return MSWDefWindowProc(message, wParam, lParam );
}
+
return 0; // Success: we processed this command.
}
::ShowCaret((HWND) GetHWND());
}
+ // panel wants to track the window which was the last to have focus in it
+ wxWindow *parent = GetParent();
+ if ( parent && parent->IsKindOf(CLASSINFO(wxPanel)) )
+ {
+ ((wxPanel *)parent)->SetLastFocus(this);
+ }
+
wxFocusEvent event(wxEVT_SET_FOCUS, m_windowId);
event.SetEventObject(this);
if (!GetEventHandler()->ProcessEvent(event))
if ( msg->message != WM_KEYDOWN )
bProcess = FALSE;
- if ( (HIWORD(msg->lParam) & KF_ALTDOWN) == KF_ALTDOWN )
+ if ( bProcess && (HIWORD(msg->lParam) & KF_ALTDOWN) == KF_ALTDOWN )
bProcess = FALSE;
- bool bCtrlDown = (::GetKeyState(VK_CONTROL) & 0x100) != 0;
+ if ( bProcess )
+ {
+ bool bCtrlDown = (::GetKeyState(VK_CONTROL) & 0x100) != 0;
- // WM_GETDLGCODE: if the control wants it for itself, don't process it
- // (except for Ctrl-Tab/Enter combinations which are always processed)
- LONG lDlgCode = 0;
- if ( bProcess && !bCtrlDown ) {
- lDlgCode = ::SendMessage(msg->hwnd, WM_GETDLGCODE, 0, 0);
- }
+ // WM_GETDLGCODE: ask the control if it wants the key for itself,
+ // don't process it if it's the case (except for Ctrl-Tab/Enter
+ // combinations which are always processed)
+ LONG lDlgCode = 0;
+ if ( !bCtrlDown )
+ {
+ lDlgCode = ::SendMessage(msg->hwnd, WM_GETDLGCODE, 0, 0);
+ }
+
+ bool bForward = TRUE,
+ bWindowChange = FALSE;
- bool bForward = TRUE,
- bWindowChange = FALSE;
- if ( bProcess ) {
- switch ( msg->wParam ) {
+ switch ( msg->wParam )
+ {
case VK_TAB:
if ( lDlgCode & DLGC_WANTTAB ) {
bProcess = FALSE;
break;
case VK_RETURN:
- // if there is a default button, Enter should press it
- if ( !GetDefaultItem() ) {
- // but if there is not it makes sense to make it work
- // like a TAB
- if ( bCtrlDown || (lDlgCode & DLGC_WANTMESSAGE == 0) )
- {
- // nothing to do - all variables are already set
-
- break;
- }
- else
+ {
+ if ( lDlgCode & DLGC_WANTMESSAGE )
{
// control wants to process Enter itself, don't
// call IsDialogMessage() which would interpret
// it
return FALSE;
}
+
+ wxButton *btnDefault = GetDefaultItem();
+ if ( btnDefault && !bCtrlDown )
+ {
+ // if there is a default button, Enter should
+ // press it
+ (void)::SendMessage((HWND)btnDefault->GetHWND(),
+ BM_CLICK, 0, 0);
+ return TRUE;
+ }
+ // else: but if there is not it makes sense to make it
+ // work like a TAB - and that's what we do.
+ // Note that Ctrl-Enter always works this way.
}
- //else: fall through and don't process the message
+ break;
default:
bProcess = FALSE;
}
- }
- if ( bProcess ) {
- wxNavigationKeyEvent event;
- event.SetDirection(bForward);
- event.SetWindowChange(bWindowChange);
- event.SetEventObject(this);
+ if ( bProcess )
+ {
+ wxNavigationKeyEvent event;
+ event.SetDirection(bForward);
+ event.SetWindowChange(bWindowChange);
+ event.SetEventObject(this);
- if ( GetEventHandler()->ProcessEvent(event) )
- return TRUE;
+ if ( GetEventHandler()->ProcessEvent(event) )
+ return TRUE;
+ }
}
- return ::IsDialogMessage((HWND)GetHWND(), msg) != 0;
+ if ( ::IsDialogMessage((HWND)GetHWND(), msg) )
+ return TRUE;
}
#if wxUSE_TOOLTIPS
- else if ( m_tooltip ) {
+ if ( m_tooltip )
+ {
// relay mouse move events to the tooltip control
MSG *msg = (MSG *)pMsg;
if ( msg->message == WM_MOUSEMOVE )
void wxWindow::MSWOnMButtonUp(int x, int y, WXUINT flags)
{
- //wxDebugMsg("MButtonUp\n") ;
wxMouseEvent event(wxEVT_MIDDLE_UP);
event.m_x = x; event.m_y = y;
void wxWindow::OnChar(wxKeyEvent& event)
{
-#if 0
- if ( event.KeyCode() == WXK_TAB ) {
- // propagate the TABs to the parent - it's up to it to decide what
- // to do with it
- wxWindow *parent = GetParent();
- if ( parent ) {
- if ( parent->GetEventHandler()->ProcessEvent(event) )
- return;
- }
- }
-#endif // 0
-
bool isVirtual;
int id = wxCharCodeWXToMSW((int)event.KeyCode(), &isVirtual);
if ( child->GetValidator() && /* child->GetValidator()->Ok() && */
!child->GetValidator()->TransferToWindow() )
{
- wxMessageBox("Application Error", "Could not transfer data to window", wxOK|wxICON_EXCLAMATION);
+ wxLogError(_("Could not transfer data to window"));
return FALSE;
}
winName = "unnamed";
else
winName = GetName();
- wxDebugMsg("Constraint(s) not satisfied for window of type %s, name %s:\n", (const char *)windowClass, (const char *)winName);
+ wxLogDebug("Constraint(s) not satisfied for window of type %s, name %s:",
+ (const char *)windowClass, (const char *)winName);
if (!constr->left.GetDone())
- wxDebugMsg(" unsatisfied 'left' constraint.\n");
+ wxLogDebug(" unsatisfied 'left' constraint.");
if (!constr->right.GetDone())
- wxDebugMsg(" unsatisfied 'right' constraint.\n");
+ wxLogDebug(" unsatisfied 'right' constraint.");
if (!constr->width.GetDone())
- wxDebugMsg(" unsatisfied 'width' constraint.\n");
+ wxLogDebug(" unsatisfied 'width' constraint.");
if (!constr->height.GetDone())
- wxDebugMsg(" unsatisfied 'height' constraint.\n");
- wxDebugMsg("Please check constraints: try adding AsIs() constraints.\n");
+ wxLogDebug(" unsatisfied 'height' constraint.");
+ wxLogDebug("Please check constraints: try adding AsIs() constraints.\n");
}
if (recurse)
--- /dev/null
+#
+# File: makefile.nt
+# Author: Julian Smart
+# Created: 1993
+# Updated:
+# Copyright: (c) 1993, AIAI, University of Edinburgh
+#
+# "%W% %G%"
+#
+# Makefile : Builds winpng.lib library for Windows 3.1
+
+# Change WXDIR or WXWIN to wherever wxWindows is found
+WXDIR = $(WXWIN)
+WXLIB = $(WXDIR)\lib\wx.lib
+WXINC = $(WXDIR)\include
+
+WINPNGDIR = ..\png
+WINPNGINC = $(WINPNGDIR)
+WINPNGLIB = ..\..\lib\winpng.lib
+
+INC = /I..\zlib
+
+FINAL=1
+
+# Set this to nothing if your compiler is MS C++ 7
+ZOPTION=
+
+!ifndef FINAL
+FINAL=0
+!endif
+
+PRECOMP=/YuWX.H
+
+!if "$(FINAL)" == "0"
+OPT = /Od
+CPPFLAGS= /W4 /Zi /MD /GX- $(ZOPTION) $(OPT) /Dwx_msw $(INC) # $(PRECOMP) /Fp$(WXDIR)\src\msw\wx.pch
+CFLAGS= /W4 /Zi /MD /GX- /Od /Dwx_msw $(INC)
+LINKFLAGS=/NOD /CO /ONERROR:NOEXE
+!else
+# /Ox for real FINAL version
+OPT = /O2
+CPPFLAGS= /W4 /MD /GX- /Dwx_msw $(INC) # $(PRECOMP) /Fp$(WXDIR)\src\msw\wx.pch
+CFLAGS= /W4 /MD /GX- /Dwx_msw $(INC)
+LINKFLAGS=/NOD /ONERROR:NOEXE
+!endif
+
+OBJECTS = png.obj pngread.obj pngrtran.obj pngrutil.obj \
+ pngpread.obj pngtrans.obj pngwrite.obj pngwtran.obj pngwutil.obj \
+ pngerror.obj pngmem.obj pngwio.obj pngrio.obj pngget.obj pngset.obj
+
+all: $(WINPNGLIB)
+
+$(WINPNGLIB): $(OBJECTS)
+ erase $(WINPNGLIB)
+ lib @<<
+-out:$(WINPNGLIB)
+$(OBJECTS)
+<<
+
+.c.obj:
+ cl -DWIN32 $(OPT) $(CFLAGS) /c $*.c
+
+clean:
+ erase *.obj
+ erase *.exe
+ erase *.lib
+
+cleanall: clean