source410: literal 4.10 source reconstruction + BC++ 4.52 fleet toolchain archived

- BORLAND/: Borland C++ 4.52 (chosen over 4.5 by byte-match: CODE/RP/CW32.LIB
  is identical to 4.52's install lib). BCC32/TLINK32/TLIB/MAKE run natively on
  Win11; CODE/BT/OPT.MAK is the shipped BTL4OPT.EXE's exact flag recipe
  (extender = Borland PowerPack DPMI32, not Phar Lap TNT).
- restoration/source410/: the literal 1995-form reconstruction of the missing
  BT game source (never mixed into CODE/). Round 1-3 state:
  * 6 of 10 surviving original TUs COMPILE CLEAN under the period toolchain
    (BTMSSN, BTCNSL, BTSCNRL, BTTEAM, BTL4MODE, BTL4ARND) - first builds
    since 1996.
  * BT_L4/BTL4APP.CPP pilot reconstruction: 12/12 functions, Fail() lands on
    its binary-recorded line 400 exactly.
  * BT/BTCNSL.HPP: console wire IDs recovered from the binary's ctors
    (Killed=9, Damaged=10, ScoreUpdate=13, DeathWithoutHonor=15 [T1];
    TeamScore=12 flagged [T4]).
  * MUNGA/: 8 engine-header backfills back-dated from the BT412 WinTesla tree
    (VDATA numbering decomp-verified; AUDREND's OpenAL-era virtual removed -
    the period compiler is the drift detector).
  * Tooling: backdate.py (WinTesla->1995 header transform), compile410.sh
    (per-TU verification sweep under authentic OPT.MAK flags).
  * README: corrected roadmap - MECH.HPP is the capstone grown with the mech
    TU reconstructions; BTREG.CPP green = the header-family milestone.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Cyd
2026-07-19 07:33:26 -05:00
co-authored by Claude Fable 5
parent 599b2388a1
commit 63312e07f9
5913 changed files with 756089 additions and 0 deletions
Binary file not shown.
@@ -0,0 +1,104 @@
//----------------------------------------------------------------------------
// ObjectWindows - (C) Copyright 1991, 1993 by Borland International
//
//----------------------------------------------------------------------------
#include <owl\owlpch.h>
#include <owl\applicat.h>
#include <owl\framewin.h>
#include <owl\button.h>
#include <owl\checkbox.h>
#include <owl\radiobut.h>
#include <owl\groupbox.h>
const WORD ID_BUTTON = 101;
const WORD ID_RBUTTON1 = 102;
const WORD ID_RBUTTON2 = 103;
const WORD ID_CHECKBOX = 104;
const WORD ID_GROUPBOX = 105;
class TTestWindow : public TWindow {
public:
TRadioButton* RButton1;
TRadioButton* RButton2;
TCheckBox* CheckBox;
TGroupBox* GroupBox;
TTestWindow();
// button handlers
//
void HandleButtonMsg(); // ID_BUTTON
void HandleCheckBoxMsg(); // ID_CHECKBOX
void HandleGroupBoxMsg(UINT);
DECLARE_RESPONSE_TABLE(TTestWindow);
};
DEFINE_RESPONSE_TABLE1(TTestWindow, TWindow)
EV_COMMAND(ID_BUTTON, HandleButtonMsg),
EV_COMMAND(ID_CHECKBOX, HandleCheckBoxMsg),
EV_CHILD_NOTIFY_ALL_CODES(ID_GROUPBOX, HandleGroupBoxMsg),
END_RESPONSE_TABLE;
TTestWindow::TTestWindow()
: TWindow(0, 0, 0)
{
new TButton(this, ID_BUTTON, "State of Check Box", 88, 48, 296, 24, FALSE);
CheckBox = new TCheckBox(this, ID_CHECKBOX, "Check Box Text", 158, 12, 150, 26, 0);
GroupBox = new TGroupBox(this, ID_GROUPBOX, "Group Box", 158, 102, 176, 108);
RButton1 = new TRadioButton(this, ID_RBUTTON1, "Radio Button 1",
174, 128, 138, 24, GroupBox);
RButton2 = new TRadioButton(this, ID_RBUTTON2, "Radio Button 2",
174, 162, 138, 24, GroupBox);
}
void
TTestWindow::HandleButtonMsg()
{
if (CheckBox->GetCheck() == BF_CHECKED)
MessageBox("Checked", "The check box is:", MB_OK);
else
MessageBox("Unchecked", "The check box is:", MB_OK);
}
void
TTestWindow::HandleCheckBoxMsg()
{
MessageBox("Toggled", "The check box has been:", MB_OK);
}
void
TTestWindow::HandleGroupBoxMsg(UINT /* notifyCode */)
{
char textBuff[20];
if (RButton1->GetCheck() == BF_CHECKED)
RButton1->GetWindowText(textBuff, sizeof(textBuff));
else
RButton2->GetWindowText(textBuff, sizeof(textBuff));
MessageBox(textBuff, "You have selected:", MB_OK);
}
//----------------------------------------------------------------------------
class TTestApp : public TApplication {
public:
TTestApp() : TApplication() {}
void InitMainWindow();
};
void
TTestApp::InitMainWindow()
{
MainWindow = new TFrameWindow(0, "Button Tester", new TTestWindow);
}
int
OwlMain(int /*argc*/, char* /*argv*/ [])
{
return TTestApp().Run();
}
Binary file not shown.
@@ -0,0 +1,9 @@
#----------------------------------------------------------------------------
# ObjectWindows - (C) Copyright 1991, 1993 by Borland International
# examples\owl\owlapi\button\makefile
#----------------------------------------------------------------------------
MODELS=mldf
EXE = buttonx
!include $(BCEXAMPLEDIR)\owlmake.gen
@@ -0,0 +1,132 @@
//----------------------------------------------------------------------------
// ObjectWindows - (C) Copyright 1994 by Borland International
// Command-enabling sample application
// First version implements four file commands, along with two commands to
// toggle flags and one command to show current state of flags.
// Performs no command enabling.
//----------------------------------------------------------------------------
#include <owl/owlpch.h>
#include <owl/applicat.h>
#include <owl/framewin.h>
#include "cmdenabl.h"
// Class definitions:
// TCmdEnableApp -- application object initializes TApplication, overrides
// InitMainWindow.
class TCmdEnableApp : public TApplication
{
public:
TCmdEnableApp() : TApplication() {}
protected:
void InitMainWindow();
};
// TCmdEnableWindow -- window object initializes TWindow, adds four event
// handlers, adds response table for four events.
class TCmdEnableWindow : public TWindow {
public:
TCmdEnableWindow(TWindow* parent = 0);
protected:
bool isDirty;
bool isNewFile;
// Event handlers
void CmFileNew();
void CmFileOpen();
void CmFileSave();
void CmFileSaveAs();
void CmToggleDirty();
void CmToggleNew();
void CmShowState();
DECLARE_RESPONSE_TABLE(TCmdEnableWindow);
};
DEFINE_RESPONSE_TABLE1(TCmdEnableWindow, TWindow)
EV_COMMAND(CM_FILENEW, CmFileNew),
EV_COMMAND(CM_FILEOPEN, CmFileOpen),
EV_COMMAND(CM_FILESAVE, CmFileSave),
EV_COMMAND(CM_FILESAVEAS, CmFileSaveAs),
EV_COMMAND(CM_TOGGLEDIRTY, CmToggleDirty),
EV_COMMAND(CM_TOGGLENEW, CmToggleNew),
EV_COMMAND(CM_SHOWSTATE, CmShowState),
END_RESPONSE_TABLE;
// Put the OwlMain here just to get it out of the way
int OwlMain(int /*argc*/, char* /*argv*/ [])
{
return TCmdEnableApp().Run();
}
// Class function definitions
// class TCmdEnableApp
// TCmdEnableApp::InitMainWindow
void
TCmdEnableApp::InitMainWindow()
{
// Construct the frame window
TFrameWindow* frame = new TFrameWindow(0, "Command-enabling sample application", new TCmdEnableWindow, true);
// Set the main window and its menu
SetMainWindow(frame);
GetMainWindow()->AssignMenu("COMMANDS");
}
TCmdEnableWindow::TCmdEnableWindow(TWindow *parent) : TWindow(parent)
{
isNewFile = true;
isDirty = false;
}
void
TCmdEnableWindow::CmFileNew()
{
isDirty=false;
isNewFile=true;
MessageBox("Opened a new file.\nisDirty=false\nisNewFile=true", "File action taken");
}
void
TCmdEnableWindow::CmFileOpen()
{
isDirty=false;
isNewFile=false;
MessageBox("Opened an existing file.\nisDirty=false\nisNewFile=false", "File action taken");
}
void
TCmdEnableWindow::CmFileSave()
{
isDirty=false;
isNewFile=false;
MessageBox("Saved an existing file.\nisDirty=false\nisNewFile=false", "File action taken");
}
void
TCmdEnableWindow::CmFileSaveAs()
{
isDirty=false;
isNewFile=false;
MessageBox("Saved a file under a new name.\nisDirty=false\nisNewFile=false", "File action taken");
}
void
TCmdEnableWindow::CmToggleDirty()
{
isDirty=!isDirty;
}
void
TCmdEnableWindow::CmToggleNew()
{
isNewFile = !isNewFile;
}
void
TCmdEnableWindow::CmShowState()
{
string str(isDirty ? "isDirty = true\n" : "isDirty = false\n");
str += (isNewFile ? "isNewFile = true" : "isNewFile = false");
MessageBox(str.c_str(), "Current state");
}
@@ -0,0 +1,159 @@
//----------------------------------------------------------------------------
// ObjectWindows - (C) Copyright 1994 by Borland International
// Command-enabling sample application
// Second version implements command enabling for file commands.
//----------------------------------------------------------------------------
#include <owl/owlpch.h>
#include <owl/applicat.h>
#include <owl/framewin.h>
#include "cmdenabl.h"
// Class definitions:
// TCmdEnableApp -- application object initializes TApplication, overrides
// InitMainWindow.
class TCmdEnableApp : public TApplication
{
public:
TCmdEnableApp() : TApplication() {}
protected:
void InitMainWindow();
};
// TCmdEnableWindow -- window object initializes TWindow, adds four event
// handlers, adds response table for four events.
class TCmdEnableWindow : public TWindow {
public:
TCmdEnableWindow(TWindow* parent = 0);
protected:
bool isDirty;
bool isNewFile;
// Event handlers
void CmFileNew();
void CmFileOpen();
void CmFileSave();
void CmFileSaveAs();
void CmToggleDirty();
void CmToggleNew();
void CmShowState();
// Command-enabling functions
void CeFileNew(TCommandEnabler&);
void CeFileOpen(TCommandEnabler&);
void CeFileSave(TCommandEnabler&);
DECLARE_RESPONSE_TABLE(TCmdEnableWindow);
};
DEFINE_RESPONSE_TABLE1(TCmdEnableWindow, TWindow)
EV_COMMAND(CM_FILENEW, CmFileNew),
EV_COMMAND(CM_FILEOPEN, CmFileOpen),
EV_COMMAND(CM_FILESAVE, CmFileSave),
EV_COMMAND(CM_FILESAVEAS, CmFileSaveAs),
EV_COMMAND(CM_TOGGLEDIRTY, CmToggleDirty),
EV_COMMAND(CM_TOGGLENEW, CmToggleNew),
EV_COMMAND(CM_SHOWSTATE, CmShowState),
EV_COMMAND_ENABLE(CM_FILENEW, CeFileNew),
EV_COMMAND_ENABLE(CM_FILEOPEN, CeFileOpen),
EV_COMMAND_ENABLE(CM_FILESAVE, CeFileSave),
END_RESPONSE_TABLE;
// Put the OwlMain here just to get it out of the way
int OwlMain(int /*argc*/, char* /*argv*/ [])
{
return TCmdEnableApp().Run();
}
// Class function definitions
// class TCmdEnableApp
// TCmdEnableApp::InitMainWindow
void
TCmdEnableApp::InitMainWindow()
{
// Construct the frame window
TFrameWindow* frame = new TFrameWindow(0, "Command-enabling sample application", new TCmdEnableWindow, true);
// Set the main window and its menu
SetMainWindow(frame);
GetMainWindow()->AssignMenu("COMMANDS");
}
TCmdEnableWindow::TCmdEnableWindow(TWindow *parent) : TWindow(parent)
{
isNewFile = true;
isDirty = false;
}
void
TCmdEnableWindow::CmFileNew()
{
isDirty=false;
isNewFile=true;
MessageBox("Opened a new file.\nisDirty=false\nisNewFile=true", "File action taken");
}
void
TCmdEnableWindow::CmFileOpen()
{
isDirty=false;
isNewFile=false;
MessageBox("Opened an existing file.\nisDirty=false\nisNewFile=false", "File action taken");
}
void
TCmdEnableWindow::CmFileSave()
{
isDirty=false;
isNewFile=false;
MessageBox("Saved an existing file.\nisDirty=false\nisNewFile=false", "File action taken");
}
void
TCmdEnableWindow::CmFileSaveAs()
{
isDirty=false;
isNewFile=false;
MessageBox("Saved a file under a new name.\nisDirty=false\nisNewFile=false", "File action taken");
}
void
TCmdEnableWindow::CmToggleDirty()
{
isDirty=!isDirty;
}
void
TCmdEnableWindow::CmToggleNew()
{
isNewFile=!isNewFile;
}
void
TCmdEnableWindow::CmShowState()
{
string str(isDirty ? "isDirty = true\n" : "isDirty = false\n");
str += (isNewFile ? "isNewFile = true" : "isNewFile = false");
MessageBox(str.c_str(), "Current state");
}
void
TCmdEnableWindow::CeFileNew(TCommandEnabler& ce)
{
// Enable CmFileNew if not dirty
ce.Enable(!isDirty);
}
void
TCmdEnableWindow::CeFileOpen(TCommandEnabler& ce)
{
// Enable CmFileSave if not new file and is dirty.
ce.Enable(!isNewFile && isDirty);
}
void
TCmdEnableWindow::CeFileSave(TCommandEnabler& ce)
{
// Enable CmFileSave if not new file
ce.Enable(!isNewFile);
}
@@ -0,0 +1,176 @@
//----------------------------------------------------------------------------
// ObjectWindows - (C) Copyright 199 by Borland International
// Command-enabling sample application
// Third version implements check marks on the toggle functions.
//----------------------------------------------------------------------------
#include <owl/owlpch.h>
#include <owl/applicat.h>
#include <owl/framewin.h>
#include "cmdenabl.h"
// Class definitions:
// TCmdEnableApp -- application object initializes TApplication, overrides
// InitMainWindow.
class TCmdEnableApp : public TApplication
{
public:
TCmdEnableApp() : TApplication() {}
protected:
void InitMainWindow();
};
// TCmdEnableWindow -- window object initializes TWindow, adds four event
// handlers, adds response table for four events.
class TCmdEnableWindow : public TWindow {
public:
TCmdEnableWindow(TWindow* parent = 0);
protected:
bool isDirty;
bool isNewFile;
// Event handlers
void CmFileNew();
void CmFileOpen();
void CmFileSave();
void CmFileSaveAs();
void CmToggleDirty();
void CmToggleNew();
void CmShowState();
// Command-enabling functions
void CeFileNew(TCommandEnabler&);
void CeFileOpen(TCommandEnabler&);
void CeFileSave(TCommandEnabler&);
void CeToggleDirty(TCommandEnabler&);
void CeToggleNew(TCommandEnabler&);
DECLARE_RESPONSE_TABLE(TCmdEnableWindow);
};
DEFINE_RESPONSE_TABLE1(TCmdEnableWindow, TWindow)
EV_COMMAND(CM_FILENEW, CmFileNew),
EV_COMMAND(CM_FILEOPEN, CmFileOpen),
EV_COMMAND(CM_FILESAVE, CmFileSave),
EV_COMMAND(CM_FILESAVEAS, CmFileSaveAs),
EV_COMMAND(CM_TOGGLEDIRTY, CmToggleDirty),
EV_COMMAND(CM_TOGGLENEW, CmToggleNew),
EV_COMMAND(CM_SHOWSTATE, CmShowState),
EV_COMMAND_ENABLE(CM_FILENEW, CeFileNew),
EV_COMMAND_ENABLE(CM_FILEOPEN, CeFileOpen),
EV_COMMAND_ENABLE(CM_FILESAVE, CeFileSave),
EV_COMMAND_ENABLE(CM_TOGGLEDIRTY, CeToggleDirty),
EV_COMMAND_ENABLE(CM_TOGGLENEW, CeToggleNew),
END_RESPONSE_TABLE;
// Put the OwlMain here just to get it out of the way
int OwlMain(int /*argc*/, char* /*argv*/ [])
{
return TCmdEnableApp().Run();
}
// Class function definitions
// class TCmdEnableApp
// TCmdEnableApp::InitMainWindow
void
TCmdEnableApp::InitMainWindow()
{
// Construct the frame window
TFrameWindow* frame = new TFrameWindow(0, "Command-enabling sample application", new TCmdEnableWindow, true);
// Set the main window and its menu
SetMainWindow(frame);
GetMainWindow()->AssignMenu("COMMANDS");
}
TCmdEnableWindow::TCmdEnableWindow(TWindow *parent) : TWindow(parent)
{
isNewFile = true;
isDirty = false;
}
void
TCmdEnableWindow::CmFileNew()
{
isDirty=false;
isNewFile=true;
MessageBox("Opened a new file.\nisDirty=false\nisNewFile=true", "File action taken");
}
void
TCmdEnableWindow::CmFileOpen()
{
isDirty=false;
isNewFile=false;
MessageBox("Opened an existing file.\nisDirty=false\nisNewFile=false", "File action taken");
}
void
TCmdEnableWindow::CmFileSave()
{
isDirty=false;
isNewFile=false;
MessageBox("Saved an existing file.\nisDirty=false\nisNewFile=false", "File action taken");
}
void
TCmdEnableWindow::CmFileSaveAs()
{
isDirty=false;
isNewFile=false;
MessageBox("Saved a file under a new name.\nisDirty=false\nisNewFile=false", "File action taken");
}
void
TCmdEnableWindow::CmToggleDirty()
{
isDirty=!isDirty;
}
void
TCmdEnableWindow::CmToggleNew()
{
isNewFile=!isNewFile;
}
void
TCmdEnableWindow::CmShowState()
{
string str(isDirty ? "isDirty = true\n" : "isDirty = false\n");
str += (isNewFile ? "isNewFile = true" : "isNewFile = false");
MessageBox(str.c_str(), "Current state");
}
void
TCmdEnableWindow::CeFileNew(TCommandEnabler& ce)
{
// Enable CmFileNew if not dirty
ce.Enable(!isDirty);
}
void
TCmdEnableWindow::CeFileOpen(TCommandEnabler& ce)
{
// Enable CmFileOpen if not dirty
ce.Enable(!isDirty);
}
void
TCmdEnableWindow::CeFileSave(TCommandEnabler& ce)
{
// Enable CmFileSave if not new file and is dirty.
ce.Enable(!isNewFile && isDirty);
}
void
TCmdEnableWindow::CeToggleDirty(TCommandEnabler& ce)
{
ce.SetCheck(isDirty ? TCommandEnabler::Checked : TCommandEnabler::Unchecked);
}
void
TCmdEnableWindow::CeToggleNew(TCommandEnabler& ce)
{
ce.SetCheck(isNewFile ? TCommandEnabler::Checked : TCommandEnabler::Unchecked);
}
@@ -0,0 +1,201 @@
//----------------------------------------------------------------------------
// ObjectWindows - (C) Copyright 1994 by Borland International
// Command-enabling sample application
// Fourth version adds a tool bar.
//----------------------------------------------------------------------------
#include <owl/owlpch.h>
#include <owl/applicat.h>
#include <owl/framewin.h>
#include "cmdenabl.h"
#include <owl/decframe.h>
#include <owl/controlb.h>
#include <owl/buttonga.h>
#include <owl/statusba.h>
// Class definitions:
// TCmdEnableApp -- application object initializes TApplication, overrides
// InitMainWindow.
class TCmdEnableApp : public TApplication
{
public:
TCmdEnableApp() : TApplication() {}
protected:
void InitMainWindow();
};
// TCmdEnableWindow -- window object initializes TWindow, adds four event
// handlers, adds response table for four events.
class TCmdEnableWindow : public TWindow {
public:
TCmdEnableWindow(TWindow* parent = 0);
protected:
bool isDirty;
bool isNewFile;
// Event handlers
void CmFileNew();
void CmFileOpen();
void CmFileSave();
void CmFileSaveAs();
void CmToggleDirty();
void CmToggleNew();
void CmShowState();
// Command-enabling functions
void CeFileNew(TCommandEnabler&);
void CeFileOpen(TCommandEnabler&);
void CeFileSave(TCommandEnabler&);
void CeToggleDirty(TCommandEnabler&);
void CeToggleNew(TCommandEnabler&);
DECLARE_RESPONSE_TABLE(TCmdEnableWindow);
};
DEFINE_RESPONSE_TABLE1(TCmdEnableWindow, TWindow)
EV_COMMAND(CM_FILENEW, CmFileNew),
EV_COMMAND(CM_FILEOPEN, CmFileOpen),
EV_COMMAND(CM_FILESAVE, CmFileSave),
EV_COMMAND(CM_FILESAVEAS, CmFileSaveAs),
EV_COMMAND(CM_TOGGLEDIRTY, CmToggleDirty),
EV_COMMAND(CM_TOGGLENEW, CmToggleNew),
EV_COMMAND(CM_SHOWSTATE, CmShowState),
EV_COMMAND_ENABLE(CM_FILENEW, CeFileNew),
EV_COMMAND_ENABLE(CM_FILEOPEN, CeFileOpen),
EV_COMMAND_ENABLE(CM_FILESAVE, CeFileSave),
EV_COMMAND_ENABLE(CM_TOGGLEDIRTY, CeToggleDirty),
EV_COMMAND_ENABLE(CM_TOGGLENEW, CeToggleNew),
END_RESPONSE_TABLE;
// Put the OwlMain here just to get it out of the way
int OwlMain(int /*argc*/, char* /*argv*/ [])
{
return TCmdEnableApp().Run();
}
// Class function definitions
// class TCmdEnableApp
// TCmdEnableApp::InitMainWindow
void
TCmdEnableApp::InitMainWindow()
{
// Construct the decorated frame window
TDecoratedFrame* frame = new TDecoratedFrame(0, "Command-enabling sample application", new TCmdEnableWindow, true);
// Construct a control bar
TControlBar *cb = new TControlBar(frame);
cb->Insert(*new TButtonGadget(CM_FILENEW, CM_FILENEW, TButtonGadget::Command));
cb->Insert(*new TButtonGadget(CM_FILEOPEN, CM_FILEOPEN, TButtonGadget::Command));
cb->Insert(*new TButtonGadget(CM_FILESAVE, CM_FILESAVE, TButtonGadget::Command));
cb->Insert(*new TButtonGadget(CM_FILESAVEAS, CM_FILESAVEAS, TButtonGadget::Command));
cb->Insert(*new TSeparatorGadget);
cb->Insert(*new TButtonGadget(CM_TOGGLEDIRTY, CM_TOGGLEDIRTY, TButtonGadget::NonExclusive));
cb->Insert(*new TButtonGadget(CM_TOGGLENEW, CM_TOGGLENEW, TButtonGadget::NonExclusive));
cb->Insert(*new TButtonGadget(CM_SHOWSTATE, CM_SHOWSTATE, TButtonGadget::Command));
// Turn hints on to fly-over
cb->SetHintMode(TGadgetWindow::EnterHints);
// Create a status bar
TStatusBar *sb = new TStatusBar(frame);
// Insert the control bar and status bar into the frame
frame->Insert(*cb, TDecoratedFrame::Top);
frame->Insert(*sb, TDecoratedFrame::Bottom);
// Set the main window and its menu
SetMainWindow(frame);
GetMainWindow()->AssignMenu("COMMANDS");
}
TCmdEnableWindow::TCmdEnableWindow(TWindow *parent) : TWindow(parent)
{
isNewFile = true;
isDirty = false;
}
void
TCmdEnableWindow::CmFileNew()
{
isDirty=false;
isNewFile=true;
MessageBox("Opened a new file.\nisDirty=false\nisNewFile=true", "File action taken");
}
void
TCmdEnableWindow::CmFileOpen()
{
isDirty=false;
isNewFile=false;
MessageBox("Opened an existing file.\nisDirty=false\nisNewFile=false", "File action taken");
}
void
TCmdEnableWindow::CmFileSave()
{
isDirty=false;
isNewFile=false;
MessageBox("Saved an existing file.\nisDirty=false\nisNewFile=false", "File action taken");
}
void
TCmdEnableWindow::CmFileSaveAs()
{
isDirty=false;
isNewFile=false;
MessageBox("Saved a file under a new name.\nisDirty=false\nisNewFile=false", "File action taken");
}
void
TCmdEnableWindow::CmToggleDirty()
{
isDirty=!isDirty;
}
void
TCmdEnableWindow::CmToggleNew()
{
isNewFile=!isNewFile;
}
void
TCmdEnableWindow::CmShowState()
{
string str(isDirty ? "isDirty = true\n" : "isDirty = false\n");
str += (isNewFile ? "isNewFile = true" : "isNewFile = false");
MessageBox(str.c_str(), "Current state");
}
void
TCmdEnableWindow::CeFileNew(TCommandEnabler& ce)
{
// Enable CmFileNew if not dirty
ce.Enable(!isDirty);
}
void
TCmdEnableWindow::CeFileOpen(TCommandEnabler& ce)
{
// Enable CmFileOpen if not dirty
ce.Enable(!isDirty);
}
void
TCmdEnableWindow::CeFileSave(TCommandEnabler& ce)
{
// Enable CmFileSave if not new file and is dirty.
ce.Enable(!isNewFile && isDirty);
}
void
TCmdEnableWindow::CeToggleDirty(TCommandEnabler& ce)
{
ce.SetCheck(isDirty ? TCommandEnabler::Checked : TCommandEnabler::Unchecked);
}
void
TCmdEnableWindow::CeToggleNew(TCommandEnabler& ce)
{
ce.SetCheck(isNewFile ? TCommandEnabler::Checked : TCommandEnabler::Unchecked);
}
@@ -0,0 +1,12 @@
//----------------------------------------------------------------------------
// ObjectWindows - (C) Copyright 1994 by Borland International
// Command-enabling sample application
//----------------------------------------------------------------------------
#define CM_FILENEW 201
#define CM_FILEOPEN 202
#define CM_FILESAVE 203
#define CM_FILESAVEAS 204
#define CM_TOGGLEDIRTY 205
#define CM_TOGGLENEW 206
#define CM_SHOWSTATE 207
@@ -0,0 +1,232 @@
//----------------------------------------------------------------------------
// ObjectWindows - (C) Copyright 1994 by Borland International
// Command-enabling sample application
//----------------------------------------------------------------------------
#ifndef WORKSHOP_INVOKED
# include <windows.h>
#endif
#include "cmdenabl.h"
#ifdef RC_INVOKED
COMMANDS MENU
{
POPUP "&File"
{
MENUITEM "&New", CM_FILENEW
MENUITEM "&Open", CM_FILEOPEN
MENUITEM "&Save", CM_FILESAVE
MENUITEM "Save &As", CM_FILESAVEAS
}
POPUP "&Actions"
{
MENUITEM "&Dirty?", CM_TOGGLEDIRTY
MENUITEM "&New?", CM_TOGGLENEW
MENUITEM "&Show file state", CM_SHOWSTATE
}
}
CM_FILENEW BITMAP
{
'42 4D 66 01 00 00 00 00 00 00 76 00 00 00 28 00'
'00 00 14 00 00 00 14 00 00 00 01 00 04 00 00 00'
'00 00 F0 00 00 00 00 00 00 00 00 00 00 00 00 00'
'00 00 00 00 00 00 00 00 00 00 00 00 80 00 00 80'
'00 00 00 80 80 00 80 00 00 00 80 00 80 00 80 80'
'00 00 80 80 80 00 C0 C0 C0 00 00 00 FF 00 00 FF'
'00 00 00 FF FF 00 FF 00 00 00 FF 00 FF 00 FF FF'
'00 00 FF FF FF 00 88 88 88 88 88 88 88 88 88 88'
'40 00 88 88 88 88 88 88 88 88 88 88 90 00 88 88'
'88 88 88 88 88 88 88 88 20 00 88 88 88 88 88 88'
'88 88 88 88 40 18 88 88 88 88 88 88 88 88 88 88'
'00 00 88 88 88 88 88 88 88 88 88 88 00 00 88 88'
'88 88 88 88 88 88 88 88 00 00 88 88 88 88 88 88'
'88 88 88 88 0B 00 88 80 08 88 88 88 88 88 88 88'
'00 00 88 80 08 88 88 88 88 88 88 88 00 00 88 80'
'08 88 88 84 44 44 44 48 00 00 88 80 08 80 88 84'
'EF EF EF 48 0B 00 88 80 07 80 08 84 FE FE FE 48'
'00 00 88 87 00 00 00 84 EF EF EF 48 00 00 88 88'
'70 00 00 84 FE FE FE 48 00 00 88 88 88 80 08 84'
'EF EF EF 48 0B 00 88 88 88 80 88 84 FE FE 44 48'
'FF FF 88 88 88 88 88 84 EF EF 44 88 FF FF 88 88'
'88 88 88 84 44 44 48 88 00 00 88 88 88 88 88 88'
'88 88 88 88 0B 00'
}
CM_FILEOPEN BITMAP
{
'42 4D 66 01 00 00 00 00 00 00 76 00 00 00 28 00'
'00 00 14 00 00 00 14 00 00 00 01 00 04 00 00 00'
'00 00 F0 00 00 00 00 00 00 00 00 00 00 00 00 00'
'00 00 00 00 00 00 00 00 00 00 00 00 80 00 00 80'
'00 00 00 80 80 00 80 00 00 00 80 00 80 00 80 80'
'00 00 80 80 80 00 C0 C0 C0 00 00 00 FF 00 00 FF'
'00 00 00 FF FF 00 FF 00 00 00 FF 00 FF 00 FF FF'
'00 00 FF FF FF 00 88 88 88 88 88 88 88 88 88 88'
'46 00 80 00 00 00 00 00 88 88 88 88 00 00 80 87'
'77 77 77 70 88 88 88 88 11 02 80 F8 88 88 88 70'
'88 88 88 88 08 00 80 F9 98 88 88 70 88 88 88 88'
'46 00 80 FF FF FF FF 80 88 88 88 88 00 00 80 00'
'00 00 00 00 88 88 88 88 11 00 88 88 88 88 88 88'
'88 88 88 88 08 30 88 80 08 88 88 88 88 88 88 88'
'46 00 88 80 08 88 88 88 88 88 88 88 00 00 88 80'
'08 88 88 84 44 44 44 48 11 00 88 80 08 80 88 84'
'EF EF EF 48 08 00 88 80 07 80 08 84 F4 44 4E 48'
'00 00 88 87 00 00 00 84 EF EF EF 48 55 55 88 88'
'70 00 00 84 F4 44 4E 48 00 00 88 88 88 80 08 84'
'EF EF EF 48 88 88 88 88 88 80 88 84 F4 4E 44 48'
'00 00 88 88 88 88 88 84 EF EF 44 88 00 00 88 88'
'88 88 88 84 44 44 48 88 00 00 88 88 88 88 88 88'
'88 88 88 88 00 00'
}
CM_FILESAVE BITMAP
{
'42 4D 66 01 00 00 00 00 00 00 76 00 00 00 28 00'
'00 00 14 00 00 00 14 00 00 00 01 00 04 00 00 00'
'00 00 F0 00 00 00 00 00 00 00 00 00 00 00 00 00'
'00 00 00 00 00 00 00 00 00 00 00 00 80 00 00 80'
'00 00 00 80 80 00 80 00 00 00 80 00 80 00 80 80'
'00 00 80 80 80 00 C0 C0 C0 00 00 00 FF 00 00 FF'
'00 00 00 FF FF 00 FF 00 00 00 FF 00 FF 00 FF FF'
'00 00 FF FF FF 00 88 88 88 88 88 88 88 88 88 88'
'46 00 88 88 88 88 00 00 00 00 00 08 00 00 88 88'
'88 88 08 77 77 77 77 08 11 00 88 88 88 88 0F 88'
'88 88 87 08 08 30 88 88 88 88 0F 99 88 88 87 08'
'46 00 88 88 88 88 0F FF FF FF F8 08 00 00 88 88'
'88 88 00 00 00 00 00 08 11 00 88 88 88 88 88 88'
'88 88 88 88 08 00 88 88 88 88 88 88 88 00 88 88'
'00 00 88 88 88 88 88 88 80 00 08 88 55 55 84 44'
'44 44 48 88 00 00 00 88 00 00 84 EF EF EF 48 88'
'88 00 88 88 88 88 84 F4 44 4E 48 88 88 00 88 88'
'00 00 84 EF EF EF 48 88 87 00 88 88 00 00 84 F4'
'44 4E 48 00 00 07 88 88 00 00 84 EF EF EF 48 00'
'00 78 88 88 00 00 84 F4 4E 44 48 88 88 88 88 88'
'00 00 84 EF EF 44 88 88 88 88 88 88 00 00 84 44'
'44 48 88 88 88 88 88 88 00 00 88 88 88 88 88 88'
'88 88 88 88 11 11'
}
CM_FILESAVEAS BITMAP
{
'42 4D 66 01 00 00 00 00 00 00 76 00 00 00 28 00'
'00 00 14 00 00 00 14 00 00 00 01 00 04 00 00 00'
'00 00 F0 00 00 00 00 00 00 00 00 00 00 00 00 00'
'00 00 00 00 00 00 00 00 00 00 00 00 80 00 00 80'
'00 00 00 80 80 00 80 00 00 00 80 00 80 00 80 80'
'00 00 80 80 80 00 C0 C0 C0 00 00 00 FF 00 00 FF'
'00 00 00 FF FF 00 FF 00 00 00 FF 00 FF 00 FF FF'
'00 00 FF FF FF 00 88 88 88 88 88 88 88 88 88 88'
'46 00 88 88 88 88 88 84 44 44 44 48 00 00 88 88'
'88 88 88 84 FF FF FF 48 11 00 88 88 88 88 88 84'
'F4 44 4F 48 08 00 88 88 88 88 88 84 FF FF FF 48'
'00 00 88 88 88 88 88 84 F4 44 4F 48 55 55 88 88'
'88 88 88 84 FF FF FF 48 00 00 88 88 88 88 88 84'
'F4 4F 44 48 88 88 88 88 88 88 88 84 FF FF 44 88'
'00 00 88 88 88 88 88 84 44 44 48 88 00 00 84 44'
'44 44 48 88 88 88 88 88 00 00 84 EF EF EF 48 88'
'88 00 88 88 00 00 84 F4 44 4E 48 88 80 00 08 88'
'00 00 84 EF EF EF 48 88 00 00 00 88 00 00 84 F4'
'44 4E 48 88 88 00 88 88 00 00 84 EF EF EF 48 88'
'87 00 88 88 11 11 84 F4 4E 44 48 00 00 07 88 88'
'00 00 84 EF EF 44 88 00 00 78 88 88 00 00 84 44'
'44 48 88 88 88 88 88 88 00 00 88 88 88 88 88 88'
'88 88 88 88 0B 00'
}
CM_TOGGLEDIRTY BITMAP
{
'42 4D 66 01 00 00 00 00 00 00 76 00 00 00 28 00'
'00 00 14 00 00 00 14 00 00 00 01 00 04 00 00 00'
'00 00 F0 00 00 00 00 00 00 00 00 00 00 00 00 00'
'00 00 10 00 00 00 00 00 00 00 00 00 BF 00 00 BF'
'00 00 00 BF BF 00 BF 00 00 00 BF 00 BF 00 BF BF'
'00 00 C0 C0 C0 00 80 80 80 00 00 00 FF 00 00 FF'
'00 00 00 FF FF 00 FF 00 00 00 FF 00 FF 00 FF FF'
'00 00 FF FF FF 00 77 77 77 77 77 77 77 77 77 77'
'00 00 70 77 07 77 70 07 70 77 77 77 00 00 37 73'
'77 77 33 77 77 07 77 77 00 00 70 70 07 07 70 00'
'00 70 07 77 00 00 30 33 77 77 77 33 33 03 00 77'
'00 00 30 07 77 70 77 77 03 03 30 07 00 00 33 77'
'77 70 07 77 73 77 30 70 00 00 37 07 00 70 00 73'
'07 07 30 30 00 00 77 77 00 70 33 03 30 77 37 37'
'00 00 77 00 00 00 37 33 37 77 77 07 00 00 73 03'
'00 30 77 77 30 70 73 77 00 00 73 00 00 73 07 03'
'07 07 77 07 00 00 73 03 03 73 37 73 00 07 03 77'
'00 00 73 33 37 77 77 73 30 03 77 77 00 00 77 00'
'07 07 77 77 33 00 07 07 00 00 73 33 77 77 77 77'
'73 30 03 77 00 00 73 30 00 07 07 77 07 37 77 77'
'00 00 77 73 70 77 77 73 77 77 77 77 00 00 77 77'
'33 03 77 77 77 77 77 77 00 00 77 77 77 77 77 77'
'77 77 77 77 00 00'
}
CM_TOGGLENEW BITMAP
{
'42 4D 66 01 00 00 00 00 00 00 76 00 00 00 28 00'
'00 00 14 00 00 00 14 00 00 00 01 00 04 00 00 00'
'00 00 F0 00 00 00 00 00 00 00 00 00 00 00 00 00'
'00 00 10 00 00 00 00 00 00 00 00 00 BF 00 00 BF'
'00 00 00 BF BF 00 BF 00 00 00 BF 00 BF 00 BF BF'
'00 00 C0 C0 C0 00 80 80 80 00 00 00 FF 00 00 FF'
'00 00 00 FF FF 00 FF 00 00 00 FF 00 FF 00 FF FF'
'00 00 FF FF FF 00 77 77 77 77 77 77 77 77 77 77'
'00 00 77 77 77 77 7B B7 77 77 77 77 00 00 77 77'
'77 77 7B B7 77 77 77 77 00 00 77 7B 77 77 7B B7'
'77 77 B7 77 00 00 77 77 B7 77 7B B7 77 7B 77 77'
'00 00 77 77 7B 77 77 77 77 B7 77 77 00 00 77 77'
'77 44 44 44 44 77 77 77 00 00 77 77 77 4E FE FE'
'F4 77 77 77 00 00 77 77 77 4F EF EF E4 77 77 77'
'00 00 77 77 77 4E FE FE F4 77 77 77 00 00 7B BB'
'B7 4F EF EF E4 7B BB B7 00 00 77 77 77 4E FE FE'
'F4 77 77 77 00 00 77 77 77 4F EF E4 44 77 77 77'
'00 00 77 77 77 4E FE F4 47 77 77 77 00 00 77 77'
'77 44 44 44 77 B7 77 77 00 00 77 77 7B 77 77 77'
'77 7B 77 77 00 00 77 77 B7 77 7B B7 77 77 B7 77'
'00 00 77 7B 77 77 7B B7 77 77 77 77 00 00 77 77'
'77 77 7B B7 77 77 77 77 00 00 77 77 77 77 7B B7'
'77 77 77 77 00 00'
}
CM_SHOWSTATE BITMAP
{
'42 4D 66 01 00 00 00 00 00 00 76 00 00 00 28 00'
'00 00 14 00 00 00 14 00 00 00 01 00 04 00 00 00'
'00 00 F0 00 00 00 00 00 00 00 00 00 00 00 00 00'
'00 00 10 00 00 00 00 00 00 00 00 00 BF 00 00 BF'
'00 00 00 BF BF 00 BF 00 00 00 BF 00 BF 00 BF BF'
'00 00 C0 C0 C0 00 80 80 80 00 00 00 FF 00 00 FF'
'00 00 00 FF FF 00 FF 00 00 00 FF 00 FF 00 FF FF'
'00 00 FF FF FF 00 77 77 77 77 77 77 77 77 77 77'
'00 00 77 77 77 77 77 77 77 77 77 77 00 00 70 00'
'00 00 00 00 00 00 00 07 00 00 70 77 77 77 77 77'
'77 77 77 07 00 00 70 77 77 77 77 77 77 77 77 07'
'00 00 70 77 77 00 00 00 00 77 77 07 00 00 70 77'
'77 07 77 77 70 77 77 07 00 00 70 77 77 07 77 77'
'70 77 77 07 00 00 70 77 77 00 00 00 00 77 77 07'
'00 00 70 77 77 77 77 77 77 77 77 07 00 00 70 70'
'00 00 00 00 00 00 07 07 00 00 70 77 77 77 77 77'
'77 77 77 07 00 00 70 70 00 00 00 00 00 00 07 07'
'00 00 70 77 77 77 77 77 77 77 77 07 00 00 70 88'
'8C CC CC CC CC CC CC 07 00 00 70 88 8C CC CC CC'
'CC CC CC 07 00 00 70 88 8C CC CC CC CC CC CC 07'
'00 00 70 00 00 00 00 00 00 00 00 07 00 00 77 77'
'77 77 77 77 77 77 77 77 00 00 77 77 77 77 77 77'
'77 77 77 77 00 00'
}
#endif // RC_INVOKED
STRINGTABLE
{
CM_FILENEW, "Create a new file; Sets New to true and Dirty to false"
CM_FILEOPEN, "Open an existing file; Sets New and Dirty to false"
CM_FILESAVE, "Save current file; Sets New and Dirty to false"
CM_FILESAVEAS, "Save current file under new name; Sets New to false and Dirty to false"
CM_TOGGLEDIRTY, "Makes file dirty if clean, clean if dirty"
CM_TOGGLENEW, "Makes file new if existing, existing if new"
CM_SHOWSTATE, "Shows current state of New and Dirty flags"
}
@@ -0,0 +1,18 @@
#----------------------------------------------------------------------------
# ObjectWindows - (C) Copyright 1994 by Borland International
#----------------------------------------------------------------------------
MODELS=mldf
EXE=cmdenab1
RESEXE=cmdenabl.res
EXEALL=cmdenab1.exe cmdenab2.exe cmdenab3.exe cmdenab4.exe
EXEMAKE= $(CMD1) $(CMD2) $(CMD3) $(CMD4)
CMD1=$(EXERULE)
CMD2=$(CMD1:cmdenab1=cmdenab2)
CMD3=$(CMD1:cmdenab1=cmdenab3)
CMD4=$(CMD1:cmdenab1=cmdenab4)
!include $(BCEXAMPLEDIR)\owlmake.gen
@@ -0,0 +1,56 @@
//----------------------------------------------------------------------------
// ObjectWindows - (C) Copyright 1991, 1993 by Borland International
//
// This example uses the custom control and dialog box defined in colordlg.cpp
//
//----------------------------------------------------------------------------
#include <owl\owlpch.h>
#include <owl\framewin.h>
#include <owl\applicat.h>
#include "cctltest.h"
#include "colordlg.h"
class TTestApp : public TApplication {
public:
TTestApp() : TApplication("Custom Control Test") {}
private:
void InitMainWindow();
void CmColor();
TColor Color;
DECLARE_RESPONSE_TABLE(TTestApp);
};
DEFINE_RESPONSE_TABLE1(TTestApp, TApplication)
EV_COMMAND(CM_COLOR, CmColor),
END_RESPONSE_TABLE;
void
TTestApp::InitMainWindow()
{
MainWindow = new TFrameWindow(0, Name);
MainWindow->AssignMenu("Commands");
Color = 0;
}
void
TTestApp::CmColor()
{
char msg[128];
if (TColorDialog(MainWindow, Color).Execute() == IDOK)
wsprintf(msg,
"RGB intensities:\r\n\r\n Red: %d\r\n Green: %d\r\n Blue: %d",
Color.Red(), Color.Green(), Color.Blue());
else
strcpy(msg, "Cancelled");
MainWindow->MessageBox(msg, Name, MB_OK);
}
int
OwlMain(int /*argc*/, char* /*argv*/ [])
{
return TTestApp().Run();
}
@@ -0,0 +1,5 @@
//----------------------------------------------------------------------------
// ObjectWindows - (C) Copyright 1991, 1993 by Borland International
//----------------------------------------------------------------------------
#define CM_COLOR 201
@@ -0,0 +1,12 @@
//----------------------------------------------------------------------------
// ObjectWindows - (C) Copyright 1991, 1993 by Borland International
//----------------------------------------------------------------------------
#include "cctltest.h"
#include <owl\owlapp.rc> // default owl app icon
Commands MENU
BEGIN
MENUITEM "&Color", CM_COLOR
END
@@ -0,0 +1,6 @@
LIBRARY CDLGDLL
DESCRIPTION 'Color Dialog DLL'
EXETYPE WINDOWS
CODE PRELOAD MOVEABLE DISCARDABLE
DATA PRELOAD MOVEABLE SINGLE
HEAPSIZE 1024
@@ -0,0 +1,193 @@
//----------------------------------------------------------------------------
// ObjectWindows
// (C) Copyright 1991, 1994 by Borland International, All Rights Reserved
//
// This file implements a custom control (TColorControl) and a
// dialog box (TColorDialog) that uses them.
//----------------------------------------------------------------------------
#include <owl/owlpch.h>
#include <owl/applicat.h>
#include "colordlg.h"
#include <stdio.h>
#include <dos.h>
#include <mem.h>
#include <string.h>
#include <owl/scrollba.h>
#include <owl/dc.h>
const unsigned int CN_CLICKED = 1; // color control notifications
DEFINE_RESPONSE_TABLE1(TColorControl, TControl)
EV_WM_LBUTTONDOWN,
EV_WM_PAINT,
END_RESPONSE_TABLE;
// This is only included if we're building the DLL version of colordlg
//
#if defined(BI_APP_DLL)
// This exported function provides C (non-OWL) access to the dialog
//
extern "C" bool FAR PASCAL __export
GetColor(HWND parentHWnd, COLORREF& colorBuffer)
{
// Create an alias OWL application object when called from a non-OWL
// program so that TDialog is happy
//
TModule* appModule;
TApplication dummyApp("color dialog app", appModule);
TWindow parentAlias(parentHWnd, ::Module);
return TColorDialog(&parentAlias, (TColor&)colorBuffer).Execute() == IDOK;
}
#endif
TColorControl::TColorControl(TWindow* parent, int resId, TColor color)
:
TControl(parent, resId, ::Module),
Color(color)
{
DisableTransfer();
}
//
// Must use EvPaint since TControl assumes a pre-defined class control has a
// window's class that paints it. (see source\owl/control.cpp)
//
void
TColorControl::EvPaint()
{
TPaintDC dc(*this);
dc.FillRect(GetClientRect(), TBrush(Color));
}
void
TColorControl::SetColor(TColor color)
{
Color = color;
Invalidate();
}
uint
TColorControl::Transfer(void* buffer, TTransferDirection direction)
{
if (direction == tdGetData)
memcpy(buffer, &Color, sizeof Color);
else
if (direction == tdSetData)
memcpy(&Color, buffer, sizeof Color);
return sizeof Color;
}
//
// Notify parent of a CN_CLICKED event by sending a WM_COMMAND message
//
void
TColorControl::EvLButtonDown(uint, TPoint&)
{
Parent->SendNotification(Attr.Id, CN_CLICKED, HWindow);
}
//----------------------------------------------------------------------------
DEFINE_RESPONSE_TABLE1(TColorDialog, TDialog)
EV_CHILD_NOTIFY(ID_COLOR1,CN_CLICKED,ClickFmControl1),
EV_CHILD_NOTIFY(ID_COLOR2,CN_CLICKED,ClickFmControl2),
EV_CHILD_NOTIFY(ID_COLOR3,CN_CLICKED,ClickFmControl3),
EV_CHILD_NOTIFY(ID_COLOR4,CN_CLICKED,ClickFmControl4),
EV_CHILD_NOTIFY(ID_COLOR5,CN_CLICKED,ClickFmControl5),
EV_CHILD_NOTIFY(ID_COLOR6,CN_CLICKED,ClickFmControl6),
EV_CHILD_NOTIFY(ID_COLOR7,CN_CLICKED,ClickFmControl7),
EV_CHILD_NOTIFY(ID_COLOR8,CN_CLICKED,ClickFmControl8),
EV_SB_ENDSCROLL(ID_COLORBAR1,SetColorFmSlider),
EV_SB_ENDSCROLL(ID_COLORBAR2,SetColorFmSlider),
EV_SB_ENDSCROLL(ID_COLORBAR3,SetColorFmSlider),
END_RESPONSE_TABLE;
static void
DisableChildTransfer(TWindow* w, void*)
{
w->DisableTransfer();
}
TColorDialog::TColorDialog(TWindow* parent, TColor& color)
:
TDialog(parent, "COLORDIALOG", ::Module)
{
new TColorControl(this, ID_COLOR1, TColor(000, 000, 000));
new TColorControl(this, ID_COLOR2, TColor(255, 255, 255));
new TColorControl(this, ID_COLOR3, TColor(255, 000, 000));
new TColorControl(this, ID_COLOR4, TColor(000, 255, 000));
new TColorControl(this, ID_COLOR5, TColor(000, 000, 255));
new TColorControl(this, ID_COLOR6, TColor(000, 255, 255));
new TColorControl(this, ID_COLOR7, TColor(255, 000, 255));
new TColorControl(this, ID_COLOR8, TColor(255, 255, 000));
ColorBar1 = new TScrollBar(this, ID_COLORBAR1, ::Module);
ColorBar2 = new TScrollBar(this, ID_COLORBAR2, ::Module);
ColorBar3 = new TScrollBar(this, ID_COLORBAR3, ::Module);
ForEach(DisableChildTransfer);
SelColor = new TColorControl(this, ID_SELCOLOR, color);
SelColor->EnableTransfer();
TransferBuffer = &color;
}
// Handlers for each custom control
//
void TColorDialog::ClickFmControl1() {SetColorFmControl(ID_COLOR1);}
void TColorDialog::ClickFmControl2() {SetColorFmControl(ID_COLOR2);}
void TColorDialog::ClickFmControl3() {SetColorFmControl(ID_COLOR3);}
void TColorDialog::ClickFmControl4() {SetColorFmControl(ID_COLOR4);}
void TColorDialog::ClickFmControl5() {SetColorFmControl(ID_COLOR5);}
void TColorDialog::ClickFmControl6() {SetColorFmControl(ID_COLOR6);}
void TColorDialog::ClickFmControl7() {SetColorFmControl(ID_COLOR7);}
void TColorDialog::ClickFmControl8() {SetColorFmControl(ID_COLOR8);}
// Update the selected color control and bars with the chosen color
//
void
TColorDialog::SetColorFmControl(uint Id)
{
TColor color = ((TColorControl*)ChildWithId(Id))->GetColor();
SelColor->SetColor(color);
UpdateBars(color);
}
// Update the selected color control with the current slider values
//
void
TColorDialog::SetColorFmSlider()
{
SelColor->SetColor(TColor(ColorBar1->GetPosition(),
ColorBar2->GetPosition(), ColorBar3->GetPosition()));
}
void
TColorDialog::SetupWindow()
{
TDialog::SetupWindow();
ColorBar1->SetRange(0, 255);
ColorBar2->SetRange(0, 255);
ColorBar3->SetRange(0, 255);
}
void
TColorDialog::TransferData(TTransferDirection transferFlag)
{
TDialog::TransferData(transferFlag);
if (transferFlag == tdSetData)
UpdateBars(SelColor->GetColor());
}
void
TColorDialog::UpdateBars(TColor color)
{
ColorBar1->SetPosition(color.Red());
ColorBar2->SetPosition(color.Green());
ColorBar3->SetPosition(color.Blue());
}
@@ -0,0 +1,72 @@
//----------------------------------------------------------------------------
// ObjectWindows - (C) Copyright 1991, 1993 by Borland International
//----------------------------------------------------------------------------
#ifndef __COLORDLG_H
#define __COLORDLG_H
#include "colordlg.rh"
#include <owl\dialog.h>
#include <owl\control.h>
#include <owl\color.h>
#include <owl\scrollba.h>
#if defined(BUILDEXAMPLEDLL)
#define _EXAMPLECLASS __export
#elif defined (USEEXAMPLEDLL)
#define _EXAMPLECLASS __import
#else
#define _EXAMPLECLASS
#endif
class _EXAMPLECLASS TColorControl : public TControl {
public:
TColorControl(TWindow* parent, int resId, TColor color);
virtual void SetColor(TColor color);
TColor GetColor() const {return Color;}
private:
TColor Color;
char far* GetClassName() {return "ColorControl";}
UINT Transfer(void* buffer, TTransferDirection direction);
void EvPaint();
void EvLButtonDown(UINT, TPoint&);
void EvLButtonDblClk(UINT, TPoint&);
DECLARE_RESPONSE_TABLE(TColorControl);
};
class _EXAMPLECLASS TColorDialog : public TDialog {
public:
TColorDialog(TWindow* parent, TColor& color);
protected:
TScrollBar* ColorBar1;
TScrollBar* ColorBar2;
TScrollBar* ColorBar3;
TColorControl* SelColor;
void SetupWindow();
void TransferData(TTransferDirection direction);
virtual void UpdateBars(TColor color);
void ClickFmControl1();
void ClickFmControl2();
void ClickFmControl3();
void ClickFmControl4();
void ClickFmControl5();
void ClickFmControl6();
void ClickFmControl7();
void ClickFmControl8();
void SetColorFmControl(UINT Id);
void SetColorFmSlider();
DECLARE_RESPONSE_TABLE(TColorDialog);
};
#endif

@@ -0,0 +1,33 @@
//----------------------------------------------------------------------------
// ObjectWindows - (C) Copyright 1991, 1993 by Borland International
//----------------------------------------------------------------------------
#ifndef WORKSHOP_INVOKED
#include <windows.h>
#endif
#include "colordlg.rh"
COLORDIALOG DIALOG 30, 32, 217, 99
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Color Dialog"
FONT 8, "MS Sans Serif"
{
CONTROL "", ID_SELCOLOR, "ColorControl", 0 | WS_CHILD | WS_VISIBLE, 174, 9, 24, 24
GROUPBOX "", ID_BARGROUP, 6, 6, 150, 29, BS_GROUPBOX | WS_CHILD | WS_VISIBLE
SCROLLBAR ID_COLORBAR1, 33, 45, 120, 9, SBS_HORZ | SBS_LEFTALIGN | WS_CHILD | WS_VISIBLE | WS_TABSTOP
SCROLLBAR ID_COLORBAR2, 33, 60, 120, 9, SBS_HORZ | SBS_LEFTALIGN | WS_CHILD | WS_VISIBLE | WS_TABSTOP
SCROLLBAR ID_COLORBAR3, 33, 75, 120, 9, SBS_HORZ | SBS_LEFTALIGN | WS_CHILD | WS_VISIBLE | WS_TABSTOP
PUSHBUTTON "OK", IDOK, 162, 42, 48, 14
PUSHBUTTON "Cancel", IDCANCEL, 162, 63, 48, 14
RTEXT "Red", -1, 9, 45, 22, 11, SS_RIGHT | WS_CHILD | WS_VISIBLE
RTEXT "Green", -1, 9, 60, 22, 11, SS_RIGHT | WS_CHILD | WS_VISIBLE
RTEXT "Blue", -1, 9, 75, 22, 11, SS_RIGHT | WS_CHILD | WS_VISIBLE
GROUPBOX "", ID_COLORGROUP, 6, 36, 150, 56, BS_GROUPBOX | WS_CHILD | WS_VISIBLE
CONTROL "", ID_COLOR1, "ColorControl", 0 | WS_CHILD | WS_VISIBLE, 12, 15, 12, 12
CONTROL "", ID_COLOR2, "ColorControl", 0 | WS_CHILD | WS_VISIBLE, 30, 15, 12, 12
CONTROL "", ID_COLOR3, "ColorControl", 0 | WS_CHILD | WS_VISIBLE, 48, 15, 12, 12
CONTROL "", ID_COLOR4, "ColorControl", 0 | WS_CHILD | WS_VISIBLE, 66, 15, 12, 12
CONTROL "", ID_COLOR5, "ColorControl", 0 | WS_CHILD | WS_VISIBLE, 84, 15, 12, 12
CONTROL "", ID_COLOR6, "ColorControl", 0 | WS_CHILD | WS_VISIBLE, 102, 15, 12, 12
CONTROL "", ID_COLOR7, "ColorControl", 0 | WS_CHILD | WS_VISIBLE, 120, 15, 12, 12
CONTROL "", ID_COLOR8, "ColorControl", 0 | WS_CHILD | WS_VISIBLE, 138, 15, 12, 12
}
@@ -0,0 +1,18 @@
//----------------------------------------------------------------------------
// ObjectWindows - (C) Copyright 1991, 1993 by Borland International
//----------------------------------------------------------------------------
#define ID_COLORBAR1 101
#define ID_COLORBAR2 102
#define ID_COLORBAR3 103
#define ID_SELCOLOR 104
#define ID_COLOR1 108
#define ID_COLOR2 109
#define ID_COLOR3 110
#define ID_COLOR4 111
#define ID_COLOR5 112
#define ID_COLOR6 113
#define ID_COLOR7 114
#define ID_COLOR8 115
#define ID_BARGROUP 116
#define ID_COLORGROUP 117
@@ -0,0 +1,46 @@
#----------------------------------------------------------------------------
# ObjectWindows - (C) Copyright 1991, 1993 by Borland International
#
# Use: MODEL=m or MODEL=l or MODEL=f to build static library OWL example
# Default is MODEL=d, which builds DLL example with additional C calling EXE
#
#----------------------------------------------------------------------------
# This makefile can be used to build three different exes
# MAKE MODEL=m or l or f will build an cctltest.exe with the dialog
# static linked
#
# MAKE MODEL=d will build the color dialog in colordlg.dll and will build
# cctltest.exe and usecdll.exe.
# cctltest.exe is an owl program that calls the dll to display the dialog.
# usecdll2.exe is a C program that calls the dll to display the dialog
!if !$d(MODEL)
MODEL=d
!endif
!if $(MODEL)!=d
#This builds the static example
EXE = cctltest
OBJEXE = cctltest.obj colordlg.obj
RESEXE = cctltest.res colordlg.res
!else
#This builds the dll examples
EXEALL = cctltest.exe usecdll2.exe
EXERES = usecdll2 # pick this target to generate sample rule, then substitute
#These declarations are required in order to build 32bit versions of the example
#This define is used when using the DLL to generate _import declarations
CCFEXE = -DUSEEXAMPLEDLL
#This define is used when building the DLL to generate _export declarations
CCFDLL = -DBUILDEXAMPLEDLL
LIBEXE = colordlg.lib
DLLRES = colordlg
EXEMAKE= $(CCTLTEST) $(USECDLL2)
CCTLTEST = $(EXERULE:usecdll2=cctltest)
USECDLL2 = $(EXERULE:usecdll2.res=cctltest.res)
!endif
!include $(BCEXAMPLEDIR)\owlmake.gen
@@ -0,0 +1,94 @@
//----------------------------------------------------------------------------
// ObjectWindows - (C) Copyright 1991, 1993 by Borland International
//----------------------------------------------------------------------------
#include <owl\owlpch.h>
#include <windows.h>
#include <stdio.h>
#include <string.h>
#include "cctltest.h"
extern "C" BOOL FAR PASCAL
GetColor(HWND parentHandle, COLORREF& colorBuffer);
char appName[] = "DLL Test (non-OWL app)";
LRESULT
doProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message) {
case WM_DESTROY:
PostQuitMessage(0);
break;
case WM_COMMAND:
if (LOWORD(lParam) == 0 && wParam == CM_COLOR) {
COLORREF color = RGB(0x00, 0x00, 0x00);
char msgStr[128];
if (GetColor(hWnd, color)) {
sprintf(msgStr,
"RGB intensities:\r\n\r\n Red: %d\r\n Green: %d\r\n Blue: %d",
GetRValue(color), GetGValue(color), GetBValue(color));
} else
strcpy(msgStr, "Cancelled");
MessageBox(hWnd, msgStr, appName, MB_OK);
} else
return DefWindowProc(hWnd, message, wParam, lParam);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
return 0;
}
#if defined(__WIN32__)
LRESULT
FAR PASCAL _stdcall
WndProc(HWND h, UINT msg, WPARAM wParam, LPARAM lParam)
{
return doProc(h, msg, wParam, lParam);
}
#else
LRESULT
FAR PASCAL __export
WndProc(HWND h, UINT msg, WPARAM wParam, LPARAM lParam)
{
return doProc(h, msg, wParam, lParam);
}
#endif
int PASCAL
WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR, int cmdShow)
{
if (!hPrevInstance) {
WNDCLASS wndClass;
wndClass.style = CS_HREDRAW | CS_VREDRAW;
wndClass.lpfnWndProc = WndProc;
wndClass.cbClsExtra = 0;
wndClass.cbWndExtra = 0;
wndClass.hInstance = hInstance;
wndClass.hIcon = LoadIcon(0, IDI_APPLICATION);
wndClass.hCursor = LoadCursor(0, IDC_ARROW);
wndClass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
wndClass.lpszMenuName = "COMMANDS";
wndClass.lpszClassName = appName;
if (!RegisterClass(&wndClass))
return FALSE;
}
HWND hWnd = CreateWindow(appName, appName, WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, 0, 0, hInstance, 0);
ShowWindow(hWnd, cmdShow);
MSG msg;
while (GetMessage(&msg, 0, 0, 0)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}
@@ -0,0 +1,5 @@
//----------------------------------------------------------------------------
// ObjectWindows - (C) Copyright 1991, 1993 by Borland International
//----------------------------------------------------------------------------
#define CM_COLOR 101
@@ -0,0 +1,515 @@
//----------------------------------------------------------------------------
// ObjectWindows - (C) Copyright 1991, 1993 by Borland International
//----------------------------------------------------------------------------
#include <owl\owlpch.h>
#include <owl\applicat.h>
#include <owl\framewin.h>
#include <owl\static.h>
#include <owl\combobox.h>
#include <owl\inputdia.h>
#include <owl\validate.h>
#include "combobxx.rh"
const WORD ID_CB_BASE = 200;
const WORD ID_SIMPLE_COMBOBOX = ID_CB_BASE;
const WORD ID_DROPDOWN_COMBOBOX = ID_CB_BASE + 1;
const WORD ID_DROPDOWNLIST_COMBOBOX = ID_CB_BASE + 2;
class TComboBoxWindow : public TFrameWindow {
public:
TComboBoxWindow(const char* title);
// override method defined by TFrameWindow
//
void Paint(TDC&, BOOL, TRect&);
// message response functions
//
void EvCBNSelChange();
void CmSimple(); // create simple combobox.
void CmDropDown(); // create drop-down combobox.
void CmDropDownList(); // create drop-down-list combobox.
void CmAddString(); // add string to listbox of combobox.
void CmAddStringAt(); // add string at index position.
void CmFindString(); // goto/display index of given string.
void CmFindStringAt(); // goto index, display string.
void CmDeleteString(); // delete string.
void CmDeleteStringAt(); // delete string at index.
void CmClear(); // clear combobox.
void CmShowList(); // show listbox part.
void CmHideList(); // hide listbox part.
void CeSimple(TCommandEnabler& commandHandler);
void CeDropDown(TCommandEnabler& commandHandler);
void CeDropDownList(TCommandEnabler& commandHandler);
void CeNotSimple(TCommandEnabler& commandHandler);
void CeAny(TCommandEnabler& commandHandler);
private:
TComboBox* ComboBox; // combobox.
TStatic* CurSelOfListBox; // text of selected string.
TStatic* CurSelIndexOfListBox; // index of selected string.
TStatic* CurEditString; // string of edit control.
TStatic* SelStringLength; // length of selected string.
TStatic* EditStringLength; // length of edit string.
UINT WhichComboBox; // current combobox.
static const int TextLen;
void ResetTextFields(); // reset text fields to blanks.
void UpdateTextFields(); // updates from combobox.
int InputNumber(char* pmpt, char* s); // get number from user.
int InputString(char* pmpt, char* s); // get string from user.
// get string and number.
int InputStringAndNumber(char* pmpt, char* s, int& n);
DECLARE_RESPONSE_TABLE(TComboBoxWindow);
};
DEFINE_RESPONSE_TABLE1(TComboBoxWindow, TFrameWindow)
EV_CBN_SELCHANGE(ID_SIMPLE_COMBOBOX, EvCBNSelChange),
EV_CBN_SELCHANGE(ID_DROPDOWN_COMBOBOX, EvCBNSelChange),
EV_CBN_SELCHANGE(ID_DROPDOWNLIST_COMBOBOX, EvCBNSelChange),
EV_COMMAND(CM_SIMPLE, CmSimple),
EV_COMMAND(CM_DROPDOWN, CmDropDown),
EV_COMMAND(CM_DROPDOWN_LIST, CmDropDownList),
EV_COMMAND(CM_ADD_STRING, CmAddString),
EV_COMMAND(CM_ADD_STRING_AT, CmAddStringAt),
EV_COMMAND(CM_FIND_STRING, CmFindString),
EV_COMMAND(CM_FIND_STRING_AT, CmFindStringAt),
EV_COMMAND(CM_DELETE_STRING, CmDeleteString),
EV_COMMAND(CM_DELETE_STRING_AT, CmDeleteStringAt),
EV_COMMAND(CM_CLEAR, CmClear),
EV_COMMAND(CM_SHOW_LIST, CmShowList),
EV_COMMAND(CM_HIDE_LIST, CmHideList),
EV_COMMAND_ENABLE(CM_SIMPLE, CeSimple),
EV_COMMAND_ENABLE(CM_DROPDOWN, CeDropDown),
EV_COMMAND_ENABLE(CM_DROPDOWN_LIST, CeDropDownList),
EV_COMMAND_ENABLE(CM_ADD_STRING, CeAny),
EV_COMMAND_ENABLE(CM_ADD_STRING_AT, CeAny),
EV_COMMAND_ENABLE(CM_FIND_STRING, CeAny),
EV_COMMAND_ENABLE(CM_FIND_STRING_AT, CeAny),
EV_COMMAND_ENABLE(CM_DELETE_STRING, CeAny),
EV_COMMAND_ENABLE(CM_DELETE_STRING_AT,CeAny),
EV_COMMAND_ENABLE(CM_CLEAR, CeAny),
EV_COMMAND_ENABLE(CM_SHOW_LIST, CeNotSimple),
EV_COMMAND_ENABLE(CM_HIDE_LIST, CeNotSimple),
END_RESPONSE_TABLE;
const int TComboBoxWindow::TextLen = 31;
TComboBoxWindow::TComboBoxWindow(const char* title)
: TFrameWindow(0, title), TWindow(0, title)
{
ComboBox = 0;
WhichComboBox = 0;
AssignMenu("COMBOBOX_MENU");
// setup static text area.
new TStatic(this, -1, "Current selection:", 200, 30, 122, 18, 18);
CurSelOfListBox = new TStatic(this, -1, " ", 392, 30, 158, 18, 25);
new TStatic(this, -1, "Index of current selection:", 200, 52, 176, 18, 28);
CurSelIndexOfListBox = new TStatic(this, -1, " ", 392, 52, 158, 18, 25);
new TStatic(this, -1, "Length of current selection:", 200, 76, 184, 18, 30);
SelStringLength = new TStatic(this, -1, " ", 392, 76, 158, 18, 25);
new TStatic(this, -1, "Edit control string:", 200, 103, 124, 18, 30);
CurEditString= new TStatic(this, -1, " ", 392, 103, 158, 18, 25);
new TStatic(this, -1, "Length of edit control string:", 200, 125, 186, 18, 30);
EditStringLength = new TStatic(this, -1, " ", 392, 125, 158, 18, 25);
}
//
// make sure comboboxes are not dropped, if they are, they'll be left floating
//
void
TComboBoxWindow::Paint(TDC&, BOOL, TRect&)
{
if (ComboBox)
ComboBox->HideList();
}
//
// A selection of the listbox part of the combobox has taken place.
// Update text info.
//
void
TComboBoxWindow::EvCBNSelChange()
{
UpdateTextFields();
}
//
// 'ComboBox|Simple' menu item. Create simple combobox and fill it with some
// strings.
//
void
TComboBoxWindow::CmSimple()
{
if (ComboBox) {
ComboBox->Destroy();
delete ComboBox;
}
ComboBox = new TComboBox(this, ID_SIMPLE_COMBOBOX, 10, 30, 150, 150,
CBS_SIMPLE, 25);
ComboBox->Create();
ComboBox->SetFocus();
ComboBox->AddString("abc");
ComboBox->AddString("DEFG");
ComboBox->AddString("12345");
ComboBox->AddString("OWL");
WhichComboBox = ID_SIMPLE_COMBOBOX;
ResetTextFields();
UpdateTextFields();
}
//
// 'ComboBox|Drop Down' menu item. Create drop down combobox and fill it some
// some strings.
//
void
TComboBoxWindow::CmDropDown()
{
if (ComboBox) {
ComboBox->Destroy();
delete ComboBox;
}
ComboBox = new TComboBox(this, ID_DROPDOWN_COMBOBOX, 10, 30, 150, 150,
CBS_DROPDOWN, 25);
ComboBox->Create();
ComboBox->SetFocus();
ComboBox->AddString("Jack");
ComboBox->AddString("Denice");
ComboBox->AddString("If then else");
ComboBox->AddString("a");
ComboBox->AddString("99");
ComboBox->AddString("42");
ComboBox->AddString("Help!");
ComboBox->AddString("windows");
WhichComboBox = ID_DROPDOWN_COMBOBOX;
ResetTextFields();
UpdateTextFields();
}
//
// 'ComboBox|Drop Down List' menu item. Create drop down list combobox and fill
// it with some strings.
//
void
TComboBoxWindow::CmDropDownList()
{
if (ComboBox) {
ComboBox->Destroy();
delete ComboBox;
}
ComboBox = new TComboBox(this, ID_DROPDOWNLIST_COMBOBOX, 10, 30, 150, 150,
CBS_DROPDOWNLIST, 25);
ComboBox->Create();
ComboBox->SetFocus();
ComboBox->AddString("A B C D");
ComboBox->AddString("[^abc]");
ComboBox->AddString("1234567890");
ComboBox->AddString("C++");
ComboBox->AddString("Just a string");
ComboBox->AddString("and another!");
WhichComboBox = ID_DROPDOWNLIST_COMBOBOX;
ResetTextFields();
UpdateTextFields();
}
//
// Add a string to the listbox part of the combobox.
//
void
TComboBoxWindow::CmAddString()
{
char buf[TextLen] = "";
if (InputString("Enter string:", buf)) {
ComboBox->AddString(buf);
UpdateTextFields();
}
}
//
// Insert a string at a given index in the listbox part of the combobox.
//
void
TComboBoxWindow::CmAddStringAt()
{
char buf[TextLen] = "";
int index;
if (InputStringAndNumber("Enter string:", buf, index)) {
if (ComboBox->InsertString(buf, index) != CB_ERR)
UpdateTextFields();
else
MessageBox("Index out of range", "Error", MB_OK);
}
}
//
// Find string. Tell combobox to select string at given index.
// Update text fields.
//
void
TComboBoxWindow::CmFindString()
{
char buf[TextLen] = "";
int index;
if (InputString("Enter string:", buf)) {
if ((index = ComboBox->FindString(buf, 0)) != CB_ERR) {
ComboBox->SendMessage(CB_SETCURSEL, index, 0);
UpdateTextFields();
}
else
MessageBox("String not found", "Error", MB_OK);
}
}
//
// Find string. Tell combobox to select string at given index.
// Update text fields. Assumes index input is correct, else atoi()
// will return 0 and will be used to select the first string.
//
void
TComboBoxWindow::CmFindStringAt()
{
char buf[TextLen] = "";
int index;
if (InputNumber("Enter number:", buf)) {
index = atoi(buf);
if (ComboBox->GetString(buf, index) != CB_ERR) {
ComboBox->SendMessage(CB_SETCURSEL, index, 0);
UpdateTextFields();
}
else
MessageBox("Index out of range", "Error", MB_OK);
}
}
//
// Delete string. Delete string input by user.
//
void
TComboBoxWindow::CmDeleteString()
{
char buf[TextLen] = "";
int index;
if (InputString( "Enter string:", buf)) {
if ((index = ComboBox->FindString(buf, 0)) != CB_ERR) {
ComboBox->DeleteString(index);
UpdateTextFields();
} else
MessageBox("String not found", "Error", MB_OK);
}
}
//
// Delete string. Delete string at given index.
//
void
TComboBoxWindow::CmDeleteStringAt()
{
char buf[TextLen] = "";
int index;
if (InputNumber("Enter number:", buf)) {
index = atoi(buf);
if (ComboBox->GetString(buf, index) != CB_ERR) {
ComboBox->DeleteString(index);
UpdateTextFields();
} else
MessageBox("Index out of range", "Error", MB_OK);
}
}
//
// Clear. Clear edit control and listbox part of combobox.
//
void
TComboBoxWindow::CmClear()
{
ComboBox->Clear();
ComboBox->ClearList();
ResetTextFields();
}
//
// Show listbox part of combobox.
//
void
TComboBoxWindow::CmShowList()
{
ComboBox->ShowList();
}
//
// Hide listbox part of combobox.
//
void
TComboBoxWindow::CmHideList()
{
ComboBox->HideList();
}
//
// Command enablers...
//
// Handle popup menus. Grey out certain menu items depending on
// whether a combobox has been created or menu item is inappropriate
// for current type of combobox.
//
//
void
TComboBoxWindow::CeSimple(TCommandEnabler& ce)
{
ce.Enable(WhichComboBox != ID_SIMPLE_COMBOBOX || !ComboBox);
}
void
TComboBoxWindow::CeDropDown(TCommandEnabler& ce)
{
ce.Enable(WhichComboBox != ID_DROPDOWN_COMBOBOX || !ComboBox);
}
void
TComboBoxWindow::CeDropDownList(TCommandEnabler& ce)
{
ce.Enable(WhichComboBox != ID_DROPDOWNLIST_COMBOBOX || !ComboBox);
}
void
TComboBoxWindow::CeNotSimple(TCommandEnabler& ce)
{
ce.Enable(WhichComboBox != ID_SIMPLE_COMBOBOX && ComboBox);
}
void
TComboBoxWindow::CeAny(TCommandEnabler& ce)
{
ce.Enable(ComboBox != 0);
}
//
// Updates text fields that reflex the combobox's state.
//
void
TComboBoxWindow::UpdateTextFields()
{
char buf[TextLen] = "";
int index = ComboBox->GetSelIndex();
int strLen;
if (index != -1) { // is something selected?
ComboBox->GetString(buf, index);
strLen = ComboBox->GetStringLen(index);
CurSelOfListBox->SetText(buf);
itoa(strLen, buf, 10);
SelStringLength->SetText(buf);
itoa(index, buf, 10);
CurSelIndexOfListBox->SetText(buf);
ComboBox->GetText(buf, TextLen - 1);
strLen = ComboBox->GetTextLen();
CurEditString->SetText(buf);
if (WhichComboBox == ID_DROPDOWNLIST_COMBOBOX)
strLen = ComboBox->GetStringLen(ComboBox->GetSelIndex());
itoa(strLen, buf, 10);
EditStringLength->SetText(buf);
}
else
ResetTextFields();
}
//
// Reset text fields to blanks.
//
void
TComboBoxWindow::ResetTextFields()
{
CurSelOfListBox->SetText(" ");
SelStringLength->SetText(" ");
CurSelIndexOfListBox->SetText(" ");
CurEditString->SetText(" ");
EditStringLength->SetText(" ");
}
//
// Get string from user. Return 1 if successful, 0 otherwise.
// assumes string length of TextLen - 1.
//
int
TComboBoxWindow::InputString(char* pmpt, char* s)
{
return TInputDialog(this, "String", pmpt, s, TextLen - 1).Execute() == IDOK;
}
int
TComboBoxWindow::InputNumber(char* pmpt, char* s)
{
return TInputDialog(this, "String", pmpt, s, TextLen-1, 0,
new TFilterValidator("0-9")).Execute() == IDOK;
}
//
// Get string and number (index) from user. Return 1 if successful, 0
// otherwise. Assumes string length of TextLen - 1.
//
int
TComboBoxWindow::InputStringAndNumber(char* pmpt, char* s, int& n)
{
char sbuf[TextLen] = "";
char nbuf[TextLen] = "";
TInputDialog getStr(this, "String", pmpt, sbuf, TextLen - 1);
// This input dialog has a validator that only accepts digits
//
TInputDialog getNum(this, "String", "Enter number:", nbuf, TextLen - 1,
0,new TFilterValidator("0-9"));
if (getStr.Execute() == IDOK &&
getNum.Execute() == IDOK) {
strcpy(s, sbuf);
n = atoi(nbuf);
return 1;
} else
return 0;
}
//----------------------------------------------------------------------------
class TComboBoxApp : public TApplication {
public:
void InitMainWindow();
};
void
TComboBoxApp::InitMainWindow()
{
MainWindow = new TComboBoxWindow("ComboBox Example");
}
int
OwlMain(int /*argc*/, char* /*argv*/ [])
{
return TComboBoxApp().Run();
}
@@ -0,0 +1,52 @@
//----------------------------------------------------------------------------
// ObjectWindows - (C) Copyright 1991, 1993 by Borland International
//----------------------------------------------------------------------------
#ifndef WORKSHOP_INVOKED
#include <windows.h>
#endif
#include <owl\owlapp.rc> // default owl app icon
#include <owl\mdi.rh>
#include <owl\inputdia.rh>
#include <owl\inputdia.rc>
#include <owl\window.rh>
#include "combobxx.rh"
COMBOBOX_MENU MENU
BEGIN
POPUP "&ComboBox"
BEGIN
MENUITEM "&Simple", CM_SIMPLE
MENUITEM "Drop &Down", CM_DROPDOWN
MENUITEM "Drop Down &List", CM_DROPDOWN_LIST
MENUITEM SEPARATOR
MENUITEM "&Exit", CM_EXIT
END
POPUP "&Add"
BEGIN
MENUITEM "Add &String", CM_ADD_STRING
MENUITEM "Add String &At", CM_ADD_STRING_AT
END
POPUP "&Search"
BEGIN
MENUITEM "Find &String", CM_FIND_STRING
MENUITEM "Find String &At", CM_FIND_STRING_AT
END
POPUP "&Delete"
BEGIN
MENUITEM "Delete &String", CM_DELETE_STRING
MENUITEM "Delete &At", CM_DELETE_STRING_AT
END
POPUP "&Other"
BEGIN
MENUITEM "&Clear", CM_CLEAR
MENUITEM "&Show", CM_SHOW_LIST
MENUITEM "&Hide", CM_HIDE_LIST
END
END
@@ -0,0 +1,19 @@
//----------------------------------------------------------------------------
// ObjectWindows - (C) Copyright 1991, 1993 by Borland International
//----------------------------------------------------------------------------
// Menu item ids.
#define CM_SIMPLE 101
#define CM_DROPDOWN 102
#define CM_DROPDOWN_LIST 103
#define CM_ADD_STRING 104
#define CM_ADD_STRING_AT 105
#define CM_FIND_STRING 107
#define CM_FIND_STRING_AT 108
#define CM_DELETE_STRING 109
#define CM_DELETE_STRING_AT 110
#define CM_CLEAR 111
#define CM_SHOW_LIST 112
#define CM_HIDE_LIST 113
@@ -0,0 +1,8 @@
#----------------------------------------------------------------------------
# ObjectWindows - (C) Copyright 1991, 1993 by Borland International
#----------------------------------------------------------------------------
EXERES=combobxx
MODELS=mldf
!include $(BCEXAMPLEDIR)\owlmake.gen
Binary file not shown.
@@ -0,0 +1,194 @@
//----------------------------------------------------------------------------
// ObjectWindows - (C) Copyright 1991, 1993 by Borland International
//
// This program has example code that uses the Common Dialog classes
// in Owl
//
// The main window will have menu selections for opening a file, changing
// the font and changing the color used for the selected font. When a file
// is selected the name will be displayed on the client area of the window.
//
//----------------------------------------------------------------------------
#include <owl\owlpch.h>
#include <owl\applicat.h>
#include <owl\framewin.h>
#include <owl\dialog.h>
#include <owl\dc.h>
#include <owl\chooseco.h>
#include <owl\choosefo.h>
#include <owl\opensave.h>
#include <stdio.h>
#include <string.h>
#include "commdlgx.rh"
class TCommDlgWnd : public TFrameWindow {
public:
TCommDlgWnd(TWindow*, const char*);
~TCommDlgWnd();
void Paint(TDC&, BOOL, TRect&);
void CmFileOpen();
void CmColor();
void CmFont();
void CmHelpAbout();
TColor Color;
TFont* Font;
TOpenSaveDialog::TData FilenameData;
TChooseFontDialog::TData FontData;
void EvSize(UINT sizeType, TSize& size);
DECLARE_RESPONSE_TABLE(TCommDlgWnd);
};
DEFINE_RESPONSE_TABLE1(TCommDlgWnd, TFrameWindow)
EV_WM_SIZE,
EV_COMMAND(CM_FILEOPEN, CmFileOpen),
EV_COMMAND(CM_COLOR, CmColor),
EV_COMMAND(CM_FONT, CmFont),
EV_COMMAND(CM_HELPABOUT, CmHelpAbout),
END_RESPONSE_TABLE;
//
// Note the initialization method of the filter string. The TOpenSave::TData
// class expects to find a filter string that has a '|' terminator between
// strings and an extra '|' that terminates the entire filter data set.
// The '|' characters are translated to 0's within TData's copy of the string.
// Using '|'s allows the filter to be loaded from a resource & copied using
// strcpy.
//
TCommDlgWnd::TCommDlgWnd(TWindow* parent, const char* title)
: TFrameWindow(parent, title),
TWindow(parent, title),
FilenameData(OFN_FILEMUSTEXIST|OFN_HIDEREADONLY|OFN_PATHMUSTEXIST,
"All Files (*.*)|*.*|Text Files (*.txt)|*.txt|",
0, "", "*")
{
AssignMenu("CMDLGAPMENU"); // Set up the menu
Color = TColor::Black; // Use black as the default color
Font = 0; // Empty the handle to the font
}
TCommDlgWnd::~TCommDlgWnd()
{
delete Font;
}
//
// We need to invalidate the entire area, not just the clip area so that
// paint gets called correctly
//
void
TCommDlgWnd::EvSize(UINT sizeType, TSize& size)
{
Invalidate();
TFrameWindow::EvSize(sizeType,size);
}
//
// Display the file name using the selected font in the selected color.
//
void
TCommDlgWnd::Paint(TDC& paintDC, BOOL, TRect&)
{
paintDC.SetTextColor(Color);
paintDC.SetBkColor(::GetSysColor(COLOR_WINDOW));
if (Font)
paintDC.SelectObject(*Font);
paintDC.DrawText(FilenameData.FileName, strlen(FilenameData.FileName),
GetClientRect(), DT_CENTER | DT_WORDBREAK);
}
//
//
//
void
TCommDlgWnd::CmFileOpen()
{
// If the call to Execute fails you can examine the Error member
// of FilenameData to determine the type of error that occured.
//
if (TFileOpenDialog(this, FilenameData).Execute() != IDOK) {
if (FilenameData.Error != 0) { // 0 value means user selected Cancel
char msg[50];
sprintf(msg, "GetOpenFileName returned Error #%ld", FilenameData.Error);
MessageBox(msg, "WARNING", MB_OK|MB_ICONSTOP);
}
}
Invalidate(); // Repaint to display the new name
}
//
//
void
TCommDlgWnd::CmColor()
{
TChooseColorDialog::TData choose;
static TColor custColors[16] = {
0x010101L, 0x101010L, 0x202020L, 0x303030L,
0x404040L, 0x505050L, 0x606060L, 0x707070L,
0x808080L, 0x909090L, 0xA0A0A0L, 0xB0B0B0L,
0xC0C0C0L, 0xD0D0D0L, 0xE0E0E0L, 0xF0F0F0L
};
choose.Flags = CC_RGBINIT;
choose.Color = Color;
choose.CustColors = custColors;
if (TChooseColorDialog(this, choose).Execute() == IDOK) {
Color = choose.Color;
}
Invalidate();
}
//
//
//
void
TCommDlgWnd::CmFont()
{
if (Font) { // FontData contains previous selections
FontData.Flags |= CF_INITTOLOGFONTSTRUCT;
FontData.Color = Color;
} else {
FontData.DC = 0;
FontData.Flags = CF_EFFECTS | CF_FORCEFONTEXIST | CF_SCREENFONTS;
FontData.Color = Color; // Color and font dialogs use the same color
FontData.Style = 0;
FontData.FontType = SCREEN_FONTTYPE;
FontData.SizeMin = 0;
FontData.SizeMax = 0;
}
if (TChooseFontDialog(this, FontData).Execute() == IDOK) {
delete Font;
Color = FontData.Color;
Font = new TFont(&FontData.LogFont);
}
Invalidate();
}
void
TCommDlgWnd::CmHelpAbout()
{
MessageBox("Common Dialog Example\nWritten using ObjectWindows\n"
"Copyright (c) 1991, 1993 Borland",
"About Common Dialog Example",
MB_OK);
}
class TCommDlgApp : public TApplication {
public:
TCommDlgApp() : TApplication() {}
void InitMainWindow() {
MainWindow = new TCommDlgWnd(0, "Common Dialog Example");
EnableCtl3d();
}
};
int
OwlMain(int /*argc*/, char* /*argv*/ [])
{
return TCommDlgApp().Run();
}
@@ -0,0 +1,26 @@
//----------------------------------------------------------------------------
// ObjectWindows - (C) Copyright 1991, 1993 by Borland International
//----------------------------------------------------------------------------
#ifndef WORKSHOP_INVOKED
#include <windows.h>
#endif
#include "commdlgx.rh"
#include <owl\owlapp.rc> // default owl app icon
CMDLGAPMENU MENU
BEGIN
POPUP "&File"
BEGIN
MENUITEM "E&xit", CM_EXIT
END
POPUP "&Text"
BEGIN
MENUITEM "&String...", CM_FILEOPEN
MENUITEM "&Color...", CM_COLOR
MENUITEM "&Font...", CM_FONT
END
POPUP "\a&Help"
BEGIN
MENUITEM "&About...", CM_HELPABOUT
END
END
@@ -0,0 +1,10 @@
//----------------------------------------------------------------------------
// ObjectWindows - (C) Copyright 1991, 1993 by Borland International
//----------------------------------------------------------------------------
#include <owl\window.rh>
#define CM_FILEOPEN 0x100
#define CM_COLOR 0x101
#define CM_FONT 0x102
#define CM_HELPABOUT 0x200
@@ -0,0 +1,7 @@
#----------------------------------------------------------------------------
# ObjectWindows - (C) Copyright 1991, 1993 by Borland International
#----------------------------------------------------------------------------
EXERES=commdlgx
MODELS=mldf
!include $(BCEXAMPLEDIR)\owlmake.gen
@@ -0,0 +1,157 @@
//----------------------------------------------------------------------------
// ObjectWindows - (C) Copyright 1991, 1993 by Borland International
//----------------------------------------------------------------------------
#include <owl\owlpch.h>
#include <owl\applicat.h>
#include <owl\framewin.h>
#include <owl\dc.h>
#include <cstring.h>
#include "dllhello.h"
#include "calldll.h"
static TModule ResourceDll("resource.dll"); // DLL to be loaded.
class TTestWindow : public TWindow {
public:
TTestWindow() : TWindow(0, 0, ::Module) {} // associate with this module
void SetupWindow();
void CleanupWindow();
void CmCreate(); // Call into a DLL to create a window.
void CmRString(); // Load a String resource from a DLL.
void CmRCursor(); // Load a Cursor resource from a DLL.
void CmRIcon(); // Load a Icon resource from a DLL.
void CmRBitmap(); // Load a Bitmap resource from a DLL.
void Paint(TDC& dc, BOOL erase, TRect& rect);
private:
HICON SampleIcon; // Handle to Icon.
HBITMAP SampleBitmap; // Handle to Bitmap.
DECLARE_RESPONSE_TABLE(TTestWindow);
};
DEFINE_RESPONSE_TABLE1(TTestWindow, TWindow)
EV_COMMAND(CM_CREATE, CmCreate),
EV_COMMAND(CM_RSTRING, CmRString),
EV_COMMAND(CM_RCURSOR, CmRCursor),
EV_COMMAND(CM_RICON, CmRIcon),
EV_COMMAND(CM_RBITMAP, CmRBitmap),
END_RESPONSE_TABLE;
void
TTestWindow::SetupWindow()
{
TWindow::SetupWindow();
SampleIcon = 0;
SampleBitmap = 0;
}
void
TTestWindow::CleanupWindow()
{
if (SampleIcon)
::DestroyIcon(SampleIcon); // Cleanup resources.
if (SampleBitmap)
::DeleteObject(SampleBitmap);
TWindow::CleanupWindow();
}
//
// Call into DLL to create window.
//
void
TTestWindow::CmCreate()
{
CreateDLLWindow(HWindow);
}
//
// Load a String from resource DLL. Display it in a message box.
//
void
TTestWindow::CmRString()
{
const RESLEN=30;
char far* str = new char[RESLEN];
ResourceDll.LoadString(ID_STRING, str, RESLEN);
MessageBox(str, "The String Is!", MB_OK);
delete[] str;
}
//
// Load and set Cursor for window.
//
void
TTestWindow::CmRCursor()
{
SetCursor(&ResourceDll, ID_CURSOR);
}
//
// Load and display cursor on window.
//
void
TTestWindow::CmRIcon()
{
char temp[5];
string resIdAsString;
itoa(ID_ICON, temp, 10);
resIdAsString = "#";
resIdAsString += temp;
SampleIcon = ResourceDll.LoadIcon(resIdAsString.c_str());
CHECK(SampleIcon);
Invalidate();
}
//
// Load and display Bitmap on window.
//
void
TTestWindow::CmRBitmap()
{
SampleBitmap = ResourceDll.LoadBitmap(ID_BITMAP);
CHECK(SampleBitmap);
Invalidate();
}
//
// Will display Icon and Bitmap resource if they have been loaded.
//
void
TTestWindow::Paint(TDC& dc, BOOL, TRect&)
{
if (SampleIcon)
dc.DrawIcon(5, 5, TIcon(SampleIcon));
if (SampleBitmap) {
TMemoryDC memDC;
memDC.SelectObject(TBitmap(SampleBitmap));
dc.BitBlt(50, 5, 64, 64, memDC, 0, 0 );
}
}
//----------------------------------------------------------------------------
class TCallDllApp : public TApplication {
public:
void InitMainWindow();
};
void
TCallDllApp::InitMainWindow()
{
MainWindow = new TFrameWindow(0, "CallDll", new TTestWindow);
MainWindow->AssignMenu("COMMANDS");
}
int
OwlMain(int /*argc*/, char* /*argv*/ [])
{
return TCallDllApp().Run();
}
@@ -0,0 +1,15 @@
//----------------------------------------------------------------------------
// ObjectWindows - (C) Copyright 1991, 1993 by Borland International
//----------------------------------------------------------------------------
#define CM_CREATE 101
#define CM_RSTRING 102
#define CM_RCURSOR 103
#define CM_RICON 104
#define CM_RBITMAP 105
#define ID_STRING 300
#define ID_ICON 301
#define ID_CURSOR 302
#define ID_BITMAP 303
@@ -0,0 +1,20 @@
//----------------------------------------------------------------------------
// ObjectWindows - (C) Copyright 1991, 1993 by Borland International
//----------------------------------------------------------------------------
#include "calldll.h"
#include <owl\owlapp.rc> // default owl app icon
COMMANDS MENU
BEGIN
MENUITEM "&Create", CM_CREATE
POPUP "&Resource"
BEGIN
MENUITEM "&String", CM_RSTRING
MENUITEM "&Cursor", CM_RCURSOR
MENUITEM "&Icon", CM_RICON
MENUITEM "&Bitmap", CM_RBITMAP
END
END
@@ -0,0 +1,22 @@
//----------------------------------------------------------------------------
// ObjectWindows - (C) Copyright 1991, 1993 by Borland International
//----------------------------------------------------------------------------
#include <owl\owlpch.h>
#include <owl\applicat.h>
#include <owl\window.h>
#include "dllhello.h"
#include <stdlib.h>
BOOL far _export
CreateDLLWindow(HWND parentHWnd)
{
TWindow* parentAlias = GetWindowPtr(parentHWnd); // check if an OWL window
if (!parentAlias)
parentAlias = new TWindow(parentHWnd, ::Module);
TWindow* window = new TWindow(parentAlias, "Hello from a DLL!");
window->Attr.Style |= WS_POPUPWINDOW | WS_CAPTION | WS_THICKFRAME
| WS_MINIMIZEBOX | WS_MAXIMIZEBOX;
window->Attr.X = 100; window->Attr.Y = 100;
window->Attr.W = 300; window->Attr.H = 300;
return window->Create();
}
@@ -0,0 +1,6 @@
LIBRARY DLLHELLO
DESCRIPTION 'DLL Hello'
EXETYPE WINDOWS
CODE PRELOAD MOVEABLE DISCARDABLE
DATA PRELOAD MOVEABLE SINGLE
HEAPSIZE 1024
@@ -0,0 +1,5 @@
//----------------------------------------------------------------------------
// ObjectWindows - (C) Copyright 1991, 1993 by Borland International
//----------------------------------------------------------------------------
extern "C" { BOOL far CreateDLLWindow(HWND ParentHWnd); }
@@ -0,0 +1,15 @@
#----------------------------------------------------------------------------
# ObjectWindows - (C) Copyright 1991, 1993 by Borland International
#----------------------------------------------------------------------------
MODELS = d # force use of DLL
EXERES = calldll
LIBEXE = dllhello.lib
DLLRES = dllhello # use this target for generating DLLRULE
DLLALL = dllhello.dll resource.dll
DLLMAKE= $(DLLHELLO) $(RESOURCE)
DLLHELLO = $(DLLRULE:dllhello.res=) # no resource for this DLL
TEMPRULE = $(DLLRULE:dllhello=resource) # change name for the other DLL
RESOURCE = $(TEMPRULE:resource.obj=) # no code module used for resource DLL
!include $(BCEXAMPLEDIR)\owlmake.gen
@@ -0,0 +1,5 @@
//----------------------------------------------------------------------------
// ObjectWindows - (C) Copyright 1991, 1993 by Borland International
//----------------------------------------------------------------------------
// File no longer required. No code required for resource-only DLL.
@@ -0,0 +1,6 @@
LIBRARY RESOURCE
DESCRIPTION 'Resource only dll'
EXETYPE WINDOWS
CODE PRELOAD MOVEABLE DISCARDABLE
DATA PRELOAD MOVEABLE SINGLE
HEAPSIZE 1024
@@ -0,0 +1,230 @@
//----------------------------------------------------------------------------
// ObjectWindows - (C) Copyright 1991, 1993 by Borland International
//----------------------------------------------------------------------------
#include "calldll.h"
ID_BITMAP BITMAP
{
'42 4D 76 08 00 00 00 00 00 00 76 00 00 00 28 00'
'00 00 40 00 00 00 40 00 00 00 01 00 04 00 00 00'
'00 00 00 08 00 00 00 00 00 00 00 00 00 00 00 00'
'00 00 10 00 00 00 00 00 00 00 00 00 80 00 00 80'
'00 00 00 80 80 00 80 00 00 00 80 00 80 00 80 80'
'00 00 80 80 80 00 C0 C0 C0 00 00 00 FF 00 00 FF'
'00 00 00 FF FF 00 FF 00 00 00 FF 00 FF 00 FF FF'
'00 00 FF FF FF 00 00 00 00 00 00 00 00 00 00 00'
'00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00'
'00 00 00 00 00 00 08 77 77 77 77 77 77 77 77 77'
'77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77'
'77 77 77 77 77 70 0F 88 88 88 88 88 88 88 88 88'
'88 88 88 88 88 88 88 88 88 88 88 88 88 88 88 88'
'88 88 88 88 88 70 0F 88 88 88 88 88 88 88 88 88'
'88 88 88 88 88 88 88 88 88 88 88 08 88 88 88 88'
'88 88 88 88 88 70 0F 88 88 88 88 88 88 88 88 88'
'88 88 88 88 88 88 88 88 88 88 88 08 88 88 88 88'
'88 88 88 88 88 70 0F 88 88 88 88 88 88 88 00 00'
'88 80 88 08 08 80 88 08 80 00 08 00 00 88 08 88'
'88 88 88 88 88 70 0F 88 88 88 88 88 88 88 08 88'
'08 80 80 88 08 80 88 08 08 88 08 08 88 08 88 88'
'88 88 88 88 88 70 0F 88 88 88 88 88 88 88 08 88'
'08 80 80 88 08 80 88 08 08 88 08 08 88 08 08 88'
'88 88 88 88 88 70 0F 88 88 88 88 88 88 88 08 88'
'08 80 80 88 08 80 88 08 80 00 08 08 88 08 08 88'
'88 88 88 88 88 70 0F 88 88 88 88 88 88 88 00 00'
'88 80 80 88 08 80 88 08 88 88 08 08 88 08 08 88'
'88 88 88 88 88 70 0F 88 88 88 88 88 88 88 08 88'
'08 80 80 08 00 08 00 88 80 00 88 00 00 88 08 88'
'88 88 88 88 88 70 0F 88 88 88 88 88 88 88 08 88'
'08 88 80 88 88 88 88 88 88 88 88 88 88 88 08 88'
'88 88 88 88 88 70 0F 88 88 88 88 88 88 88 08 88'
'08 88 80 88 88 88 88 88 88 88 88 88 88 88 08 88'
'88 88 88 88 88 70 0F 88 88 88 88 88 88 88 00 00'
'88 80 88 88 88 88 88 88 88 88 88 88 88 88 08 88'
'88 88 88 88 88 70 0F 88 88 88 88 88 88 88 88 88'
'88 88 88 88 88 88 88 88 88 88 88 88 88 88 88 88'
'88 88 88 88 88 70 0F 88 88 88 88 88 88 88 88 88'
'88 88 88 88 88 88 88 88 88 88 88 88 88 88 88 88'
'88 88 88 88 88 70 0F 88 88 88 88 FF FF FF FF FF'
'FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF'
'FF 88 88 88 88 70 0F 88 88 88 87 CC CC CC CC CC'
'8D DD DD DD DD D8 EE EE EE EE EE 8F FF FF FF FF'
'FF 88 88 88 88 70 0F 88 88 88 87 CC CC CC CC CC'
'8D DD DD DD DD D8 EE EE EE EE EE 8F FF FF FF FF'
'FF 88 88 88 88 70 0F 88 88 88 87 CC CC CC CC CC'
'8D DD DD DD DD D8 EE EE EE EE EE 8F FF FF FF FF'
'FF 88 88 88 88 70 0F 88 88 88 87 CC CC CC CC CC'
'8D DD DD DD DD D8 EE EE EE EE EE 8F FF FF FF FF'
'FF 88 88 88 88 70 0F 88 88 88 87 CC CC CC CC CC'
'8D DD DD DD DD D8 EE EE EE EE EE 8F FF FF FF FF'
'FF 88 88 88 88 70 0F 88 88 88 87 CC CC CC CC CC'
'8D DD DD DD DD D8 EE EE EE EE EE 8F FF FF FF FF'
'FF 88 88 88 88 70 0F 88 88 88 87 CC CC CC CC CC'
'8D DD DD DD DD D8 EE EE EE EE EE 8F FF FF FF FF'
'FF 88 88 88 88 70 0F 88 88 88 87 CC CC CC CC CC'
'8D DD DD DD DD D8 EE EE EE EE EE 8F FF FF FF FF'
'FF 88 88 88 88 70 0F 88 88 88 87 CC CC CC CC CC'
'8D DD DD DD DD D8 EE EE EE EE EE 8F FF FF FF FF'
'FF 88 88 88 88 70 0F 88 88 88 87 CC CC CC CC CC'
'8D DD DD DD DD D8 EE EE EE EE EE 8F FF FF FF FF'
'FF 88 88 88 88 70 0F 88 88 88 87 88 88 88 88 88'
'88 88 88 88 88 88 88 88 88 88 88 88 88 88 88 88'
'8F 88 88 88 88 70 0F 88 88 88 87 88 88 88 88 88'
'89 99 99 99 99 98 AA AA AA AA AA 8B BB BB BB BB'
'BF 88 88 88 88 70 0F 88 88 88 87 88 88 88 88 88'
'89 99 99 99 99 98 AA AA AA AA AA 8B BB BB BB BB'
'BF 88 88 88 88 70 0F 88 88 88 87 88 88 88 88 88'
'89 99 99 99 99 98 AA AA AA AA AA 8B BB BB BB BB'
'BF 88 88 88 88 70 0F 88 88 88 87 88 88 88 88 88'
'89 99 99 99 99 98 AA AA AA AA AA 8B BB BB BB BB'
'BF 88 88 88 88 70 0F 88 88 88 87 88 88 88 88 88'
'89 99 99 99 99 98 AA AA AA AA AA 8B BB BB BB BB'
'BF 88 88 88 88 70 0F 88 88 88 87 88 88 88 88 88'
'89 99 99 99 99 98 AA AA AA AA AA 8B BB BB BB BB'
'BF 88 88 88 88 70 0F 88 88 88 87 88 88 88 88 88'
'89 99 99 99 99 98 AA AA AA AA AA 8B BB BB BB BB'
'BF 88 88 88 88 70 0F 88 88 88 87 88 88 88 88 88'
'89 99 99 99 99 98 AA AA AA AA AA 8B BB BB BB BB'
'BF 88 88 88 88 70 0F 88 88 88 87 88 88 88 88 88'
'89 99 99 99 99 98 AA AA AA AA AA 8B BB BB BB BB'
'BF 88 88 88 88 70 0F 88 88 88 87 88 88 88 88 88'
'89 99 99 99 99 98 AA AA AA AA AA 8B BB BB BB BB'
'BF 88 88 88 88 70 0F 88 88 88 87 88 88 88 88 88'
'88 88 88 88 88 88 88 88 88 88 88 88 88 88 88 88'
'8F 88 88 88 88 70 0F 88 88 88 87 44 44 44 44 44'
'85 55 55 55 55 58 66 66 66 66 66 87 77 77 77 77'
'7F 88 88 88 88 70 0F 88 88 88 87 44 44 44 44 44'
'85 55 55 55 55 58 66 66 66 66 66 87 77 77 77 77'
'7F 88 88 88 88 70 0F 88 88 88 87 44 44 44 44 44'
'85 55 55 55 55 58 66 66 66 66 66 87 77 77 77 77'
'7F 88 88 88 88 70 0F 88 88 88 87 44 44 44 44 44'
'85 55 55 55 55 58 66 66 66 66 66 87 77 77 77 77'
'7F 88 88 88 88 70 0F 88 88 88 87 44 44 44 44 44'
'85 55 55 55 55 58 66 66 66 66 66 87 77 77 77 77'
'7F 88 88 88 88 70 0F 88 88 88 87 44 44 44 44 44'
'85 55 55 55 55 58 66 66 66 66 66 87 77 77 77 77'
'7F 88 88 88 88 70 0F 88 88 88 87 44 44 44 44 44'
'85 55 55 55 55 58 66 66 66 66 66 87 77 77 77 77'
'7F 88 88 88 88 70 0F 88 88 88 87 44 44 44 44 44'
'85 55 55 55 55 58 66 66 66 66 66 87 77 77 77 77'
'7F 88 88 88 88 70 0F 88 88 88 87 44 44 44 44 44'
'85 55 55 55 55 58 66 66 66 66 66 87 77 77 77 77'
'7F 88 88 88 88 70 0F 88 88 88 87 44 44 44 44 44'
'85 55 55 55 55 58 66 66 66 66 66 87 77 77 77 77'
'7F 88 88 88 88 70 0F 88 88 88 87 88 88 88 88 88'
'88 88 88 88 88 88 88 88 88 88 88 88 88 88 88 88'
'8F 88 88 88 88 70 0F 88 88 88 87 00 00 00 00 00'
'81 11 11 11 11 18 22 22 22 22 22 83 33 33 33 33'
'3F 88 88 88 88 70 0F 88 88 88 87 00 00 00 00 00'
'81 11 11 11 11 18 22 22 22 22 22 83 33 33 33 33'
'3F 88 88 88 88 70 0F 88 88 88 87 00 00 00 00 00'
'81 11 11 11 11 18 22 22 22 22 22 83 33 33 33 33'
'3F 88 88 88 88 70 0F 88 88 88 87 00 00 00 00 00'
'81 11 11 11 11 18 22 22 22 22 22 83 33 33 33 33'
'3F 88 88 88 88 70 0F 88 88 88 87 00 00 00 00 00'
'81 11 11 11 11 18 22 22 22 22 22 83 33 33 33 33'
'3F 88 88 88 88 70 0F 88 88 88 87 00 00 00 00 00'
'81 11 11 11 11 18 22 22 22 22 22 83 33 33 33 33'
'3F 88 88 88 88 70 0F 88 88 88 87 00 00 00 00 00'
'81 11 11 11 11 18 22 22 22 22 22 83 33 33 33 33'
'3F 88 88 88 88 70 0F 88 88 88 87 00 00 00 00 00'
'81 11 11 11 11 18 22 22 22 22 22 83 33 33 33 33'
'3F 88 88 88 88 70 0F 88 88 88 87 00 00 00 00 00'
'81 11 11 11 11 18 22 22 22 22 22 83 33 33 33 33'
'3F 88 88 88 88 70 0F 88 88 88 87 00 00 00 00 00'
'81 11 11 11 11 18 22 22 22 22 22 83 33 33 33 33'
'3F 88 88 88 88 70 0F 88 88 88 87 77 77 77 77 77'
'77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77'
'78 88 88 88 88 70 0F 88 88 88 88 88 88 88 88 88'
'88 88 88 88 88 88 88 88 88 88 88 88 88 88 88 88'
'88 88 88 88 88 70 0F FF FF FF FF FF FF FF FF FF'
'FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF'
'FF FF FF FF FF 80 00 00 00 00 00 00 00 00 00 00'
'00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00'
'00 00 00 00 00 00'
}
ID_CURSOR CURSOR
{
'00 00 02 00 01 00 20 20 00 00 09 00 09 00 30 01'
'00 00 16 00 00 00 28 00 00 00 20 00 00 00 40 00'
'00 00 01 00 01 00 00 00 00 00 00 02 00 00 00 00'
'00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00'
'00 00 FF FF FF 00 00 00 00 00 00 00 00 00 00 00'
'00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00'
'00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00'
'00 00 00 00 00 00 00 60 00 00 00 90 00 00 01 08'
'00 00 02 04 00 00 03 9C 00 00 00 90 00 00 18 91'
'80 00 28 91 40 00 4F 9F 20 00 80 00 10 00 80 00'
'10 00 4F 9F 20 00 28 91 40 00 18 91 80 00 00 90'
'00 00 03 9C 00 00 02 04 00 00 01 08 00 00 00 90'
'00 00 00 60 00 00 87 2B 9C 6D 7A CB 6B AF 7E EB'
'DB AD 7E EB BB AD 7E EB 6B AD 7E E9 9C 65 7F FF'
'FF FD 7B FF FF FD 87 FF FF FD FF FF FF FF FF FF'
'FF FF FF FF FF FF FF 9F FF FF FF 0F FF FF FE 07'
'FF FF FC 03 FF FF FC 03 FF FF FF 0F FF FF E7 0E'
'7F FF C7 0E 3F FF 80 00 1F FF 00 60 0F FF 00 60'
'0F FF 80 00 1F FF C7 0E 3F FF E7 0E 7F FF FF 0F'
'FF FF FC 03 FF FF FC 03 FF FF FE 07 FF FF FF 0F'
'FF FF FF 9F FF FF'
}
ID_ICON ICON
{
'00 00 01 00 01 00 20 20 10 00 00 00 00 00 E8 02'
'00 00 16 00 00 00 28 00 00 00 20 00 00 00 40 00'
'00 00 01 00 04 00 00 00 00 00 80 02 00 00 00 00'
'00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00'
'00 00 00 00 80 00 00 80 00 00 00 80 80 00 80 00'
'00 00 80 00 80 00 80 80 00 00 80 80 80 00 C0 C0'
'C0 00 00 00 FF 00 00 FF 00 00 00 FF FF 00 FF 00'
'00 00 FF 00 FF 00 FF FF 00 00 FF FF FF 00 00 00'
'00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00'
'00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00'
'00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00'
'00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00'
'00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00'
'00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00'
'00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00'
'00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00'
'00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00'
'00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00'
'00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00'
'0C CC CC C0 00 00 00 00 00 00 00 00 00 00 00 00'
'0C CC CC C0 40 00 00 00 00 00 00 00 00 00 00 00'
'0C CC CC C0 40 00 00 00 00 00 00 00 00 00 00 00'
'0C CC CC C0 40 00 00 00 00 00 00 00 00 00 00 00'
'0C CC CC C0 40 00 00 99 99 99 90 00 00 00 00 00'
'0C CC CC C0 40 00 00 99 99 99 90 10 00 00 00 00'
'00 00 00 00 40 00 00 09 99 99 01 11 00 00 00 00'
'00 EE EE EE 00 00 00 09 99 99 01 10 00 00 00 00'
'00 00 00 00 00 00 00 00 99 90 11 00 00 00 00 00'
'00 00 00 00 00 00 00 00 99 90 10 00 00 00 00 00'
'00 00 00 00 00 00 00 00 09 01 00 00 00 00 00 00'
'00 00 00 00 03 33 00 00 09 00 00 00 00 00 00 00'
'00 00 00 0B 3B 3B 33 00 00 00 00 00 00 00 00 00'
'00 00 00 03 B3 B3 B3 00 00 00 00 00 00 00 00 00'
'00 00 00 BB BB BB 3B 30 00 00 00 00 00 00 00 00'
'00 00 00 BB BB BB B3 30 00 00 00 00 00 00 00 00'
'00 00 00 BB FF BB 3B 30 00 00 00 00 00 00 00 00'
'00 00 00 0B FF BB B3 00 00 00 00 00 00 00 00 00'
'00 00 00 0B BB BB 3B 00 00 00 00 00 00 00 00 00'
'00 00 00 00 0B BB 00 00 00 00 00 00 00 00 00 00'
'00 00 00 00 00 00 00 00 00 00 00 00 00 00 FD 8E'
'37 5F FD 75 D7 7F FD 7D D7 5F FD 7D D7 5F FD 75'
'D3 5F FD 8E 34 DF FD FF FF DF FD FF FF DF FD FF'
'FF DF FF FF FF FF F0 0F FF FF F0 07 FF FF F0 03'
'FF FF F0 03 FF FF F0 03 80 3F F0 03 80 1F F0 03'
'80 0F F0 03 C0 07 F8 03 C0 0F FC 03 E0 1F FF FF'
'E0 3F FF F8 F0 7F FF E0 30 FF FF C0 19 FF FF C0'
'1F FF FF 80 0F FF FF 80 0F FF FF 80 0F FF FF C0'
'1F FF FF C0 1F FF FF E0 3F FF FF F8 FF FF'
}
STRINGTABLE
{
ID_STRING, "Hello from a resource!"
}
Binary file not shown.
@@ -0,0 +1,299 @@
//----------------------------------------------------------------------------
// ObjectWindows - (C) Copyright 1993 by Borland International
// Example of a minimal doc/view application. Doc/views must be linked in.
// NOTE: this example interprets command line flags to select frame type.
//----------------------------------------------------------------------------
#include <owl\owlpch.h>
#include <owl\docmanag.h>
#include <owl\decmdifr.h>
#include <owl\statusba.h>
#include "docviewx.rc"
class MyDVApp : public TApplication {
public:
MyDVApp() {}
TMDIClient* Client;
int DocMode;
void InitInstance();
void InitMainWindow();
void EvNewView (TView& view);
void EvCloseView(TView& view);
void EvDropFiles(TDropInfo dropInfo);
void CmDeskClear();
void CmDeskSave();
void CmDeskRestore();
void CmHideView();
void CmShowViews();
void CmDisableView();
void CmEnableViews();
DECLARE_RESPONSE_TABLE(MyDVApp);
DECLARE_STREAMABLE(, MyDVApp, 1);
};
DEFINE_RESPONSE_TABLE1(MyDVApp, TApplication)
EV_OWLVIEW(dnCreate, EvNewView),
EV_OWLVIEW(dnClose, EvCloseView),
EV_WM_DROPFILES,
EV_COMMAND(CM_DESKCLEAR, CmDeskClear),
EV_COMMAND(CM_DESKSAVE, CmDeskSave),
EV_COMMAND(CM_DESKRESTORE, CmDeskRestore),
EV_COMMAND(CM_HIDEVIEW, CmHideView),
EV_COMMAND(CM_SHOWVIEWS, CmShowViews),
EV_COMMAND(CM_DISABLEVIEW, CmDisableView),
EV_COMMAND(CM_ENABLEVIEWS, CmEnableViews),
END_RESPONSE_TABLE;
IMPLEMENT_CASTABLE1(MyDVApp, TApplication);
IMPLEMENT_STREAMABLE1(MyDVApp, TApplication);
const char sSDIStream[] = "C:\\DOCVIEWX.SDI";
const char sMDIStream[] = "C:\\DOCVIEWX.MDI";
_OWLLINK(rTMDIChild); // force TMDIChild::Streamer to be linked in
_OWLLINK(rTMDIClient); // force TMDIClient::Streamer to be linked in
_OWLLINK(rTFileDocument); // force TMDIClient::Streamer to be linked in
void MyDVApp::EvDropFiles(TDropInfo dropInfo)
{
int fileCount = dropInfo.DragQueryFileCount();
int index = 0;
while (index < fileCount) {
int fileLength = dropInfo.DragQueryFileNameLen(index)+1;
char* filePath = new char [fileLength];
dropInfo.DragQueryFile(index++, filePath, fileLength);
TDocTemplate* tpl = GetDocManager()->MatchTemplate(filePath);
#if 0 // obsolete code
if (tpl) {
tpl->CreateDoc(filePath);
}
#else // new code
GetDocManager()->CreateDoc(tpl, filePath);
#endif
delete filePath;
}
dropInfo.DragFinish();
}
void MyDVApp::InitInstance()
{
TApplication::InitInstance();
MainWindow->DragAcceptFiles(TRUE);
}
void MyDVApp::InitMainWindow()
{
BOOL decorate;
switch ((_argc>1 && _argv[1][0]=='-' ? _argv[1][1] : (char)0) | ('S'^'s')) {
case 's': DocMode = dmSDI; decorate = FALSE; break; // command line: -s
case 'm': DocMode = dmMDI; decorate = FALSE; break; // command line: -m
case 'd': DocMode = dmSDI; decorate = TRUE; break; // command line: -d
default : DocMode = dmMDI; decorate = TRUE; break; // no command line
}
DocManager = new TDocManager(DocMode | dmMenu);
if (decorate) {
TDecoratedFrame* frame = (DocMode == dmSDI
? new TDecoratedFrame(0, "SDI DocView Example", 0,TRUE)
: new TDecoratedMDIFrame("MDI DocView Example", 0,
*(Client=new TMDIClient), TRUE));
TStatusBar* sb = new TStatusBar(frame, TGadget::Recessed,
TStatusBar::CapsLock | TStatusBar::NumLock | TStatusBar::Overtype);
frame->Insert(*sb, TDecoratedFrame::Bottom);
MainWindow = frame;
} else { // !decorate
MainWindow = (DocMode == dmSDI
? new TFrameWindow(0, "SDI DocView Example")
: new TMDIFrame("MDI DocView Example", 0, *(Client=new TMDIClient)));
}
MainWindow->SetMenuDescr(TMenuDescr(DocMode==dmSDI ? IDM_DVSDI : IDM_DVMDI));
MainWindow->SetIcon(this, IDI_DOCVIEW);
}
void MyDVApp::EvNewView(TView& view)
{
if (DocMode == dmSDI) {
MainWindow->SetClientWindow(view.GetWindow());
if (!view.IsOK())
MainWindow->SetClientWindow(0);
else if (view.GetViewMenu())
MainWindow->MergeMenu(*view.GetViewMenu());
} else { // DocMode == dmMDI
TMDIChild* child = new TMDIChild(*Client, 0, view.GetWindow());
if (view.GetViewMenu())
child->SetMenuDescr(*view.GetViewMenu());
child->Create();
}
}
void MyDVApp::EvCloseView(TView& /*view*/)
{
if (DocMode == dmSDI) {
MainWindow->SetClientWindow(0);
MainWindow->RestoreMenu();
MainWindow->SetCaption("SDI DocView Example");
}
}
void MyDVApp::CmDeskClear()
{
delete DocManager; // delete existing document manager, and doc/views
DocManager = new TDocManager(DocMode | dmMenu);
}
void MyDVApp::CmDeskSave()
{
ofpstream os(DocMode == dmMDI ? sMDIStream : sSDIStream);
os << *this; // start stream with application
os.close();
if (os.bad()) {
unlink(DocMode == dmMDI ? sMDIStream : sSDIStream);
MainWindow->MessageBox("Unable to write desktop file.", "File error",
MB_OK | MB_ICONEXCLAMATION);
}
}
void MyDVApp::CmDeskRestore()
{
char* errorMsg = 0;
ifpstream is(DocMode == dmMDI ? sMDIStream : sSDIStream);
if (is.bad())
errorMsg = "Unable to open desktop file.";
else {
delete DocManager; // delete existing document manager, and doc/views
DocManager = new TDocManager(DocMode | dmMenu);
is >> *this; // stream in documents, views, windows
if (is.bad())
errorMsg = "Error reading desktop file.";
is.close();
}
if (errorMsg)
MainWindow->MessageBox(errorMsg, "Error", MB_OK | MB_ICONEXCLAMATION);
}
void MyDVApp::Streamer::Write(opstream& os) const
{
MyDVApp* o = GetObject();
TFrameWindow* mainWnd = o->MainWindow;
WriteBaseObject((TApplication*)o, os);
os <<mainWnd->Attr.X <<mainWnd->Attr.Y <<mainWnd->Attr.W <<mainWnd->Attr.H;
if (o->DocMode == dmMDI) {
os << *o->Client;// stream out object reference only, no children streamed
os << *o->DocManager;
os << o->Client->GetActiveMDIChild();
} else {
TWindow* client = mainWnd->SetClientWindow(0); // unhook view
if (client) {
client->ShowWindow(SW_HIDE);
client->SetParent(0);
os << *o->DocManager;
os << client; // save pointer to client window
mainWnd->SetClientWindow(client);
}
}
}
void* MyDVApp::Streamer::Read(ipstream& is, uint32 /*version*/ ) const
{
MyDVApp* o = GetObject();
TFrameWindow* mainWnd = o->MainWindow;
ReadBaseObject((TApplication*)o, is);
is >>mainWnd->Attr.X >>mainWnd->Attr.Y >>mainWnd->Attr.W >>mainWnd->Attr.H;
mainWnd->MoveWindow(mainWnd->Attr.X, mainWnd->Attr.Y,
mainWnd->Attr.W, mainWnd->Attr.H, TRUE);
if (o->DocMode == dmMDI) {
is >> *o->Client; // skip stream top ref, no data or children read in
is >> *o->DocManager; // streams in all templates, docs, views, windows
o->Client->CreateChildren(); // create MDI children and descendents
TMDIChild* active;
is >> active;
if (active)
GetObject()->Client->HandleMessage(WM_MDIACTIVATE,(UINT)active->HWindow);
} else {
TWindow* client;
is >> *o->DocManager; // streams in all templates, docs, views, windows
is >> client; // streams in pointer to constructed client window
if (client) {
mainWnd->SetClientWindow(client);
TDocument* doc;
TView* view;
if ((doc = o->DocManager->DocList.Next(0)) != 0 &&
(view = doc->NextView(0)) != 0)
mainWnd->MergeMenu(*view->GetViewMenu());
}
}
return GetObject();
}
void MyDVApp::CmHideView()
{
TMDIChild* child = Client->GetActiveMDIChild();
if (child)
child->ShowWindow(SW_HIDE);
}
void sUnHide(TWindow* win, void*)
{
TMDIChild* child = TYPESAFE_DOWNCAST(win, TMDIChild);
if (child && !child->IsWindowVisible())
child->ShowWindow(SW_RESTORE);
}
void MyDVApp::CmShowViews()
{
Client->ForEach(sUnHide);
}
void MyDVApp::CmDisableView()
{
TMDIChild* child = Client->GetActiveMDIChild();
if (child)
child->EnableWindow(FALSE);
}
void sUnDisable(TWindow* win, void*)
{
TMDIChild* child = TYPESAFE_DOWNCAST(win, TMDIChild);
if (child && !child->IsWindowEnabled())
child->EnableWindow(TRUE);
}
void MyDVApp::CmEnableViews()
{
Client->ForEach(sUnDisable);
}
int OwlMain(int /*argc*/, char* /*argv*/ [])
{
MyDVApp* app;
int status;
int done;
do {
try {
app = new MyDVApp;
status = app->Run();
done = 1;
if (status) {
char buf[40];
wsprintf(buf, "Run returned %i", status);
done = HandleGlobalException(xmsg(string(buf)),
"Abnormal Termination","RunAgain?");
}
}
catch (xmsg& x) {
done = status = HandleGlobalException(x,
"Abnormal Termination, uncaught xmsg","RunAgain?");
}
catch(...) {
done = status = HandleGlobalException(xmsg(string()),
"Abnormal Termination, uncaught ...","RunAgain?");
}
delete app;
} while (!done);
return status;
}
@@ -0,0 +1,131 @@
//----------------------------------------------------------------------------
// ObjectWindows - (C) Copyright 1993 by Borland International
// Resources for use with doc/view example
//----------------------------------------------------------------------------
#ifndef WS_POPUP
#include <windows.h>
#endif
#include <owl\docview.rc>
#include <owl\except.rc>
#include <owl\mdi.rh>
#define IDI_DOCVIEW 22201
#define IDM_DVSDI 22201
#define IDM_DVMDI 22202
#define CM_DESKCLEAR 22202
#define CM_DESKSAVE 22203
#define CM_DESKRESTORE 22204
#define CM_HIDEVIEW 22205
#define CM_SHOWVIEWS 22206
#define CM_DISABLEVIEW 22207
#define CM_ENABLEVIEWS 22208
#if defined(RC_INVOKED)
#include <owl\statusba.rc>
#include <owl\owlapp.rc>
IDM_DVSDI MENU LOADONCALL MOVEABLE PURE DISCARDABLE
{
MenuItem "File", 0,GRAYED ;placeholder for File menu from DocManager
MenuItem Separator
MenuItem Separator
POPUP "&Desktop"
{
MenuItem "&Clear Desktop", CM_DESKCLEAR
; MenuItem "&Save Desktop", CM_DESKSAVE
; MenuItem "&Restore Desktop",CM_DESKRESTORE
}
}
IDM_DVMDI MENU LOADONCALL MOVEABLE PURE DISCARDABLE
{
MenuItem "File", 0,GRAYED ;placeholder for File menu from DocManager
MenuItem Separator
MenuItem Separator
POPUP "&Desktop"
{
MenuItem "&Clear Desktop", CM_DESKCLEAR
; MenuItem "&Save Desktop", CM_DESKSAVE
; MenuItem "&Restore Desktop",CM_DESKRESTORE
MenuItem "&Hide View", CM_HIDEVIEW
MenuItem "&Unhide Views", CM_SHOWVIEWS
MenuItem "&Disable View", CM_DISABLEVIEW
MenuItem "&Enable Views", CM_ENABLEVIEWS
}
MenuItem Separator
MenuItem Separator
POPUP "&Window"
{
MenuItem "&Cascade", CM_CASCADECHILDREN
MenuItem "&Tile", CM_TILECHILDREN
MenuItem "Arrange &Icons", CM_ARRANGEICONS
MenuItem "C&lose All", CM_CLOSECHILDREN
MenuItem "Add &View", CM_VIEWCREATE
}
}
STRINGTABLE LOADONCALL MOVEABLE DISCARDABLE
{
CM_DESKCLEAR, "Clear desktop"
CM_DESKSAVE, "Save desktop"
CM_DESKRESTORE, "Restore desktop"
CM_HIDEVIEW, "Hide current view"
CM_SHOWVIEWS, "Unhide hidden views"
CM_DISABLEVIEW, "Disable current view"
CM_ENABLEVIEWS, "Enable disabled views"
}
IDI_DOCVIEW ICON
{
'00 00 01 00 01 00 20 20 10 00 00 00 00 00 E8 02'
'00 00 16 00 00 00 28 00 00 00 20 00 00 00 40 00'
'00 00 01 00 04 00 00 00 00 00 80 02 00 00 00 00'
'00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00'
'00 00 00 00 BF 00 00 BF 00 00 00 BF BF 00 BF 00'
'00 00 BF 00 BF 00 BF BF 00 00 C0 C0 C0 00 80 80'
'80 00 00 00 FF 00 00 FF 00 00 00 FF FF 00 FF 00'
'00 00 FF 00 FF 00 FF FF 00 00 FF FF FF 00 CC CC'
'CC CC CC CC CC 00 00 00 00 00 00 00 00 00 C0 00'
'00 00 00 00 0C 00 00 00 00 00 00 00 00 00 CF FF'
'0F FF F0 FF FC 00 0C CC CC CC CC CC CC C0 CF FF'
'0F FF F0 FF FC 00 0C FF FF FF FF FF FF C0 C0 00'
'00 00 00 00 0C 00 0C F0 00 00 00 00 00 C0 CF FF'
'0A AA A0 FF FC 00 0C F0 22 FF FF FF FF C0 CF FF'
'0A AA A0 FF FC 00 0C F0 FF 2F FF FF FF C0 C0 00'
'00 00 00 00 0C 00 0C F0 FF F2 FF FF F9 C0 CF FF'
'0F FF F0 FF FC 00 0C F0 FF FF 2F FF 9F C0 CF FF'
'0F FF F0 FF FC 00 0C F0 FF FF F2 F9 FF C0 C0 00'
'00 00 00 00 0C 00 0C F0 9F FF F2 F9 FF C0 CF FF'
'FF FF FF FF FC 00 0C F0 F9 FF FF 29 FF C0 C7 7F'
'FF 77 FF F7 7C 00 0C F0 FF 99 FF 92 FF C0 CC CC'
'CC CC CC CC CC 00 0C F0 FF FF 99 FF 22 C0 00 00'
'99 90 00 00 00 00 9C F0 FF FF FF FF FF C0 00 00'
'99 90 00 00 00 09 9C CC CC CC CC CC CC C0 00 00'
'99 90 00 00 00 99 99 00 00 00 00 00 00 00 BB BB'
'BB BB BB BB B9 99 90 00 00 00 00 00 00 00 B0 00'
'00 00 BB BB B9 99 00 CC CC CC CC CC CC CC BB BB'
'BB BB BB BB B9 90 00 CF FF FF FF FF FF FC B0 00'
'00 00 00 0B B0 00 00 CF 0F 0F 0F 0F 0F FC BB BB'
'BB BB BB BB B0 00 00 CF FF FF FF FF FF FC B0 00'
'00 00 0B BB B0 00 00 CC CC FC CC FC CC CC BB BB'
'BB BB BB BB B0 00 00 CC FC CC FC CC FC CC B0 00'
'00 00 00 0B B0 00 00 CF FF FF FF FF FF FC BB BB'
'BB BB BB BB B0 00 00 CF 0F 0F 0F 0F 0F FC B0 00'
'00 00 00 BB B9 99 99 CF FF FF FF FF FF FC BB BB'
'BB BB BB BB B9 99 99 CF 0F 0F 0F 0F 0F FC B0 00'
'00 00 BB BB B9 99 99 CF FF FF FF FF FF FC BB BB'
'BB BB BB BB B0 00 00 CF 0F 0F 0F 0F 0F FC B0 00'
'00 00 00 00 B0 00 00 CF FF FF FF FF FF FC BB BB'
'BB BB BB BB B0 00 00 CC CC CC CC CC CC CC 00 03'
'FF FF 00 03 FF FF 00 03 80 01 00 03 80 01 00 03'
'80 01 00 03 80 01 00 03 80 01 00 03 80 01 00 03'
'80 01 00 03 80 01 00 03 80 01 00 03 80 01 00 03'
'80 01 00 03 80 01 F1 FF 00 01 F1 FE 00 01 F1 FC'
'3F FF 00 00 7F FF 00 00 C0 00 00 01 C0 00 00 07'
'C0 00 00 07 C0 00 00 07 C0 00 00 07 C0 00 00 07'
'C0 00 00 07 C0 00 00 00 00 00 00 00 00 00 00 00'
'00 00 00 07 C0 00 00 07 C0 00 00 07 C0 00'
}
#endif // defined(RC_INVOKED)
@@ -0,0 +1,549 @@
//----------------------------------------------------------------------------
// ObjectWindows - (C) Copyright 1993 by Borland International
// Implements class TDumpView
//----------------------------------------------------------------------------
#include <owl\owlpch.h>
#include <owl\docmanag.h>
#include <owl\filedoc.h>
#include <owl\listbox.h>
#include <owl\inputdia.h>
#include <owl\dc.h>
#include "dumpview.rc"
struct TDumpData;
class _DOCVIEWCLASS TDumpView : public TListBox, public TView {
public:
TDumpView(TDocument& doc, TWindow* parent = 0);
~TDumpView();
static LPCSTR StaticName() {return "Dump View";} // put in resource
//
// overridden virtuals from TView
//
LPCSTR GetViewName(){return StaticName();}
// const char far* GetViewName(){return StaticName();}
TWindow* GetWindow() {return (TWindow*)this;}
BOOL SetDocTitle(LPCSTR docname, int index)
// BOOL SetDocTitle(const char far* docname, int index)
{return TListBox::SetDocTitle(docname, index);}
//
// overridden virtuals from TWindow
//
BOOL Create();
BOOL CanClose() {return TListBox::CanClose() && Doc->CanClose();}
int MaxWidth; // maximum horizontal extent
protected:
long Origin;
long FileSize;
int UpdateMode; // 0=NotEditing, 1=HighNibble, 2=LowNibble, -1=Flushing
int CharWidth;
int CharHeight;
int EditByte;
int EditLine;
TDumpData* Changes;
void Init();
BOOL LoadData(int top, int sel);
void FormatLine(int index, TDumpData* data);
BOOL NewEditLine(int line, int byte);
void EndEditLine();
void KillChanges();
private:
//
// message response functions
//
BOOL VnCommit(BOOL force);
BOOL VnRevert(BOOL clear);
BOOL VnIsWindow(HWND hWnd) {return HWindow == hWnd;}
BOOL VnIsDirty();
BOOL VnDocClosed(int omode);
void CmEditUndo();
void CmEditItem();
void EvPaint();
void EvKeyDown(UINT key, UINT repeatCount, UINT flags);
void EvLButtonDown(UINT modKeys, TPoint& point);
void EvLButtonDblClk(UINT modKeys, TPoint& point);
void CmSelChange(){} // to prevent interpreting as unprocessed accelerator
DECLARE_RESPONSE_TABLE(TDumpView);
DECLARE_STREAMABLE(,TDumpView,1);
};
DIAG_DECLARE_GROUP(OwlDocView); // General Doc/View diagnostic group
const int DisplayLines = 16; // initial list box size
const int ListBoxMax = 100; // max number of lines stored in list box
const int DataWidth = 8; // number of data bytes per line
const int AddrWidth = 2; // number of bytes in address
const int LineWidth = AddrWidth*2 + 1 + DataWidth*3 + DataWidth;
struct TDumpData {
long Addr;
char Old[DataWidth];
char New[DataWidth];
int Count;
TDumpData* Next;
};
DEFINE_RESPONSE_TABLE1(TDumpView, TListBox)
EV_WM_KEYDOWN,
EV_COMMAND(CM_DUMPUNDO, CmEditUndo),
EV_COMMAND(CM_DUMPEDIT, CmEditItem),
EV_WM_PAINT,
EV_WM_LBUTTONDOWN,
EV_WM_LBUTTONDBLCLK,
EV_VN_DOCCLOSED,
EV_VN_ISWINDOW,
EV_VN_ISDIRTY,
EV_VN_COMMIT,
EV_VN_REVERT,
EV_NOTIFY_AT_CHILD(LBN_SELCHANGE, CmSelChange),
END_RESPONSE_TABLE;
TDumpView::TDumpView(TDocument& doc, TWindow* parent)
: TView(doc), TListBox(parent, GetNextViewId(), 0,0,0,0)
{
Init();
// Attr.Style &= ~(WS_BORDER | LBS_SORT);
Attr.Style &= ~(LBS_SORT);
Attr.Style |= LBS_DISABLENOSCROLL | LBS_NOINTEGRALHEIGHT;
Attr.AccelTable = IDA_DUMPVIEW;
SetViewMenu(new TMenuDescr(IDM_DUMPVIEW,0,1,0,0,0,1));
}
void
TDumpView::Init()
{
Origin = 0;
UpdateMode = 0;
Changes = 0;
}
BOOL
TDumpView::VnDocClosed(int omode)
{
if (UpdateMode == -1 || !(omode & ofWrite)) // make sure someone else's write
return FALSE;
int top = GetTopIndex();
int sel = GetSelIndex();
ClearList();
LoadData(top, sel);
return TRUE;
}
static char HexDigit(int i)
{
char c = char((i & 15) + '0');
if (c > '9')
c += char('A' - ('9' + 1));
return c;
}
void
TDumpView::FormatLine(int line, TDumpData* data)
{
char buf[LineWidth + 2];
int index;
char* pbuf;
char* pasc;
unsigned char chr;
long addr = data->Addr;
for (index = AddrWidth*2; --index >= 0; addr >>= 4)
buf[index] = HexDigit((int)addr);
pbuf = buf + AddrWidth*2;
*pbuf++ = ' ';
pasc = pbuf + DataWidth*3;
for (index = 0; index < DataWidth; index++) {
if (index < data->Count) {
chr = data->New[index];
*pbuf++ = HexDigit(chr >> 4);
*pbuf++ = HexDigit(chr);
pasc[index] = char((chr >= 0x20 && chr < 0x7F) ? chr : 0x7F);
} else {
*pbuf++ = ' ';
*pbuf++ = ' ';
pasc[index] = ' ';
}
*pbuf++ = ' ';
}
pasc[DataWidth] = 0; // null terminate buffer
InsertString(buf, line);
}
static long GetAddr(int index)
{
return index * DataWidth;
// need to add origin!
}
static int GetIndex(long addr)
{
return int(addr / DataWidth);
// need to subtract origin!
}
BOOL
TDumpView::LoadData(int top, int sel)
{
TDumpData data;
istream* inStream;
int count;
if ((inStream = Doc->InStream(ofRead | ofBinary)) == 0)
return FALSE;
for (count=0, data.Addr=0; count<ListBoxMax; count++,data.Addr+=DataWidth) {
inStream->read(data.New, DataWidth);
if ((data.Count = inStream->gcount()) == 0)
break;
FormatLine(-1, &data);
if (data.Count != DataWidth)
break;
}
SetTopIndex(top);
SetSelIndex(sel);
delete inStream; // close file in case process switch
return TRUE;
}
BOOL
TDumpView::Create()
{
TRect rect;
LOGFONT fontinfo;
HGDIOBJ font = GetStockObject(SYSTEM_FIXED_FONT);
TListBox::Create(); // throws exception TXInvalidWindow
SendMessage(WM_SETFONT, (UINT)font, 0L);
GetObject(font, sizeof(LOGFONT), &fontinfo);
CharWidth = fontinfo.lfWidth;
CharHeight = fontinfo.lfHeight;
GetClientRect(rect); // created with 0,0 size, .right is -scroll bar size
if (rect.right < 0) { // if new view, else streaming in presized window
rect.right = LineWidth * CharWidth + (-rect.right+2) + CharWidth/2;
rect.bottom = CharHeight * DisplayLines;
MoveWindow(rect);
//if (!Parent->IsFlagSet(wfMainWindow))// prevent parent shrink if main window
Parent->SetFlag(wfShrinkToClient);
}
if (!Doc->GetDocPath())
return TRUE; // new file, no data to display
if (!LoadData(0, 0))
NotOK();
return TRUE;
}
BOOL
TDumpView::VnCommit(BOOL /*force*/)
{
TDumpData* edit;
ostream* outStream;
EndEditLine();
if (!Changes)
return TRUE;
if ((outStream = Doc->OutStream(ofReadWrite | ofBinary)) == 0)
return FALSE;
while ((edit = Changes) != 0) {
outStream->seekp(edit->Addr);
outStream->write(edit->New, edit->Count);
// test goodbit
Changes = Changes->Next;
delete edit;
}
UpdateMode = -1; // to detect our own close notification
outStream->seekp(0,ios::end);
delete outStream;
return TRUE;
}
BOOL
TDumpView::VnRevert(BOOL clear)
{
EndEditLine();
KillChanges();
ClearList();
return (!clear && Doc->GetDocPath() != 0) ? LoadData(0, 0) : TRUE;
}
TDumpView::~TDumpView()
{
KillChanges();
}
BOOL
TDumpView::NewEditLine(int line, int byte)
{
istream* inStream;
TDumpData* edit;
TRect rect;
BOOL stat = TRUE;
if (line < 0)
return FALSE;
SetSelIndex(line); // restore index in case changes
if (UpdateMode > 0) {
return FALSE;
}
if ((inStream = Doc->InStream(ofRead | ofBinary)) == 0)
return FALSE;
if ((edit = new TDumpData) == 0)
return FALSE;
edit->Addr = GetAddr(line);
inStream->seekg(edit->Addr);
// test goodbit
inStream->read(edit->Old, DataWidth);
if ((edit->Count = inStream->gcount()) > 0) {
memcpy(edit->New, edit->Old, edit->Count);
UpdateMode = 1;
GetItemRect(line, rect);
InvalidateRect(rect);
edit->Next = Changes;
Changes = edit;
while (byte >= edit->Count)
byte--;
EditByte = byte;
EditLine = line;
} else {
delete edit;
stat = FALSE;
}
delete inStream;
return stat;
}
BOOL
TDumpView::VnIsDirty()
{
return (Changes
&& (Changes->Next
|| memcmp(Changes->New, Changes->Old, Changes->Count) != 0));
}
void
TDumpView::EndEditLine()
{
TDumpData* edit = Changes;
if (UpdateMode > 0) {
TRect rect;
GetItemRect(EditLine, rect);
InvalidateRect(rect);
if (memcmp(edit->New, edit->Old, edit->Count) == 0) {
Changes = Changes->Next;
delete edit;
}
}
UpdateMode = 0;
}
void
TDumpView::KillChanges()
{
TDumpData* edit;
while ((edit = Changes) != 0) {
Changes = Changes->Next;
delete edit;
}
}
void
TDumpView::EvLButtonDown(UINT modKeys, TPoint& point)
{
if (UpdateMode > 0) {
int line = point.y/CharHeight + GetTopIndex();
if (line != EditLine) {
EndEditLine();
TListBox::EvLButtonDown(modKeys, point);
return;
}
int index = ((point.x*2 - CharWidth)/(CharWidth*2) - AddrWidth*2)/3;
if (index >= 0 && index < Changes->Count) {
EditByte = index;
UpdateMode = 1;
TRect rect;
GetItemRect(EditLine, rect);
InvalidateRect(rect);
}
} else
TListBox::EvLButtonDown(modKeys, point);
}
void
TDumpView::EvLButtonDblClk(UINT /*modKeys*/, TPoint& point)
{
int index = ((point.x*2 - CharWidth)/(CharWidth*2) - AddrWidth*2)/3;
if (index < 0 || index >= DataWidth)
index = 0;
int line = point.y/CharHeight + GetTopIndex();
if (UpdateMode <= 0 || line != EditLine) {
// EndEditLine();
NewEditLine(line, index);
}
}
void
TDumpView::EvKeyDown(UINT key, UINT repeatCount, UINT flags)
{
char oldchr, newchr;
MSG msg;
if (UpdateMode <= 0) {
if (key != VK_LEFT && key != VK_RIGHT)
TListBox::EvKeyDown(key, repeatCount, flags);
return;
}
switch (key) {
case VK_ESCAPE: // abort changes to current line
CmEditUndo();
return;
case VK_RETURN: // enter changes for current line, not committed yet
EndEditLine();
break;
case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
key += ('0' + 10) - 'A'; // fall through to digit cases
case '0': case '1': case '2': case '3': case '4':
case '5': case '6': case '7': case '8': case '9':
newchr = char(key - '0');
oldchr = Changes->New[EditByte];
::PeekMessage(&msg, HWindow, WM_CHAR, WM_CHAR, PM_REMOVE);
switch(UpdateMode) {
case 1:
newchr = char((oldchr & 0x0F) + (newchr<<4));
break;
case 2:
newchr = char((oldchr & 0xF0) + newchr);
break;
default:
return;
}
Changes->New[EditByte] = newchr;
DeleteString(EditLine);
FormatLine(EditLine, Changes);
SetSelIndex(EditLine);
if (UpdateMode++ == 2 && EditByte < Changes->Count-1) {
EditByte++;
UpdateMode = 1;
}
break;
case VK_UP:
case VK_DOWN:
case VK_PRIOR:
case VK_NEXT:
case VK_END:
case VK_HOME:
if (UpdateMode > 0)
return;
break;
case VK_LEFT:
if (UpdateMode <= 0 || EditByte == 0)
return;
UpdateMode = 1;
EditByte--;
break;
case VK_RIGHT:
if (UpdateMode <= 0 || EditByte >= (Changes->Count-1))
return;
UpdateMode = 1;
EditByte++;
break;
default:
break;
}
TRect rect;
GetItemRect(EditLine, rect);
InvalidateRect(rect);
}
void
TDumpView::EvPaint()
{
TRegion updateRgn;
GetUpdateRgn(updateRgn);
DefaultProcessing(); // predefined listbox class will paint, don't call TWindow
if (UpdateMode <= 0)
return;
if (GetSelIndex() != EditLine) {
//::MessageBeep(MB_ICONEXCLAMATION);
return;
}
if (GetTopIndex() > EditLine || (GetTopIndex()+DisplayLines) <= EditLine)
return;
TRect rect;
GetItemRect(EditLine, rect);
rect.left += CharWidth * (AddrWidth*2+1+EditByte*3) + 1;
rect.right = rect.left + CharWidth * 2;
// should check if in update region!
TClientDC dc(HWindow);
// dc.SelectClipRgn(updateRgn);
// dc.IntersectClipRect(rect);
// dc.InvertRgn(updateRgn);
dc.InvertRgn(updateRgn &= rect);
}
void
TDumpView::CmEditUndo()
{
TRect rect;
TDumpData* edit;
UpdateMode = 0;
if (!Changes)
return;
int index = GetIndex(Changes->Addr);
DeleteString(index);
memcpy(Changes->New, Changes->Old, Changes->Count);
FormatLine(index, Changes);
SetSelIndex(index);
edit = Changes;
Changes = Changes->Next;
delete edit;
GetItemRect(index, rect);
InvalidateRect(rect);
}
void
TDumpView::CmEditItem()
{
int line = GetSelIndex();
if (UpdateMode > 0) {
if (line == EditLine)
return;
EndEditLine();
}
NewEditLine(line, 0);
}
IMPLEMENT_STREAMABLE2(TDumpView, TListBox, TView);
void*
TDumpView::Streamer::Read(ipstream& is, uint32 /*version*/) const
{
ReadBaseObject((TListBox*)GetObject(), is);
ReadBaseObject((TView*)GetObject(), is);
is >> GetObject()->Origin;
GetObject()->Init();
return GetObject();
}
void
TDumpView::Streamer::Write(opstream &os) const
{
WriteBaseObject((TListBox*)GetObject(), os);
WriteBaseObject((TView*)GetObject(), os);
os << GetObject()->Origin;
}
DEFINE_DOC_TEMPLATE_CLASS(TFileDocument, TDumpView, DumpTemplate);
DumpTemplate dumpTpl("DumpView, Binary files", "*.obj;*.res", 0, 0,
dtAutoDelete | dtUpdateDir);
@@ -0,0 +1,59 @@
//----------------------------------------------------------------------------
// ObjectWindows - (C) Copyright 1993 by Borland International
// Menu and accelerators for use with TDumpView
//----------------------------------------------------------------------------
#define CM_DUMPUNDO 24681
#define CM_DUMPCUT 24682
#define CM_DUMPCOPY 24683
#define CM_DUMPPASTE 24684
#define CM_DUMPEDIT 24688
#define IDM_DUMPVIEW 32382
#define IDA_DUMPVIEW 32382
#define IDS_DUMPNUM 32382
#if defined(RC_INVOKED)
IDM_DUMPVIEW MENU LOADONCALL MOVEABLE PURE DISCARDABLE
BEGIN
POPUP "&Edit"
BEGIN
MenuItem "&Undo\aCtrl+Z", CM_DUMPUNDO
MenuItem SEPARATOR
MenuItem "&Cut\aCtrl+X", CM_DUMPCUT
MenuItem "C&opy\aCtrl+C", CM_DUMPCOPY
MenuItem "&Paste\aCtrl+V", CM_DUMPPASTE
MenuItem "&Edit Item\aAlt+Enter",CM_DUMPEDIT
END
POPUP "&Help"
BEGIN
MenuItem "OWL DumpView", 0, INACTIVE
END
END
IDA_DUMPVIEW ACCELERATORS
BEGIN
"^z", CM_DUMPUNDO,
"^x", CM_DUMPCUT,
"^c", CM_DUMPCOPY,
"^v", CM_DUMPPASTE,
VK_DELETE, CM_DUMPCUT, VIRTKEY, SHIFT
VK_INSERT, CM_DUMPCOPY, VIRTKEY, CONTROL
VK_INSERT, CM_DUMPPASTE, VIRTKEY, SHIFT
VK_BACK, CM_DUMPUNDO, VIRTKEY, ALT
VK_RETURN, CM_DUMPEDIT, VIRTKEY
END
STRINGTABLE LOADONCALL MOVEABLE DISCARDABLE
BEGIN
CM_DUMPUNDO, "Reverses the last operation"
CM_DUMPCUT, "Cuts the selection and puts it on the Clipboard"
CM_DUMPCOPY, "Copies the selection to the Clipboard"
CM_DUMPPASTE, "Inserts the Clipboard contents at the caret"
CM_DUMPEDIT, "Edit the current line"
IDS_DUMPNUM, "Address %d"
END
#endif // defined(RC_INVOKED)
@@ -0,0 +1,108 @@
//----------------------------------------------------------------------------
// ObjectWindows - (C) Copyright 1993 by Borland International
// Provides TModuleDoc class to dynamically load new document/view classes
//----------------------------------------------------------------------------
#include <owl\owlpch.h>
#include <owl\docmanag.h>
#include "dvloader.rc"
class TModuleDocument : public TDocument {
public:
TModuleDocument(TDocument* parent=0) : TDocument(parent), Module(0) {}
~TModuleDocument() { Close(); }
BOOL Open(int mode, const char far* path=0);
BOOL Close();
BOOL IsOpen() { return Module != 0; }
protected:
TModule* Module;
DECLARE_STREAMABLE(, TModuleDocument,1);
};
class TModuleView : public TView {
public:
TModuleView(TDocument& doc, TWindow* parent = 0) : TView(doc) {
doc.GetDocManager().PostDocError(doc, IDS_DVLOADED);
NotOK();
}
static LPCSTR StaticName() {return "Module View";}
LPCSTR GetViewName() {return StaticName();}
};
BOOL TModuleDocument::Open(int /*mode*/, const char far* path)
{
if (IsOpen())
return TRUE;
if (path)
SetDocPath(path);
if (!GetDocPath())
return FALSE;
try {
Module = new TModule(GetDocPath());
}
catch(TXOwl&) {
return FALSE;
}
TDocTemplate** tplhead;
TDocTemplate** PASCAL(*entry)(int version);
(FARPROC)entry = Module->GetProcAddress("GetDocTemplateHead");
if (!entry || (tplhead = entry(OWLVersion)) == 0) {
delete Module;
Module = 0;
return FALSE;
}
TDocTemplate* tpl = *tplhead;
for (; tpl; tpl = GetDocManager().GetNextTemplate(tpl))
tpl->Clone(Module)->SetDocManager(&GetDocManager());
return TRUE;
}
BOOL TModuleDocument::Close()
{
if (!IsOpen())
return TRUE;
TDocTemplate* tpl;
TDocTemplate* next;
for (tpl = GetDocManager().GetNextTemplate(0); tpl; tpl = next) {
next = GetDocManager().GetNextTemplate(tpl);
if (*tpl->GetModule() == *Module) {
// must remove any remaining associated documents before freeing module
TDocument* doc;
TDocument* next;
for (doc = GetDocManager().DocList.Next(0); doc; doc = next) {
next = GetDocManager().DocList.Next(doc);
if (doc->GetTemplate() == tpl){
doc->Close();
delete doc;
}
}
GetDocManager().DeleteTemplate(*tpl); // RefCnt should go to 0 now
}
}
delete Module;
Module = 0;
return TRUE;
}
IMPLEMENT_STREAMABLE1(TModuleDocument, TDocument);
void*
TModuleDocument::Streamer::Read(ipstream& is, uint32 /*version*/) const
{
ReadBaseObject((TDocument*)GetObject(), is);
is >> GetObject()->Module;
return GetObject();
}
void
TModuleDocument::Streamer::Write(opstream& os) const
{
WriteBaseObject((TDocument*)GetObject(), os);
os << GetObject()->Module;
}
DEFINE_DOC_TEMPLATE_CLASS(TModuleDocument, TModuleView, LoadTemplate);
LoadTemplate loadTpl("DocView Components (*.DVC)","*.dvc",0,0,
dtAutoOpen|dtUpdateDir|dtReadOnly|dtHideReadOnly);
@@ -0,0 +1,14 @@
//----------------------------------------------------------------------------
// ObjectWindows - (C) Copyright 1993 by Borland International
// Resources for doc/view loader document
//----------------------------------------------------------------------------
#define IDS_DVLOADED 25880
#ifdef RC_INVOKED
STRINGTABLE
{
IDS_DVLOADED, "Document/view loaded"
}
#endif
@@ -0,0 +1,20 @@
//----------------------------------------------------------------------------
// ObjectWindows - (C) Copyright 1993 by Borland International
// Provides templates and DLL access to TEditView and TListView
//----------------------------------------------------------------------------
#include <owl\owlpch.h>
#include <owl\listview.h>
#include <owl\editview.h>
#include <owl\filedoc.h>
#include <owl\docmanag.h>
DEFINE_DOC_TEMPLATE_CLASS(TFileDocument, TListView, ListTemplate);
DEFINE_DOC_TEMPLATE_CLASS(TFileDocument, TEditView, EditTemplate);
_OWLLINK(rTListView); // force TListView::Streamer to be linked in
_OWLLINK(rTEditView); // force TEditView::Streamer to be linked in
EditTemplate atpl("Text files, EditView", "*.txt", 0, "TXT", dtAutoDelete|dtUpdateDir);
ListTemplate btpl("Text files, ListView", "*.txt", 0, "TXT", dtAutoDelete|dtUpdateDir);
ListTemplate ctpl("Batch files, ListView", "*.bat", 0, "BAT", dtAutoDelete|dtUpdateDir);
EditTemplate dtpl("Source files, EditView", "*.cpp;*.h",0,0,dtAutoDelete|dtUpdateDir);
@@ -0,0 +1,5 @@
//----------------------------------------------------------------------------
// ObjectWindows - (C) Copyright 1993 by Borland International
//----------------------------------------------------------------------------
#include <owl\listview.rc>
#include <owl\editview.rc>
@@ -0,0 +1,205 @@
//----------------------------------------------------------------------------
// ObjectWindows - (C) Copyright 1993 by Borland International
// Implements class TInfoView
//----------------------------------------------------------------------------
#include <owl\owlpch.h>
#include <owl\docmanag.h>
#include <owl\filedoc.h>
#include <owl\dc.h>
#include "infoview.rc"
class _DOCVIEWCLASS TInfoView : public TWindowView {
public:
struct Data {
const char* PropName;
char* PropData;
int PropSize;
int PropFlags;
};
TInfoView(TDocument& doc, TWindow* parent = 0);
~TInfoView();
static LPCSTR StaticName() {return "Info View";} // put in resource
LPCSTR GetViewName() {return StaticName();}
BOOL SetDocTitle(LPCSTR docname, int index)
{ Invalidate(); return TWindow::SetDocTitle(docname, index); }
void Paint(TDC&, BOOL, TRect&);
protected:
Data* PropList;
int PropCount;
int YLoc;
int OpenCount; //temp
int CloseCount; //temp
void GetInfo();
void Init();
//
// event handlers
//
void CmInfoOpen();
BOOL VnViewOpened(TView*);
BOOL VnViewClosed(TView*);
BOOL VnDocOpened(int omode);
BOOL VnDocClosed(int omode);
BOOL VnIsWindow(HWND hWnd) {return HWindow == hWnd;}
DECLARE_RESPONSE_TABLE(TInfoView);
DECLARE_STREAMABLE(,TInfoView,1);
};
DEFINE_RESPONSE_TABLE1(TInfoView, TWindow)
EV_COMMAND(CM_INFOOPEN, CmInfoOpen),
EV_VN_DOCOPENED,
EV_VN_DOCCLOSED,
EV_VN_VIEWOPENED,
EV_VN_VIEWCLOSED,
EV_VN_ISWINDOW,
END_RESPONSE_TABLE;
TInfoView::TInfoView(TDocument& doc,TWindow* parent) : TWindowView(doc,parent)
{
Attr.Style &= ~(WS_BORDER);
SetViewMenu(new TMenuDescr(IDM_INFOVIEW,0,1,0,0,0,1));
Init();
}
void TInfoView::Init()
{
PropCount = Doc->PropertyCount();
PropList = new Data[PropCount];
for (int i = 0; i < PropCount; i++) {
PropList[i].PropName = Doc->PropertyName(i+1);
PropList[i].PropFlags = Doc->PropertyFlags(i+1);
PropList[i].PropData = 0;
}
OpenCount = CloseCount = 0; //temp
GetInfo();
}
TInfoView::~TInfoView()
{
for (int i = 0; i < PropCount; i++) {
delete PropList[i].PropData;
}
delete PropList;
}
void TInfoView::GetInfo()
{
BOOL changed = FALSE;
int prop;
int len;
char buf[256+1];
for (prop = 0; prop < PropCount; prop++) {
int flags = PropList[prop].PropFlags;
if ((flags & pfGetText) && !(flags & pfHidden)
&& (len = Doc->GetProperty(prop+1, buf, sizeof(buf)-1)) != 0) {
if (PropList[prop].PropData) {
if (flags & pfConstant)
continue;
if (len == PropList[prop].PropSize) {
if (strcmp(buf, PropList[prop].PropData) != 0) {
strcpy(PropList[prop].PropData, buf);
changed = TRUE;
}
continue;
}
delete PropList[prop].PropData;
}
PropList[prop].PropData = strnewdup(buf);
PropList[prop].PropSize = len;
changed = TRUE;
}
}
if (changed)
Invalidate();
}
// len = wsprintf(buf, "Document State: %s (Opens=%d Closes=%d)", (char far*)(Doc->IsOpen() ? "Open" : "Closed"),OpenCount,CloseCount);
void TInfoView::Paint(TDC& dc, BOOL /*erase*/, TRect&)
{
TSize size;
static char separator[] = " = ";
int sepsize;
int prop;
YLoc = 0;
dc.GetTextExtent(separator, sizeof(separator)-1, size);
sepsize = size.cx;
for (prop = 0; prop < PropCount; prop++) {
if (!PropList[prop].PropData)
continue;
int len = strlen(PropList[prop].PropName);
dc.GetTextExtent( PropList[prop].PropName, len, size);
dc.TextOut(0, YLoc, PropList[prop].PropName, len);
dc.TextOut(size.cx, YLoc, separator, sizeof(separator)-1);
dc.TextOut(size.cx+sepsize, YLoc, PropList[prop].PropData,
strlen(PropList[prop].PropData));
YLoc += size.cy;
}
}
void
TInfoView::CmInfoOpen()
{
if (!Doc->IsOpen()
&& Doc->GetDocPath() != 0
&& Doc->Open(ofRead | shReadWrite | ofNoCreate | ofPriority)) {
// GetInfo();
Doc->Close();
OpenCount--; CloseCount--;
}
}
BOOL
TInfoView::VnViewOpened(TView*)
{
GetInfo();
return TRUE;
}
BOOL
TInfoView::VnViewClosed(TView*)
{
GetInfo();
return TRUE;
}
BOOL
TInfoView::VnDocOpened(int)
{
++OpenCount;
GetInfo();
return TRUE;
}
BOOL
TInfoView::VnDocClosed(int)
{
++CloseCount;
GetInfo();
return TRUE;
}
IMPLEMENT_STREAMABLE1(TInfoView, TWindowView);
void*
TInfoView::Streamer::Read(ipstream& is, uint32 /*version*/) const
{
ReadBaseObject((TWindowView*)GetObject(), is);
GetObject()->Init();
return GetObject();
}
void
TInfoView::Streamer::Write(opstream &os) const
{
WriteBaseObject((TWindowView*)GetObject(), os);
}
DEFINE_DOC_TEMPLATE_CLASS(TFileDocument, TInfoView, InfoTemplate);
InfoTemplate infoTpl("InfoView, All files", "*.*", 0, 0,dtAutoDelete|dtReadOnly);
@@ -0,0 +1,28 @@
//----------------------------------------------------------------------------
// ObjectWindows - (C) Copyright 1993 by Borland International
// Menu and accelerators for use with TInfoView
//----------------------------------------------------------------------------
#define CM_INFOOPEN 24521
#define IDM_INFOVIEW 31521
#if defined(RC_INVOKED)
IDM_INFOVIEW MENU LOADONCALL MOVEABLE PURE DISCARDABLE
BEGIN
POPUP "&Edit"
BEGIN
MenuItem "&Open", CM_INFOOPEN
END
POPUP "&Help"
BEGIN
MenuItem "OWL InfoView", 0, INACTIVE
END
END
STRINGTABLE LOADONCALL MOVEABLE DISCARDABLE
BEGIN
CM_INFOOPEN, "Opens the file to get info"
END
#endif // defined(RC_INVOKED)
@@ -0,0 +1,836 @@
//----------------------------------------------------------------------------
// ObjectWindows - (C) Copyright 1991, 1993 by Borland International
// Implements classes TDrawDocument, TDrawView, TDrawListView
//----------------------------------------------------------------------------
#include <owl\owlpch.h>
#include <owl\docmanag.h>
#include <owl\filedoc.h>
#include <owl\dc.h>
#include <owl\inputdia.h>
#include <owl\chooseco.h>
#include <owl\gdiobjec.h>
#include <owl\listbox.h>
#include <owl\docview.h>
#include <classlib\arrays.h>
#include "linedoc.rc"
typedef TArray<TPoint> TPoints;
typedef TArrayIterator<TPoint> TPointsIterator;
class TLine : public TPoints {
public:
// Constructor to allow construction from a color and a pen size.
// Also serves as default constructor.
TLine(const TColor &color = TColor(0), int penSize = 1)
: TPoints(10, 0, 10), PenSize(penSize), Color(color) {}
// Functions to modify and query pen attributes.
int QueryPenSize() const { return PenSize; }
const TColor& QueryColor() const { return Color; }
void SetPen(TColor &newColor, int penSize = 0);
void SetPen(int penSize);
BOOL GetPenSize();
BOOL GetPenColor();
// TLine draws itself. Returns TRUE if everything went OK.
virtual BOOL Draw(TDC &) const;
// The == operator must be defined for the container class, even if unused
BOOL operator ==(const TLine& other) const { return &other == this; }
friend ostream& operator <<(ostream& os, const TLine& line);
friend istream& operator >>(istream& is, TLine& line);
protected:
int PenSize;
TColor Color;
};
typedef TArray<TLine> TLines;
typedef TArrayIterator<TLine> TLinesIterator;
class _DOCVIEWCLASS TDrawDocument : public TFileDocument
{
public:
enum {
PrevProperty = TFileDocument::NextProperty-1,
LineCount,
Description,
NextProperty,
};
enum {
UndoNone,
UndoDelete,
UndoAppend,
UndoModify
};
TDrawDocument(TDocument* parent = 0)
: TFileDocument(parent), Lines(0), UndoLine(0), UndoState(UndoNone) {}
~TDrawDocument() { delete Lines; delete UndoLine; }
// implement virtual methods of TDocument
BOOL Open(int mode, const char far* path=0);
BOOL Close();
BOOL IsOpen() { return Lines != 0; }
BOOL Commit(BOOL force = FALSE);
BOOL Revert(BOOL clear = FALSE);
int FindProperty(const char far* name); // return index
int PropertyFlags(int index);
const char* PropertyName(int index);
int PropertyCount() {return NextProperty - 1;}
int GetProperty(int index, void far* dest, int textlen=0);
// data access functions
const TLine* GetLine(unsigned int index);
int AddLine(TLine& line);
void DeleteLine(unsigned int index);
void ModifyLine(TLine& line, unsigned int index);
void Clear();
void Undo();
protected:
TLines* Lines;
TLine* UndoLine;
int UndoState;
int UndoIndex;
string FileInfo;
DECLARE_STREAMABLE(, TDrawDocument,1);
};
class _DOCVIEWCLASS TDrawView : public TWindowView
{
public:
TDrawView(TDrawDocument& doc, TWindow *parent = 0);
~TDrawView() {delete DragDC; delete Line;}
static const char far* StaticName() {return "Draw View";}
const char far* GetViewName(){return StaticName();}
protected:
TDrawDocument* DrawDoc; // same as Doc member, but cast to derived class
TDC *DragDC;
TPen *Pen;
TLine *Line; // To hold a single line sent or received from document
// Message response functions
void EvLButtonDown(UINT, TPoint&);
void EvRButtonDown(UINT, TPoint&);
void EvMouseMove(UINT, TPoint&);
void EvLButtonUp(UINT, TPoint&);
void Paint(TDC&, BOOL, TRect&);
void CmPenSize();
void CmPenColor();
void CmClear();
void CmUndo();
// Document notifications
BOOL VnCommit(BOOL force);
BOOL VnRevert(BOOL clear);
BOOL VnAppend(unsigned int index);
BOOL VnDelete(unsigned int index);
BOOL VnModify(unsigned int index);
DECLARE_RESPONSE_TABLE(TDrawView);
DECLARE_STREAMABLE(,TDrawView,1);
};
class _DOCVIEWCLASS TDrawListView : public TListBox, public TView {
public:
TDrawListView(TDrawDocument& doc, TWindow* parent = 0);
~TDrawListView(){}
static const char far* StaticName() {return "DrawList View";}
// Overridden virtuals from TView
//
const char far* GetViewName(){return StaticName();}
TWindow* GetWindow() {return (TWindow*)this;}
BOOL SetDocTitle(const char far* docname, int index)
{return TListBox::SetDocTitle(docname, index); }
// Overridden virtuals from TWindow
//
BOOL CanClose() {return TListBox::CanClose() && Doc->CanClose();}
BOOL Create();
protected:
TDrawDocument* DrawDoc; // same as Doc member, but cast to derived class
void LoadData();
void FormatData(const TLine* line, unsigned int index);
// Message response functions
void CmPenSize();
void CmPenColor();
void CmClear();
void CmUndo();
void CmDelete();
// Document notifications
BOOL VnIsWindow(HWND hWnd) {return HWindow == hWnd;}
BOOL VnCommit(BOOL force);
BOOL VnRevert(BOOL clear);
BOOL VnAppend(unsigned int index);
BOOL VnDelete(unsigned int index);
BOOL VnModify(unsigned int index);
DECLARE_RESPONSE_TABLE(TDrawListView);
DECLARE_STREAMABLE(,TDrawListView,1);
};
const int vnDrawAppend = vnCustomBase+0;
const int vnDrawDelete = vnCustomBase+1;
const int vnDrawModify = vnCustomBase+2;
NOTIFY_SIG(vnDrawAppend, unsigned int)
NOTIFY_SIG(vnDrawDelete, unsigned int)
NOTIFY_SIG(vnDrawModify, unsigned int)
#define EV_VN_DRAWAPPEND VN_DEFINE(vnDrawAppend, VnAppend, int)
#define EV_VN_DRAWDELETE VN_DEFINE(vnDrawDelete, VnDelete, int)
#define EV_VN_DRAWMODIFY VN_DEFINE(vnDrawModify, VnModify, int)
DEFINE_DOC_TEMPLATE_CLASS(TDrawDocument, TDrawView, DrawTemplate);
DEFINE_DOC_TEMPLATE_CLASS(TDrawDocument, TDrawListView, DrawListTemplate);
DrawTemplate drawTpl("Draw Line Files (*.PTS)","*.pts",0,"PTS",dtAutoDelete|dtUpdateDir);
DrawListTemplate drawListTpl("Line List"," *.pts",0,"PTS",dtAutoDelete|dtHidden);
void TLine::SetPen(int penSize)
{
if (penSize < 1)
PenSize = 1;
else
PenSize = penSize;
}
void TLine::SetPen(TColor &newColor, int penSize)
{
// If penSize isn't the default (0), set PenSize to the new size.
if (penSize)
PenSize = penSize;
Color = newColor;
}
BOOL TLine::Draw(TDC &dc) const
{
// Set pen for the dc to the values for this line
TPen pen(Color, PenSize);
dc.SelectObject(pen);
// Iterates through the points in the line i.
TPointsIterator j(*this);
BOOL first = TRUE;
while (j) {
TPoint p = j++;
if (!first)
dc.LineTo(p);
else {
dc.MoveTo(p);
first = FALSE;
}
}
dc.RestorePen();
return TRUE;
}
ostream& operator <<(ostream& os, const TLine& line)
{
// Write the number of points in the line
os << line.GetItemsInContainer();
// Get and write pen attributes.
os << ' ' << line.Color << ' ' << line.PenSize;
// Get an iterator for the array of points
TPointsIterator j(line);
// While the iterator is valid (i.e. we haven't run out of points)
while(j)
// Write the point from the iterator and increment the array.
os << j++;
os << '\n';
// return the stream object
return os;
}
istream& operator >>(istream& is, TLine& line)
{
unsigned numPoints;
is >> numPoints;
COLORREF color;
int penSize;
is >> color >> penSize;
line.SetPen(TColor(color), penSize);
while (numPoints--) {
TPoint point;
is >> point;
line.Add(point);
}
// return the stream object
return is;
}
BOOL TDrawDocument::Commit(BOOL force)
{
if (!IsDirty() && !force)
return TRUE;
TOutStream* os = OutStream(ofWrite);
if (!os)
return FALSE;
// Write the number of lines in the figure
*os << Lines->GetItemsInContainer();
// Append a description using a resource string
*os << ' ' << FileInfo << '\n';
// Get an iterator for the array of lines
TLinesIterator i(*Lines);
// While the iterator is valid (i.e. we haven't run out of lines)
while (i) {
// Copy the current line from the iterator and increment the array.
*os << i++;
}
delete os;
SetDirty(FALSE);
return TRUE;
}
BOOL TDrawDocument::Revert(BOOL clear)
{
if (!TFileDocument::Revert(clear))
return FALSE;
if (!clear)
Open(0);
return TRUE;
}
BOOL TDrawDocument::Open(int /*mode*/, const char far* path)
{
char fileinfo[100];
Lines = new TLines(5, 0, 5);
if (path)
SetDocPath(path);
if (GetDocPath()) {
TInStream* is = InStream(ofRead);
if (!is)
return FALSE;
unsigned numLines;
*is >> numLines;
is->getline(fileinfo, sizeof(fileinfo));
while (numLines--) {
TLine line;
*is >> line;
Lines->Add(line);
}
delete is;
FileInfo = fileinfo;
} else {
FileInfo = string(*::Module,IDS_FILEINFO);
}
SetDirty(FALSE);
UndoState = UndoNone;
return TRUE;
}
BOOL TDrawDocument::Close()
{
delete Lines;
Lines = 0;
return TRUE;
}
const TLine* TDrawDocument::GetLine(unsigned int index)
{
if (!IsOpen() && !Open(ofRead | ofWrite))
return 0;
return index < Lines->GetItemsInContainer() ? &(*Lines)[index] : 0;
}
int TDrawDocument::AddLine(TLine& line)
{
int index = Lines->GetItemsInContainer();
Lines->Add(line);
SetDirty(TRUE);
NotifyViews(vnDrawAppend, index);
UndoState = UndoAppend;
return index;
}
void TDrawDocument::DeleteLine(unsigned int index)
{
const TLine* oldLine = GetLine(index);
if (!oldLine)
return;
delete UndoLine;
UndoLine = new TLine(*oldLine);
Lines->Detach(index);
SetDirty(TRUE);
NotifyViews(vnDrawDelete, index);
UndoState = UndoDelete;
}
void TDrawDocument::ModifyLine(TLine& line, unsigned int index)
{
delete UndoLine;
UndoLine = new TLine((*Lines)[index]);
SetDirty(TRUE);
(*Lines)[index] = line;
NotifyViews(vnDrawModify, index);
UndoState = UndoModify;
UndoIndex = index;
}
void TDrawDocument::Clear()
{
Lines->Flush();
NotifyViews(vnRevert, TRUE);
}
void TDrawDocument::Undo()
{
switch (UndoState) {
case UndoAppend:
DeleteLine(Lines->GetItemsInContainer()-1);
return;
case UndoDelete:
AddLine(*UndoLine);
delete UndoLine;
UndoLine = 0;
return;
case UndoModify:
TLine* temp = UndoLine;
UndoLine = 0;
ModifyLine(*temp, UndoIndex);
delete temp;
}
}
BOOL TLine::GetPenSize()
{
char inputText[6];
wsprintf(inputText, "%d", PenSize);
if (TInputDialog(0, "Line Thickness",
"Input a new thickness:",
inputText,
sizeof(inputText),::Module).Execute() != IDOK)
return FALSE;
PenSize = atoi(inputText);
if (PenSize < 1)
PenSize = 1;
return TRUE;
}
BOOL TLine::GetPenColor()
{
TChooseColorDialog::TData colors;
static TColor custColors[16] =
{
0x010101L, 0x101010L, 0x202020L, 0x303030L,
0x404040L, 0x505050L, 0x606060L, 0x707070L,
0x808080L, 0x909090L, 0xA0A0A0L, 0xB0B0B0L,
0xC0C0C0L, 0xD0D0D0L, 0xE0E0E0L, 0xF0F0F0L
};
colors.Flags = CC_RGBINIT;
colors.Color = TColor(QueryColor());
colors.CustColors = custColors;
if (TChooseColorDialog(0, colors).Execute() != IDOK)
return FALSE;
SetPen(colors.Color);
return TRUE;
}
DEFINE_RESPONSE_TABLE1(TDrawView, TWindowView)
EV_WM_LBUTTONDOWN,
EV_WM_RBUTTONDOWN,
EV_WM_MOUSEMOVE,
EV_WM_LBUTTONUP,
EV_COMMAND(CM_PENSIZE, CmPenSize),
EV_COMMAND(CM_PENCOLOR, CmPenColor),
EV_COMMAND(CM_CLEAR, CmClear),
EV_COMMAND(CM_UNDO, CmUndo),
EV_VN_COMMIT,
EV_VN_REVERT,
EV_VN_DRAWAPPEND,
EV_VN_DRAWDELETE,
EV_VN_DRAWMODIFY,
END_RESPONSE_TABLE;
TDrawView::TDrawView(TDrawDocument& doc,TWindow *parent)
: TWindowView(doc,parent), DrawDoc(&doc)
{
DragDC = 0;
Line = new TLine(TColor::Black, 1);
SetViewMenu(new TMenuDescr(IDM_DRAWVIEW,0,2,0,0,0,1));
}
void TDrawView::EvLButtonDown(UINT, TPoint& point)
{
if (!DragDC) {
SetCapture();
DragDC = new TClientDC(*this);
Pen = new TPen(Line->QueryColor(), Line->QueryPenSize());
DragDC->SelectObject(*Pen);
DragDC->MoveTo(point);
Line->Add(point);
}
}
void TDrawView::EvRButtonDown(UINT, TPoint&)
{
CmUndo();
}
void TDrawView::EvMouseMove(UINT, TPoint& point)
{
if (DragDC) {
DragDC->LineTo(point);
Line->Add(point);
}
}
void TDrawView::EvLButtonUp(UINT, TPoint&)
{
if (DragDC) {
ReleaseCapture();
if (Line->GetItemsInContainer() > 1)
DrawDoc->AddLine(*Line);
Line->Flush();
delete DragDC;
delete Pen;
DragDC = 0;
}
}
void TDrawView::CmPenSize()
{
Line->GetPenSize();
}
void TDrawView::CmPenColor()
{
Line->GetPenColor();
}
void TDrawView::CmClear()
{
DrawDoc->Clear();
}
void TDrawView::CmUndo()
{
DrawDoc->Undo();
}
void TDrawView::Paint(TDC& dc, BOOL, TRect&)
{
// Iterates through the array of line objects.
int i = 0;
const TLine* line;
while ((line = DrawDoc->GetLine(i++)) != 0)
line->Draw(dc);
}
BOOL TDrawView::VnCommit(BOOL /*force*/)
{
// nothing to do here, no data held in view
return TRUE;
}
BOOL TDrawView::VnRevert(BOOL /*clear*/)
{
Invalidate(); // force full repaint
return TRUE;
}
BOOL TDrawView::VnAppend(unsigned int index)
{
TClientDC dc(*this);
const TLine* line = DrawDoc->GetLine(index);
line->Draw(dc);
return TRUE;
}
BOOL TDrawView::VnModify(unsigned int /*index*/)
{
Invalidate(); // force full repaint
return TRUE;
}
BOOL TDrawView::VnDelete(unsigned int /*index*/)
{
Invalidate(); // force full repaint
return TRUE;
}
DEFINE_RESPONSE_TABLE1(TDrawListView, TListBox)
EV_COMMAND(CM_PENSIZE, CmPenSize),
EV_COMMAND(CM_PENCOLOR, CmPenColor),
EV_COMMAND(CM_CLEAR, CmClear),
EV_COMMAND(CM_UNDO, CmUndo),
EV_COMMAND(CM_DELETE, CmDelete),
EV_VN_ISWINDOW,
EV_VN_COMMIT,
EV_VN_REVERT,
EV_VN_DRAWAPPEND,
EV_VN_DRAWDELETE,
EV_VN_DRAWMODIFY,
END_RESPONSE_TABLE;
TDrawListView::TDrawListView(TDrawDocument& doc,TWindow *parent)
: TView(doc), TListBox(parent, GetNextViewId(), 0,0,0,0), DrawDoc(&doc)
{
Attr.Style &= ~(WS_BORDER | LBS_SORT);
Attr.AccelTable = IDA_DRAWLISTVIEW;
SetViewMenu(new TMenuDescr(IDM_DRAWLISTVIEW,0,1,0,0,0,1));
}
BOOL TDrawListView::Create()
{
TListBox::Create();
LoadData();
return TRUE;
}
void TDrawListView::LoadData()
{
ClearList();
int i = 0;
const TLine* line;
while ((line = DrawDoc->GetLine(i)) != 0)
FormatData(line, i++);
SetSelIndex(0);
}
void TDrawListView::FormatData(const TLine* line, int unsigned index)
{
char buf[80];
TColor color(line->QueryColor());
wsprintf(buf, "Color = R%d G%d B%d, Size = %d, Points = %d",
color.Red(), color.Green(), color.Blue(),
line->QueryPenSize(), line->GetItemsInContainer());
DeleteString(index);
InsertString(buf, index);
SetSelIndex(index);
}
void TDrawListView::CmPenSize()
{
int index = GetSelIndex();
const TLine* line = DrawDoc->GetLine(index);
if (line) {
TLine* newline = new TLine(*line);
if (newline->GetPenSize())
DrawDoc->ModifyLine(*newline, index);
delete newline;
}
}
void TDrawListView::CmPenColor()
{
int index = GetSelIndex();
const TLine* line = DrawDoc->GetLine(index);
if (line) {
TLine* newline = new TLine(*line);
if (newline->GetPenColor())
DrawDoc->ModifyLine(*newline, index);
delete newline;
}
}
void TDrawListView::CmClear()
{
DrawDoc->Clear();
}
void TDrawListView::CmUndo()
{
DrawDoc->Undo();
}
void TDrawListView::CmDelete()
{
DrawDoc->DeleteLine(GetSelIndex());
}
BOOL TDrawListView::VnCommit(BOOL /*force*/)
{
return TRUE;
}
BOOL TDrawListView::VnRevert(BOOL /*clear*/)
{
LoadData();
return TRUE;
}
BOOL TDrawListView::VnAppend(unsigned int index)
{
const TLine* line = DrawDoc->GetLine(index);
FormatData(line, index);
SetSelIndex(index);
return TRUE;
}
BOOL TDrawListView::VnDelete(unsigned int index)
{
DeleteString(index);
HandleMessage(WM_KEYDOWN,VK_DOWN); // force selection
return TRUE;
}
BOOL TDrawListView::VnModify(unsigned int index)
{
const TLine* line = DrawDoc->GetLine(index);
FormatData(line, index);
return TRUE;
}
static char* PropNames[] = {
"Line Count", // LineCount
"Description", // Description
};
static int PropFlags[] = {
pfGetBinary|pfGetText, // LineCount
pfGetText, // Description
};
const char*
TDrawDocument::PropertyName(int index)
{
if (index <= PrevProperty)
return TFileDocument::PropertyName(index);
else if (index < NextProperty)
return PropNames[index-PrevProperty-1];
else
return 0;
}
int
TDrawDocument::PropertyFlags(int index)
{
if (index <= PrevProperty)
return TFileDocument::PropertyFlags(index);
else if (index < NextProperty)
return PropFlags[index-PrevProperty-1];
else
return 0;
}
int
TDrawDocument::FindProperty(const char far* name)
{
for (int i=0; i < NextProperty-PrevProperty-1; i++)
if (strcmp(PropNames[i], name) == 0)
return i+PrevProperty+1;
return 0;
}
int
TDrawDocument::GetProperty(int prop, void far* dest, int textlen)
{
if (IsOpen())
switch(prop)
{
case LineCount:
{
int count = Lines->GetItemsInContainer();
if (!textlen) {
*(int far*)dest = count;
return sizeof(int);
}
return wsprintf((char far*)dest, "%d", count);
}
case Description:
char* temp = new char[textlen]; // need local copy for medium model
int len = FileInfo.copy(temp, textlen);
strcpy((char far*)dest, temp);
return len;
}
return TFileDocument::GetProperty(prop, dest, textlen);
}
IMPLEMENT_STREAMABLE1(TDrawDocument, TFileDocument);
void*
TDrawDocument::Streamer::Read(ipstream& is, uint32 /*version*/) const
{
TDrawDocument* o = GetObject();
o->UndoState = UndoNone;
o->UndoLine = 0;
o->Lines = 0;
ReadBaseObject((TFileDocument*)o, is);
return o;
}
void
TDrawDocument::Streamer::Write(opstream& os) const
{
WriteBaseObject((TFileDocument*)GetObject(), os);
}
IMPLEMENT_STREAMABLE1(TDrawView, TWindowView);
void*
TDrawView::Streamer::Read(ipstream& is, uint32 /*version*/) const
{
TDrawView* o = GetObject();
ReadBaseObject((TWindowView*)o, is);
is >> o->DrawDoc;
int width;
COLORREF color;
is >> width >> color;
o->Line = new TLine(TColor(color), width);
o->DragDC = 0;
return o;
}
void
TDrawView::Streamer::Write(opstream &os) const
{
TDrawView* o = GetObject();
WriteBaseObject((TWindowView*)o, os);
os << o->DrawDoc;
os << o->Line->QueryPenSize();
os << COLORREF(o->Line->QueryColor());
}
IMPLEMENT_STREAMABLE2(TDrawListView, TListBox, TView);
void*
TDrawListView::Streamer::Read(ipstream& is, uint32 /*version*/) const
{
TDrawListView* o = GetObject();
ReadBaseObject((TListBox*)o, is);
ReadBaseObject((TView*)o, is);
is >> o->DrawDoc;
return o;
}
void
TDrawListView::Streamer::Write(opstream &os) const
{
TDrawListView* o = GetObject();
WriteBaseObject((TListBox*)o, os);
WriteBaseObject((TView*)o, os);
os << o->DrawDoc;
}

Binary file not shown.
@@ -0,0 +1,71 @@
//----------------------------------------------------------------------------
// ObjectWindows - (C) Copyright 1991, 1993 by Borland International
// Resources for TDrawView and TDrawListView
//----------------------------------------------------------------------------
#define CM_PENSIZE 206
#define CM_PENCOLOR 207
#define CM_UNDO 208
#define CM_CLEAR 209
#define CM_DELETE 210
#define IDM_DRAWVIEW 212
#define IDM_DRAWLISTVIEW 213
#define IDA_DRAWLISTVIEW 213
#define IDS_FILEINFO 215
#ifdef RC_INVOKED
#include <owl\inputdia.rc>
IDM_DRAWVIEW MENU
{
POPUP "&Edit"
{
MENUITEM "&Undo", CM_UNDO
MENUITEM "&Clear", CM_CLEAR
}
POPUP "&Tools"
{
MENUITEM "Pen &Size", CM_PENSIZE
MENUITEM "Pen &Color", CM_PENCOLOR
}
POPUP "&Help"
{
MENUITEM "OWL Line Draw", 0, INACTIVE
}
}
IDM_DRAWLISTVIEW MENU
{
POPUP "&Edit"
{
MENUITEM "Pen &Size", CM_PENSIZE
MENUITEM "Pen &Color", CM_PENCOLOR
MENUITEM "&Delete Line",CM_DELETE
MENUITEM "&Undo", CM_UNDO
MENUITEM "Clear All", CM_CLEAR
}
POPUP "&Help"
{
MENUITEM "OWL Line Draw List", 0, INACTIVE
}
}
IDA_DRAWLISTVIEW ACCELERATORS
BEGIN
VK_DELETE, CM_DELETE, VIRTKEY, SHIFT
VK_BACK, CM_UNDO, VIRTKEY, ALT
END
STRINGTABLE
{
CM_PENSIZE, "Changes the pen width"
CM_PENCOLOR, "Changes the pen color"
CM_DELETE, "Erase selected line"
CM_CLEAR, "Erase all lines"
CM_UNDO, "Undo last action"
IDS_FILEINFO, "Lines from TLineDocument"
}
#endif // RC_INVOKED
@@ -0,0 +1,62 @@
#----------------------------------------------------------------------------
# ObjectWindows - (C) Copyright 1993 by Borland International
# Use MODEL=m|l|d|f to statically link documents and viewers to application
# Use MODEL=x to build dynamically loaded document/view components
#
# This example combines an empty desktop with a variety of documents/views.
# The list of document/view modules is specified below by DOCVIEW = {obj list}.
# Document/view object files may be added or removed as desired from this list.
# Each document/view file must include document template(s) for their classes.
# The following document/view files are included in this examples:
# editlist.cpp - templates only, uses ObjectWindows TListView and TEditView
# dumpview.cpp - hex dump viewer/editor using TFileDocument
# odlistvw.cpp - owner-draw listbox viewer derived from example TODListBox
# infoview.cpp - viewer which displays all properties from any document
# xcptview.cpp - view which generates and logs a variety of exceptions
# linedoc.cpp - graphic line document with graphic and listbox viewers
# dvloader.cpp - pseudo-document & template used to load doc/view components
# These modules may be statically linked with the base application, or may be
# linked as DLL's for dynamic loading (dvloader must be statically linked).
#
# This application uses command-line switches to select the main frame class:
# -s SDI plain main window (TFrameWindow)
# -m MDI plain main window (TDecoratedFrame)
# -d SDI main window with status bar (TDecoratedFrame)
# (no switch) MDI main window with status bar (TDecoratedMDIFrame)
#
# Drag and drop from the file manager is supported by creating a document and
# view from the first document template with a matching file filter. Template
# order is dependent on the link ordering. In the dynmically built doc/view
# model, doc/view components (*.DVC) may be dropped or loaded from FileOpen.
#----------------------------------------------------------------------------
MODELS = mldfx
EXE = docviewx
DOCVIEW= editlist.obj dumpview.obj linedoc.obj xcptview.obj infoview.obj odlistvw.obj
!if "$(MODEL)" != "x" # static link of all document/view modules
OBJEXE = docviewx.obj odlistbx.obj $(DOCVIEW)
RESEXE = docviewx.res $(DOCVIEW:obj=res)
!include $(BCEXAMPLEDIR)\owlmake.gen
EXERULE = $(EXERULE) @echo Ignore previous warning about duplicate resource
!else # build each document/view module into a DLL, static link of dvloader
EXEBIN = docviewc.exe
OBJEXE = docviewx.obj dvloader.obj
RESEXE = docviewx.res dvloader.res
DLLRES = editlist
DLLBIN = editlist.dvc
DLLALL = $(DOCVIEW:obj=dvc)
DLLMAKE= $(EDITLIST) $(INFOVIEW) $(LINEDOC) $(XCPTVIEW) $(DUMPVIEW) $(ODLISTVW)
EDITLIST = $(DLLRULE:editlist.res=)
XCPTVIEW = $(DLLRULE:editlist=xcptview)
DUMPVIEW = $(DLLRULE:editlist=dumpview)
INFOVIEW = $(DLLRULE:editlist=infoview)
LINEDOC = $(DLLRULE:editlist=linedoc)
ODLISTX = $(DLLRULE:editlist=odlistvw)
ODLISTVW = $(ODLISTX:odlistvw.obj=odlistbx.obj odlistvw.obj)
!include $(BCEXAMPLEDIR)\owlmake.gen
!endif
@@ -0,0 +1,159 @@
//----------------------------------------------------------------------------
// ObjectWindows - (C) Copyright 1992, 1993 by Borland International
// Implements class TODListBox
//----------------------------------------------------------------------------
#include <owl\owlpch.h>
#include "odlistbx.h"
TODListBox::TODListBox(int id)
: TControl(0, id, 0, 0,0, 100,100), BufTemp(0), BufLen(0), MaxWidth(0)
{
Attr.Style &= ~(LBS_SORT | LBS_HASSTRINGS | LBS_MULTIPLESEL);
Attr.Style |= (LBS_NOTIFY | WS_VSCROLL | WS_HSCROLL | WS_BORDER | LBS_OWNERDRAWVARIABLE);
}
char far *
TODListBox::GetClassName()
{
return "LISTBOX";
}
void TODListBox::ItemRedraw(int index) // force item to be redrawn
{
TRect rect;
if (GetItemRect(index, rect) <= 0)
return; // return 1 if OK, -1 if error
InvalidateRect(rect);
}
void TODListBox::DrawItem(DRAWITEMSTRUCT far & dis)
{
ODItemInfo item;
UINT action = dis.itemAction;
item.Hdc = dis.hDC;
item.State = dis.itemState;
item.Data = (void far*) dis.itemData;
item.Index = dis.itemID;
item.Bound.Set(dis.rcItem.left, dis.rcItem.top,
dis.rcItem.right,dis.rcItem.bottom);
if (item.Index < 0)
return; // ignore if empty listbox, no focus rect?
GetItemInfo(item); // must fill in: Extent,Text,TextLen,Offset
if (action & ODA_DRAWENTIRE){
// // shift the item rect to account for horizontal scrolling
//if (item.Bound.right > clientrect.right)
// item.Bound.left = -(item.Bound.right - clientrect.right);
if (item.Extent.cx > MaxWidth) {
SetHorizontalExtent(MaxWidth = item.Extent.cx);
}
DrawItemData(item);
action = 0; // redraw destoys previous focus and selection painting
if (item.State & ODS_SELECTED) action |= ODA_SELECT;
if (item.State & ODS_FOCUS) action |= ODA_FOCUS;
}
if (action & ODA_SELECT) {
ChangeHilight(item);
}
if (action & ODA_FOCUS){
item.Bound.right = item.Extent.cx; // focus drawn around entire item
ChangeFocus(item);
}
}
void TODListBox::MeasureItem (MEASUREITEMSTRUCT far& mis)
{
ODItemInfo item;
item.Hdc = ::GetDC(*this);
item.Data = (void far*) mis.itemData;
item.Index = mis.itemID;
item.State = 0;
GetItemInfo(item);
mis.itemHeight = item.Extent.cy;
mis.itemWidth = item.Extent.cx;
if (item.Extent.cx > MaxWidth) {
SetHorizontalExtent(MaxWidth = item.Extent.cx);
}
::ReleaseDC(*this, item.Hdc);
}
// The following methods are defaults for use with text string items only.
// These must be overridden if for data items that are not standard text.
// If the style LBS_HASSTRINGS is set, strings are stored within the list box.
// Otherwise only the pointers are stored; data must be managed by the caller.
BOOL TODListBox::GetItemInfo(ODItemInfo& item) {
LPSTR str;
int len;
if (Attr.Style & LBS_HASSTRINGS) { // strings stored in list box
len = GetStringLen(item.Index);
if (len == 0) {
str = 0;
} else {
if (len >= BufLen){ // check temporary buffer size
if (BufTemp) delete BufTemp;
BufTemp = new char[BufLen = len+1];
}
GetString(str = BufTemp, item.Index);
}
} else { // assume text pointer is allocated data stored in item data
str = (char far*)item.Data;
len = str ? lstrlen(str) : 0;
}
item.TextLen = len;
item.Text = str;
if (!len) {
str = " "; // must have text to measure
len++;
}
GetTextExtentPoint(item.Hdc, str, len, &item.Extent);
item.Extent.cx += 2; // room for focus rectangle
item.Extent.cy += 2; // room for focus rectangle
item.Offset.x = 1; // room for focus rectangle, no indentation
item.Offset.y = 1; // room for focus rectangle
return TRUE; // OK to draw
}
void TODListBox::ChangeHilight(ODItemInfo& item)
{
InvertRect(item.Hdc, &item.Bound); // need to fix to do nicer!!
}
void TODListBox::ChangeFocus(ODItemInfo& item)
{
int brushtype = item.State & ODS_FOCUS ? LTGRAY_BRUSH
:(item.State & ODS_SELECTED ? BLACK_BRUSH : WHITE_BRUSH);
FrameRect(item.Hdc, &item.Bound, (HBRUSH)GetStockObject(brushtype));
}
void TODListBox::DrawItemData(ODItemInfo& item)
{
//HFONT oldfont = SelectObject(item.Hdc, StdFont); // need member HFONT StdFont
ExtTextOut(item.Hdc,
item.Bound.left + item.Offset.x,
item.Bound.top + item.Offset.y,
ETO_CLIPPED | ETO_OPAQUE,
&item.Bound,
item.Text, item.TextLen,
(LPINT) NULL); /* default char spacing */
//SelectObject(item.Hdc, oldfont);
}
IMPLEMENT_STREAMABLE1(TODListBox, TControl);
void*
TODListBox::Streamer::Read(ipstream& is, uint32 /*version*/) const
{
ReadBaseObject((TControl*)GetObject(), is);
is >> GetObject()->MaxWidth;
GetObject()->BufTemp = 0;
GetObject()->BufLen = 0;
return GetObject();
}
void
TODListBox::Streamer::Write(opstream& os) const
{
WriteBaseObject((TControl*)GetObject(), os);
os << GetObject()->MaxWidth;
}
@@ -0,0 +1,200 @@
//----------------------------------------------------------------------------
// ObjectWindows - (C) Copyright 1992, 1993 by Borland International
// Defines class TODListBox
//----------------------------------------------------------------------------
#ifndef __OWL_ODLISTBX_H
#define __OWL_ODLISTBX_H
#ifndef __OWL_CONTROL_H
#include <owl\control.h>
#endif
class TODListBox : public TControl {
public:
struct ODItemInfo { // temporary information about current item
// the following are supplied to the GetItemInfo function:
HDC Hdc; // display context for listbox
int Index; // index of current item, set by Draw/MeasureItem
void far* Data; // user item data value, set by Draw/MeasureItem
UINT State; // ODS_xxxx flags for new state, set by Draw/MeasureItem
TRect Bound; // actual drawing area bounds
// the following are to be set by the GetItemInfo function:
TSize Extent; // cell size to display entire data
TPoint Offset; // offset in rect of drawn data
char far* Text; // pointer to text data to draw
int TextLen; // length of text data
};
TODListBox(int id);
~TODListBox();
//
// list box wrappers
//
virtual void ClearList();
virtual int GetCount() const;
int GetTopIndex() const;
int SetTopIndex(int index);
int GetHorizontalExtent() const;
void SetHorizontalExtent(int horzExtent);
virtual int GetStringLen(int index) const;
virtual int GetString(char far* str, int index) const;
virtual DWORD GetItemData(int index) const;
virtual int SetItemData(int index, DWORD itemData);
int GetItemRect(int index, TRect& rect) const;
virtual int GetItemHeight(int index) const;
virtual int SetItemHeight(int index, int height);
virtual int AddString(const char far* str);
virtual int InsertString(const char far* str, int index);
virtual int DeleteString(int index);
virtual int GetSelIndex() const;
virtual int SetSelIndex(int index);
//
// Override TWindow virtual member functions
//
char far *GetClassName();
virtual void ItemRedraw(int index); // force item to be redrawn
protected:
int MaxWidth; // maximum horizontal extent
char far* BufTemp; // temporary buffer for returning strings
int BufLen; // allocated length of temporary buffer
// calls eminating from TControl for WM_DRAWITEM and WM_MEASUREITEM
virtual void DrawItem (DRAWITEMSTRUCT far &);
virtual void MeasureItem (MEASUREITEMSTRUCT far &);
// calls from TODListBox::DrawItem() which must be overridden if not text
virtual BOOL GetItemInfo (ODItemInfo& item); // fill Offset, Text, TextLen
virtual void ChangeHilight(ODItemInfo& item);
virtual void ChangeFocus (ODItemInfo& item);
virtual void DrawItemData (ODItemInfo& item);
private:
//
// hidden to prevent accidental copying or assignment
//
TODListBox(const TODListBox&);
TODListBox& operator=(const TODListBox&);
DECLARE_STREAMABLE(, TODListBox, 1);
};
//----------------------------------------------------------------------------
// Inlines
//----------------------------------------------------------------------------
inline TODListBox::~TODListBox() {
if (BufTemp) delete BufTemp;
}
inline int TODListBox::GetTopIndex() const {
return (int)CONST_CAST(TODListBox*,this)->HandleMessage(LB_GETTOPINDEX);
}
inline int TODListBox::SetTopIndex(int index) {
return (int)HandleMessage(LB_SETTOPINDEX, index);
}
inline int TODListBox::GetHorizontalExtent() const {
return (int)CONST_CAST(TODListBox*,this)->HandleMessage(LB_GETHORIZONTALEXTENT);
}
inline void TODListBox::SetHorizontalExtent(int horzExtent) {
HandleMessage(LB_SETHORIZONTALEXTENT, horzExtent);
}
inline DWORD TODListBox::GetItemData(int index) const {
return CONST_CAST(TODListBox*,this)->HandleMessage(LB_GETITEMDATA, index);
}
inline int TODListBox::SetItemData(int index, DWORD itemData) {
return (int)HandleMessage(LB_SETITEMDATA, index, itemData);
}
inline int TODListBox::GetItemRect(int index, TRect& rect) const {
return (int)CONST_CAST(TODListBox*,this)->
HandleMessage(LB_GETITEMRECT, index, (LPARAM)(TRect FAR*)&rect);
}
inline int TODListBox::GetItemHeight(int index) const {
return (int)CONST_CAST(TODListBox*,this)->
HandleMessage(LB_GETITEMHEIGHT, index);
}
inline int TODListBox::SetItemHeight(int index, int height) {
return (int)HandleMessage(LB_SETITEMHEIGHT, index, MAKELPARAM(height, 0));
}
// Adds a string to an associated listbox
// Returns index of the string in the list(the first entry is at index 0),
// a negative if an error occurs.
//
inline int TODListBox::AddString(const char far* str) {
return (int)HandleMessage(LB_ADDSTRING, 0, (LPARAM)str);
}
// Inserts a string in the associated listbox at the passed index,
// returns the index of the string in the list, a negative if an error occurs
//
inline int TODListBox::InsertString(const char far* str, int index) {
return (int)HandleMessage(LB_INSERTSTRING, index, (LPARAM)str);
}
// Deletes the string at the passed index in the associated listbox
// Returns a count of the entries remaining in the list, a negative
// value if an error occurs
//
inline int TODListBox::DeleteString(int index) {
return (int)HandleMessage(LB_DELETESTRING, index);
}
// Clears all the entries in the associated listbox
//
inline void TODListBox::ClearList() {
HandleMessage(LB_RESETCONTENT);
}
// Returns the number of entries in the associated listbox, a negative
// value if an error occurs
//
inline int TODListBox::GetCount() const {
return (int)CONST_CAST(TODListBox*,this)->HandleMessage(LB_GETCOUNT);
}
// Retrieves the contents of the string at the passed index of the
// associated listbox. Returns the length of the string (in bytes
// excluding the terminating 0), a negative if the passed index is not valid
//
// The buffer must be large enough for the string and the terminating 0
//
inline int TODListBox::GetString(char far* str, int index) const {
return (int)CONST_CAST(TODListBox*,this)->
HandleMessage(LB_GETTEXT, index, (LPARAM)str);
}
// Returns the length of the string at the passed index in the associated
// listbox excluding the terminating 0, a negative if an error occurs
//
inline int TODListBox::GetStringLen(int index) const {
return (int)CONST_CAST(TODListBox*,this)->HandleMessage(LB_GETTEXTLEN, index);
}
inline int TODListBox::GetSelIndex() const {
return (int)CONST_CAST(TODListBox*,this)->HandleMessage(LB_GETCURSEL);
}
// selects the string at passed index in the associated listbox and
// forces the string into view
//
// clears selection when -1 is passed as the index. a negative value is
// returned if an error occurs
//
inline int TODListBox::SetSelIndex(int index) {
return (int)HandleMessage(LB_SETCURSEL, index);
}
#endif // __OWL_ODLISTBX_H
@@ -0,0 +1,437 @@
//----------------------------------------------------------------------------
// ObjectWindows - (C) Copyright 1992, 1993 by Borland International
// Implements class TODListView
//----------------------------------------------------------------------------
#include <owl\owlpch.h>
#include <owl\docmanag.h>
#include <owl\filedoc.h>
#include <owl\inputdia.h>
#include "odlistbx.h"
#include "odlistvw.rc"
// class TODListView
// ----- -----------
//
class _DOCVIEWCLASS TODListView : public TODListBox, public TView {
public:
TODListView(TDocument& doc, TWindow* parent = 0);
~TODListView();
static const char far* StaticName() {return "OD List View";} // put in resource
BOOL DirtyFlag;
//
// overridden virtuals from TView
//
const char far* GetViewName() {return StaticName();}
TWindow* GetWindow() {return (TWindow*)this;}
BOOL SetDocTitle(const char far* docname, int index)
{return TODListBox::SetDocTitle(docname, index); }
//
// overridden virtuals from TWindow
//
BOOL Create();
UINT EvGetDlgCode(MSG far*);
BOOL CanClose() {return TODListBox::CanClose() && Doc->CanClose();}
protected:
long Origin;
BOOL LoadData(int top, int sel);
//
// message response functions
//
void CmEditUndo();
void CmEditCut();
void CmEditCopy();
void CmEditPaste();
void CmEditDelete();
void CmEditClear();
void CmEditAdd();
void CmEditItem();
// void CmLineIndent();
// void CmLineUnindent();
BOOL VnCommit(BOOL force);
BOOL VnRevert(BOOL clear);
BOOL VnIsWindow(HWND hWnd) {return HWindow == hWnd;}
BOOL VnIsDirty() {return DirtyFlag;}
BOOL VnDocClosed(int omode);
void EvDestroy();
void CmSelChange() {} // to prevent interpreting as unprocessed accelerator
DECLARE_RESPONSE_TABLE(TODListView);
DECLARE_STREAMABLE(,TODListView,1);
};
const char VirtualLastLineStr[] = "---"; // Last virtual line appended to list
DEFINE_RESPONSE_TABLE1(TODListView, TODListBox)
EV_COMMAND(CM_ODLISTUNDO, CmEditUndo),
EV_COMMAND(CM_ODLISTCUT, CmEditCut),
EV_COMMAND(CM_ODLISTCOPY, CmEditCopy),
EV_COMMAND(CM_ODLISTPASTE, CmEditPaste),
EV_COMMAND(CM_ODLISTCLEAR, CmEditClear),
EV_COMMAND(CM_ODLISTDELETE, CmEditDelete),
EV_COMMAND(CM_ODLISTADD, CmEditAdd),
EV_COMMAND(CM_ODLISTEDIT, CmEditItem),
EV_WM_GETDLGCODE,
EV_WM_DESTROY,
EV_NOTIFY_AT_CHILD(LBN_DBLCLK, CmEditItem),
EV_NOTIFY_AT_CHILD(LBN_SELCHANGE, CmSelChange),
EV_VN_DOCCLOSED,
EV_VN_ISWINDOW,
EV_VN_ISDIRTY,
EV_VN_COMMIT,
EV_VN_REVERT,
END_RESPONSE_TABLE;
DEFINE_DOC_TEMPLATE_CLASS(TFileDocument, TODListView, ODLBTemplate);
ODLBTemplate odBinTpl("ODListBox, All files","*.*", 0, "TXT",dtAutoDelete);
ODLBTemplate odTxtTpl("ODStrings, All files","*.*", 0, "TXT",dtAutoDelete);
TODListView::TODListView(TDocument& doc, TWindow* /*parent*/)
: TView(doc), TODListBox(GetNextViewId()),
Origin(0), DirtyFlag(FALSE)
{
Attr.Style &= ~(WS_BORDER | LBS_SORT);
Attr.Style |= (WS_HSCROLL | LBS_NOINTEGRALHEIGHT);
if (doc.GetTemplate() == &odTxtTpl)
Attr.Style |= LBS_HASSTRINGS;
Attr.AccelTable = IDA_ODLISTVIEW;
SetViewMenu(new TMenuDescr(IDM_ODLISTVIEW,0,1,0,0,0,1));
}
BOOL
TODListView::LoadData(int top, int sel)
{
CmEditClear();
DeleteString(0);
DirtyFlag = FALSE;
istream* inStream;
if ((inStream = Doc->InStream(ios::in)) == 0)
return FALSE;
for (;;) {
char buf[100+1];
inStream->getline(buf, sizeof(buf)-1);
if (!inStream->gcount() && !inStream->good())
break; // if EOF or error
char* str;
if (Attr.Style & LBS_HASSTRINGS) { // strings stored in list box
str = buf;
} else {
str = new char[strlen(buf)+1];
strcpy(str, buf);
}
AddString(str);
}
AddString(VirtualLastLineStr);
SetSelIndex(top);
SetSelIndex(sel);
delete inStream; // close file in case process switch
return TRUE;
}
BOOL
TODListView::Create()
{
DirtyFlag = FALSE;
TODListBox::Create(); // throws exception TXInvalidWindow
if (Doc->GetDocPath() == 0) {
CmEditClear(); // perform any clearing initialization
return TRUE; // new file, no data to display
}
if (!LoadData(0, 0))
NotOK();
return TRUE;
}
BOOL
TODListView::VnDocClosed(int omode)
{
int top;
int sel;
if (DirtyFlag == 2 || !(omode & ofWrite)) // make sure someone else's write
return FALSE;
top = GetTopIndex();
sel = GetSelIndex();
LoadData(top, sel);
return TRUE;
}
BOOL
TODListView::VnCommit(BOOL force)
{
if (!force && !DirtyFlag)
return TRUE;
ostream* outStream;
if ((outStream = Doc->OutStream(ios::out)) == 0)
return FALSE;
outStream->seekp(Origin);
char* buf = 0; // initialized only to prevent warning about use before def
int buflen = 0;
int count = GetCount();
for (int index = 0; index < count-1; index++) { // don't write last virtual line
int len;
char far* str;
if (Attr.Style & LBS_HASSTRINGS) {
len = GetStringLen(index);
} else {
str = (char far*)GetItemData(index);
len = str ? strlen(str) : 0;
}
if (len != 0) {
if (len >= buflen) {
if (buflen != 0)
delete buf;
buf = new char[buflen = len+1];
}
if (Attr.Style & LBS_HASSTRINGS)
GetString(buf, index);
else
strcpy(buf, str);
*outStream << buf;
}
*outStream << '\n';
}
if (buflen != 0)
delete buf;
DirtyFlag = 2; // to detect our own close notification
delete outStream;
DirtyFlag = FALSE;
return TRUE;
}
BOOL
TODListView::VnRevert(BOOL clear)
{
if (!clear && Doc->GetDocPath() != 0)
return LoadData(0,0);
CmEditClear();
DirtyFlag = FALSE;
return TRUE;
}
UINT
TODListView::EvGetDlgCode(MSG far*)
{
UINT retVal = (UINT)DefaultProcessing();
retVal |= DLGC_WANTCHARS;
return retVal;
}
void
TODListView::CmEditUndo()
{
MessageBox("Feature not implemented", "Undo", MB_OK);
}
void
TODListView::CmEditCut()
{
CmEditCopy();
CmEditDelete();
}
void
TODListView::CmEditCopy()
{
int index = GetSelIndex();
int count = GetCount();
if (count <= 1 || index >= count-1)
return;
char far* str;
int len;
if (Attr.Style & LBS_HASSTRINGS) { // strings stored in list box
len = GetStringLen(index);
} else {
str = (char far*)GetItemData(index);
len = strlen(str);
}
TClipboard cb(*this);
if (cb.EmptyClipboard()) {
HANDLE cbhdl = ::GlobalAlloc(GHND, len+0+1);
char far* gbuf = (char far*)::GlobalLock(cbhdl);
if (Attr.Style & LBS_HASSTRINGS) { // strings stored in list box
GetString(gbuf, index);
} else {
strcpy(gbuf, str);
}
::GlobalUnlock(cbhdl);
cb.SetClipboardData(CF_TEXT, cbhdl);
}
}
void
TODListView::CmEditPaste()
{
int index = GetSelIndex();
if (index < 0)
index = 0;
TClipboard cb(*this);
if (!cb)
return; // clipboard open by another window
HANDLE cbhdl = cb.GetClipboardData(CF_TEXT);
if (cbhdl) {
char far* text = (char far*)::GlobalLock(cbhdl);
char far* str;
if (Attr.Style & LBS_HASSTRINGS) { // strings stored in list box
str = text;
} else {
str = new char[strlen(text)+1];
strcpy(str, text);
}
InsertString(str, index);
SetSelIndex(index+1);
DirtyFlag = TRUE;
::GlobalUnlock(cbhdl);
}
}
void
TODListView::CmEditDelete()
{
int count = GetCount();
int index = GetSelIndex();
if (count <= 1 || index >= count-1)
return;
ODItemInfo item;
item.Hdc = ::GetDC(*this);
item.Index = index;
item.Data = (void far*)GetItemData(index);
item.State = 0;
GetItemInfo(item);
::ReleaseDC(*this, item.Hdc);
if (item.Extent.cx == MaxWidth)
SetHorizontalExtent(MaxWidth = 0); // force recalculate max width
if (!(Attr.Style & LBS_HASSTRINGS)) // strings not stored in list box
delete item.Data;
DeleteString(index);
SetSelIndex(index);
DirtyFlag = TRUE;
}
void
TODListView::CmEditClear()
{
int count = GetCount();
if (count == 1)
return;
if (count) {
if (!(Attr.Style & LBS_HASSTRINGS)) // strings not stored in list box
for (int index = 0; index < count-1; index++)
delete (char far*)GetItemData(index);
ClearList();
DirtyFlag = TRUE;
SetHorizontalExtent(MaxWidth = 0);
}
AddString(VirtualLastLineStr);
}
TODListView::~TODListView()
{
if (HWindow)
CmEditClear();
}
void
TODListView::EvDestroy()
{
CmEditClear();
TWindow::EvDestroy();
}
static int linePrompt(TWindow* parent, int index, UINT id, char far* buf,int buflen)
{
char msg[41];
wsprintf(msg, string(*parent->GetModule(), IDS_ODLISTNUM).c_str(), index);
const char far* prompt = string(*parent->GetModule(), id).c_str();
return TInputDialog(parent, msg, prompt, buf, buflen).Execute();
}
void
TODListView::CmEditAdd()
{
char inputText[80];
*inputText = 0;
int index = GetSelIndex();
if (index < 0)
index = 0;
if (linePrompt(this,index+1,CM_ODLISTADD,inputText,sizeof(inputText))==IDOK) {
char far* str;
if (Attr.Style & LBS_HASSTRINGS) { // strings stored in list box
str = inputText;
} else {
str = new char[strlen(inputText)+1];
strcpy(str, inputText);
}
InsertString(str, index);
SetSelIndex(index+1);
DirtyFlag = TRUE;
}
}
void
TODListView::CmEditItem()
{
int index = GetSelIndex();
if (index < 0 || index >= GetCount()-1)
return;
int len;
char* inputText;
if (Attr.Style & LBS_HASSTRINGS) { // strings stored in list box
len = GetStringLen(index);
inputText = new char[len + 81];
GetString(inputText, index);
} else {
char far* str = (char far*)GetItemData(index);
len = strlen(str);
inputText = new char[len + 81];
strcpy(inputText, str);
}
if (linePrompt(this,index+1,CM_ODLISTEDIT,inputText, len + 81)==IDOK) {
char far* str;
if (Attr.Style & LBS_HASSTRINGS) { // strings stored in list box
str = inputText;
} else {
delete (char far*)GetItemData(index);
str = strnewdup(inputText);
}
DeleteString(index);
InsertString(str, index);
SetSelIndex(index);
DirtyFlag = TRUE;
}
delete inputText;
}
IMPLEMENT_STREAMABLE2(TODListView, TODListBox, TView);
void *
TODListView::Streamer::Read(ipstream &is, uint32 /* version */) const
{
ReadBaseObject((TODListBox*)GetObject(), is);
ReadBaseObject((TView*)GetObject(), is);
is >> GetObject()->Origin;
GetObject()->DirtyFlag = FALSE;
return GetObject();
}
void
TODListView::Streamer::Write(opstream &os) const
{
WriteBaseObject((TODListBox*)GetObject(), os);
WriteBaseObject((TView*)GetObject(), os);
os << GetObject()->Origin;
}
@@ -0,0 +1,72 @@
//----------------------------------------------------------------------------
// ObjectWindows - (C) Copyright 1993 by Borland International
// Menu and accelerators for use with TODListView
//----------------------------------------------------------------------------
#include <owl\inputdia.rh>
#define CM_ODLISTUNDO 27381
#define CM_ODLISTCUT 27382
#define CM_ODLISTCOPY 27383
#define CM_ODLISTPASTE 27384
#define CM_ODLISTDELETE 27385
#define CM_ODLISTCLEAR 27386
#define CM_ODLISTADD 27387
#define CM_ODLISTEDIT 27388
#define IDS_ODLISTNUM 32583
#define IDM_ODLISTVIEW 32583
#define IDA_ODLISTVIEW 32584
#if defined(RC_INVOKED)
IDM_ODLISTVIEW MENU LOADONCALL MOVEABLE PURE DISCARDABLE
BEGIN
POPUP "&Edit"
BEGIN
MenuItem "&Undo\aCtrl+Z", CM_ODLISTUNDO
MenuItem SEPARATOR
MenuItem "&Cut\aCtrl+X", CM_ODLISTCUT
MenuItem "C&opy\aCtrl+C", CM_ODLISTCOPY
MenuItem "&Paste\aCtrl+V", CM_ODLISTPASTE
MenuItem "&Delete\aDel", CM_ODLISTDELETE
MenuItem "&Add Item\aIns", CM_ODLISTADD
MenuItem "&Edit Item\aEnter", CM_ODLISTEDIT
MenuItem "C&lear All\aCtrl+Del", CM_ODLISTCLEAR
END
POPUP "&Help"
BEGIN
MenuItem "OWL Owner-draw ListView", 0, INACTIVE
END
END
IDA_ODLISTVIEW ACCELERATORS
BEGIN
"^z", CM_ODLISTUNDO,
"^x", CM_ODLISTCUT,
"^c", CM_ODLISTCOPY,
"^v", CM_ODLISTPASTE,
VK_DELETE, CM_ODLISTDELETE VIRTKEY
VK_DELETE, CM_ODLISTCUT, VIRTKEY, SHIFT
VK_DELETE, CM_ODLISTCLEAR, VIRTKEY, CONTROL
VK_INSERT, CM_ODLISTCOPY, VIRTKEY, CONTROL
VK_INSERT, CM_ODLISTPASTE, VIRTKEY, SHIFT
VK_BACK, CM_ODLISTUNDO, VIRTKEY, ALT
VK_INSERT, CM_ODLISTADD, VIRTKEY
VK_RETURN, CM_ODLISTEDIT, VIRTKEY
END
STRINGTABLE LOADONCALL MOVEABLE DISCARDABLE
BEGIN
CM_ODLISTUNDO, "Reverses the last operation"
CM_ODLISTCUT, "Cuts the selection and puts it on the Clipboard"
CM_ODLISTCOPY, "Copies the selection to the Clipboard"
CM_ODLISTPASTE, "Inserts the Clipboard contents at the caret"
CM_ODLISTDELETE,"Deletes the selection"
CM_ODLISTCLEAR, "Clear the document"
CM_ODLISTADD, "Insert a new line"
CM_ODLISTEDIT, "Edit the current line"
IDS_ODLISTNUM, "Line number %d"
END
#endif /* defined(RC_INVOKED) */
@@ -0,0 +1,485 @@
//----------------------------------------------------------------------------
// ObjectWindows - (C) Copyright 1993 by Borland International
// Implements class TExceptionView
//----------------------------------------------------------------------------
#include <owl\owlpch.h>
#include <owl\docmanag.h>
#include "xcptview.rc"
#include <owl\docview.rc>
#include <owl\inputdia.h>
#include <owl\compat.h>
#include <owl\listbox.h>
#include <owl\filedoc.h>
#include "xcptview.rc"
class XVLink;
class _DOCVIEWCLASS TExceptionView : public TListBox, public TView {
public:
TExceptionView(TDocument& doc, TWindow* parent = 0);
~TExceptionView();
static LPCSTR StaticName() {return "Exception Log";} // put in resource
BOOL DirtyFlag;
int CurIndex;
void LogThrow(char* str);
void Annotate(int index, char chr, BOOL cache = FALSE);
//
// overridden virtuals from TView
//
const char far* GetViewName(){return StaticName();}
// LPCSTR GetViewName(){return StaticName();}
TWindow* GetWindow() {return (TWindow*)this;}
BOOL SetDocTitle(const char far* docname, int index)
// BOOL SetDocTitle(LPCSTR docname, int index)
{return TListBox::SetDocTitle(docname, index); }
//
// overridden virtuals from TWindow
//
BOOL CanClose() {return TListBox::CanClose() && Doc->CanClose();}
BOOL Create();
protected:
long Origin;
int MaxWidth; // maximum horizontal extent
XVLink* Link;
char Cache;
unexpected_function OldUnexpectedHandler;
void Init();
void SetExtent(LPSTR str);
BOOL LoadData(int top, int sel);
//
// message response functions
//
BOOL VnDocClosed(int omode);
BOOL VnCommit(BOOL force);
BOOL VnRevert(BOOL clear);
BOOL VnIsWindow(HWND hWnd) {return HWindow == hWnd;}
BOOL VnIsDirty() {return DirtyFlag;}
void CmSelChange(){} // to prevent interpreting as unprocessed accelerator
void CmTXOwl();
void CmTXTest();
void CmTXComp();
void CmTXMem();
void CmXalloc();
void CmXmsg();
void CmForeign();
void CmUnexpected() throw (xalloc);
void CmBadCast();
void CmBadTypeid();
void CmOwlSend();
void CmClear();
void EvTimeChange();
DECLARE_RESPONSE_TABLE(TExceptionView);
DECLARE_STREAMABLE(,TExceptionView,1);
};
class XVLink{ // access class to prevent calling deleted view
public:
XVLink(TExceptionView* view) : View(view), RefCnt(1), Suspended(FALSE) {}
TExceptionView* View;
int RefCnt;
BOOL Suspended;
void Annotate(int index, char chr)
{if (View) View->Annotate(index, chr, Suspended);}
void AddRef() {RefCnt++;}
void SubRef() {if (--RefCnt == 0) delete this;}
};
class TXTest : public TXOwl {
public:
TXTest(UINT resId, XVLink* view, int index);
TXTest(const TXTest&);
const TXTest& operator = (const TXTest&);
~TXTest();
TXOwl* Clone();
void Throw();
int Unhandled(TModule* app, unsigned promptResId);
XVLink* View;
int Index;
};
DEFINE_RESPONSE_TABLE1(TExceptionView, TListBox)
EV_COMMAND(CM_TXOWL, CmTXOwl),
EV_COMMAND(CM_TXTEST, CmTXTest),
EV_COMMAND(CM_TXCOMP, CmTXComp),
EV_COMMAND(CM_TXMEM, CmTXMem),
EV_COMMAND(CM_XALLOC, CmXalloc),
EV_COMMAND(CM_XMSG, CmXmsg),
EV_COMMAND(CM_FOREIGN, CmForeign),
EV_COMMAND(CM_UNEXPECTED, CmUnexpected),
EV_COMMAND(CM_BADCAST, CmBadCast),
EV_COMMAND(CM_BADTYPEID, CmBadTypeid),
EV_COMMAND(CM_OWLSEND, CmOwlSend),
EV_COMMAND(CM_XCLEAR, CmClear),
EV_NOTIFY_AT_CHILD(LBN_SELCHANGE, CmSelChange),
EV_VN_DOCCLOSED,
EV_VN_ISWINDOW,
EV_VN_ISDIRTY,
EV_VN_COMMIT,
EV_VN_REVERT,
EV_WM_TIMECHANGE,
END_RESPONSE_TABLE;
void XUnexpectedHandler()
{
throw xmsg(string(*::Module,XM_UNEXPECTED));
}
TExceptionView::TExceptionView(TDocument& doc, TWindow* parent)
: TView(doc), TListBox(parent, GetNextViewId(), 0,0,0,0),
Origin(0), MaxWidth(0)
{
Attr.Style &= ~(WS_BORDER | LBS_SORT);
Attr.Style |= (WS_HSCROLL | LBS_NOINTEGRALHEIGHT);
Attr.AccelTable = IDA_XCPTVIEW;
SetViewMenu(new TMenuDescr(IDM_XCPTVIEW,0,2,0,0,0,1));
Init();
}
void TExceptionView::Init()
{
Link = new XVLink(this);
OldUnexpectedHandler = set_unexpected(XUnexpectedHandler);
DirtyFlag = FALSE;
Cache = 0;
}
TExceptionView::~TExceptionView()
{
Link->View = 0; // prevent calling into destructed view
Link->SubRef(); // will destruct when no outstanding exceptions
set_unexpected(OldUnexpectedHandler);
}
struct XTest { // class with destructor for testing TPointer
char* P;
XTest() {P = new char[4];}
virtual ~XTest(); // non inline to allow breakpoint set
};
XTest::~XTest(){delete P;}
struct XTestD : public XTest { // class derived from XTest
XTestD() : XTest(), Q(0) {}
char* Q;
~XTestD() {delete Q;}
};
static ThrowTXOwl() // extra call level to allow TPointer testing
{
throw TXOwl(XM_TXOWL);
}
void TExceptionView::CmTXOwl()
{
TPointer<char> ptr = new char[20];
ptr[0] = 0;
TPointer<XTest> x;
x = new XTest();
LogThrow("TXOwl thrown");
XTest* xt = new XTestD();
delete xt;
ThrowTXOwl();
}
void TExceptionView::CmTXTest()
{
LogThrow("TXTest thrown");
throw TXTest(XM_TXTEST, Link, CurIndex);
}
void TExceptionView::CmTXComp()
{
LogThrow("TXCompatibility throw by setting Status");
Status = EM_INVALIDWINDOW;
}
void TExceptionView::CmTXMem()
{
LogThrow("TXOutOfMemory thrown");
throw TXOutOfMemory();
}
void TExceptionView::CmXalloc()
{
LogThrow("xalloc thrown");
throw xalloc(string(*::Module,XM_XALLOC),1234);
}
void TExceptionView::CmXmsg()
{
LogThrow("xmsg thrown");
throw xmsg(string(*::Module,XM_XMSG));
}
void TExceptionView::CmForeign()
{
LogThrow("int thrown");
throw (int)35;
}
void TExceptionView::CmUnexpected() throw (xalloc)
{
LogThrow("Unexpected xmsg thrown");
throw xmsg(string(*::Module,XM_UNEXPECTED));
}
static xmsg* XVRef(xmsg&) {return 0;}
void TExceptionView::CmBadCast()
{
LogThrow("Failed dynamic_cast<>");
XVRef(dynamic_cast<xmsg&>(*this));
}
void TExceptionView::CmBadTypeid()
{
LogThrow("type_id() called on invalid object");
class __rtti C {int i; virtual ~C(){}};
C* o = 0;
static const char* n;
n = typeid(*o).name();
}
void TExceptionView::CmOwlSend()
{
::SendMessage(HWindow, WM_TIMECHANGE,0,0); // any strange message will do
GetApplication()->ResumeThrow();
}
void TExceptionView::EvTimeChange()
{
LogThrow("TXTest thrown from event handler");
throw TXTest(XM_OWLSEND, Link, CurIndex);
}
void TExceptionView::CmClear()
{
ClearList();
DirtyFlag = FALSE;
SetHorizontalExtent(MaxWidth = 0);
}
void TExceptionView::LogThrow(char* str)
{
SetSelIndex(CurIndex = AddString(str));
SetExtent(str);
DirtyFlag = TRUE;
}
void TExceptionView::Annotate(int index, char chr, BOOL cache)
{
if (Cache) { // check if character logged during exception processing
char chr = Cache;
Cache = 0;
Annotate(index, chr); // we assume here we're still at the same index
}
if (cache && chr == '~') { // check if in destructor with cloned exception
Cache = chr;
return;
}
char buf[100];
int len = GetStringLen(index);
GetString(buf, index);
buf[len] = ' ';
buf[len+1] = chr;
buf[len+2] = 0;
DeleteString(index);
InsertString(buf, index);
SetSelIndex(index);
}
void TExceptionView::SetExtent(LPSTR str)
{
HDC hdc;
int len;
TSize extent;
if ((len = strlen(str)) == 0)
return;
hdc = ::GetDC(HWindow);
::GetTextExtentPoint(hdc, str, len, &extent);
extent.cx += 2; // room for focus rectangle
if (extent.cx > MaxWidth){
SetHorizontalExtent(MaxWidth = extent.cx);
}
::ReleaseDC(HWindow, hdc);
}
BOOL TExceptionView::VnDocClosed(int omode)
{
int top;
int sel;
if (DirtyFlag == 2 || !(omode & ofWrite)) // make sure someone else's write
return FALSE;
top = GetTopIndex();
sel = GetSelIndex();
LoadData(top, sel);
return TRUE;
}
BOOL TExceptionView::LoadData(int top, int sel)
{
char buf[100+1];
istream* inStream;
BOOL status = TRUE;
CmClear();
DirtyFlag = FALSE;
if ((inStream = Doc->InStream(ios::in)) == 0) {
Doc->PostError(IDS_UNABLEOPEN, MB_OK);
return FALSE;
}
for (;;) {
inStream->getline(buf, sizeof(buf)-1);
if (!inStream->gcount() && !inStream->good()) {
status = inStream->eof();
break;
}
AddString(buf);
SetExtent(buf);
}
SetTopIndex(top);
SetSelIndex(sel);
delete inStream; // close file in case process switch
if (!status)
Doc->PostError(IDS_READERROR, MB_OK);
return status;
}
BOOL TExceptionView::Create()
{
try {
TListBox::Create(); // throws exception TWindow::TXWindow
}
catch (TXOwl& x) {
Doc->PostError(IDS_NOMEMORYFORVIEW, MB_OK);
return TRUE; // cannot return FALSE - throws another exception
}
if (Doc->GetDocPath() == 0) {
return TRUE; // new file, no data to display
}
if (!LoadData(0, 0))
NotOK();
return TRUE;
}
BOOL TExceptionView::VnCommit(BOOL force)
{
int count;
int index;
int len;
char* buf;
ostream* outStream;
BOOL status;
if (!force && !DirtyFlag)
return TRUE;
if ((outStream = Doc->OutStream(ios::out)) == 0) {
Doc->PostError(IDS_UNABLEOPEN, MB_OK);
return FALSE;
}
outStream->seekp(Origin);
count = GetCount();
for (index = 0; index < count; index++) {
len = GetStringLen(index);
buf = new char[len+1];
GetString(buf, index);
*outStream << buf << '\n';
delete buf;
}
DirtyFlag = 2; // to detect our own close notification
status = outStream->good();
delete outStream;
DirtyFlag = FALSE;
if (!status)
Doc->PostError(IDS_WRITEERROR, MB_OK);
return status;
}
BOOL TExceptionView::VnRevert(BOOL clear)
{
if (!clear && Doc->GetDocPath() != 0)
return LoadData(0,0);
CmClear();
return TRUE;
}
// Exception class for monitoring exception progress
TXTest::TXTest(UINT resId, XVLink* view, int index)
: TXOwl(resId), View(view), Index(index)
{
View->AddRef();
View->Annotate(Index, '#');
}
TXTest::TXTest(const TXTest& s) : TXOwl(s), View(s.View),Index(s.Index)
{
View->AddRef();
View->Annotate(Index, '+');
}
TXTest::~TXTest()
{
// We cannot do any action here that would cause an exeption to be thrown
// since this object may have just been caught and cloned, a call involving
// messaging through windows would cause the cloned exception to be rethrown
View->Annotate(Index, '~');
View->SubRef();
}
const TXTest& TXTest::operator = (const TXTest& src)
{
*(TXOwl*)this = src;
View = src.View;
Index = src.Index;
View->AddRef();
View->Annotate(Index, '=');
return *this;
}
TXOwl* TXTest::Clone()
{
View->Suspended = TRUE; // prevent rethrow during logging Windows call
View->Annotate(Index, '&');
return new TXTest(*this); // will do the AddRef
}
void TXTest::Throw()
{
View->Suspended = FALSE;
View->Annotate(Index, '!');
throw *this;
}
int TXTest::Unhandled(TModule* app, unsigned promptResId)
{
View->Annotate(Index, '?');
return TXOwl::Unhandled(app, promptResId);
}
IMPLEMENT_STREAMABLE2(TExceptionView, TListBox, TView);
void* TExceptionView::Streamer::Read(ipstream& is, uint32 /*version*/) const
{
TExceptionView* o = GetObject();
ReadBaseObject((TListBox*)o, is);
ReadBaseObject((TView*)o, is);
o->Init();
is >> o->Origin;
is >> o->MaxWidth;
return o;
}
void TExceptionView::Streamer::Write(opstream &os) const
{
WriteBaseObject((TListBox*)GetObject(), os);
WriteBaseObject((TView*)GetObject(), os);
os << GetObject()->Origin;
os << GetObject()->MaxWidth;
}
DEFINE_DOC_TEMPLATE_CLASS(TFileDocument, TExceptionView, XcptTemplate);
XcptTemplate xcptTpl("Exception Log File","*.xlg", 0, "XLG",dtAutoDelete|dtUpdateDir);
@@ -0,0 +1,109 @@
//----------------------------------------------------------------------------
// ObjectWindows - (C) Copyright 1993 by Borland International
// Menu and strings for use with TExceptionView
//----------------------------------------------------------------------------
#include <owl\inputdia.rh>
//#include <owl\except.rc>
#define CM_TXOWL 30380
#define CM_TXTEST 30381
#define CM_TXCOMP 30382
#define CM_TXMEM 30383
#define CM_XALLOC 30384
#define CM_XMSG 30385
#define CM_FOREIGN 30386
#define CM_UNEXPECTED 30387
#define CM_BADCAST 30388
#define CM_BADTYPEID 30389
#define CM_OWLSEND 30390
#define CM_XCLEAR 30391
#define XM_TXOWL 30480
#define XM_TXTEST 30481
#define XM_XALLOC 30482
#define XM_XMSG 30483
#define XM_UNEXPECTED 30484
#define XM_OWLSEND 30485
#define IDM_XCPTVIEW 30300
#define IDA_XCPTVIEW 30300
#if defined(RC_INVOKED)
#include <owl\inputdia.rc>
#define NO_IDD_INPUTDIALOG
#if !defined(NO_IDM_XCPTVIEW) && !defined(__IDM_XCPTVIEW)
#define __IDM_XCPTVIEW
IDM_XCPTVIEW MENU LOADONCALL MOVEABLE PURE DISCARDABLE
BEGIN
POPUP "&Edit"
BEGIN
MenuItem "&Clear Data\aCtrl+Del",CM_XCLEAR
END
POPUP "&Throw Exception"
BEGIN
MenuItem "TX&Owl Exception", CM_TXOWL
MenuItem "TX&Test Exception", CM_TXTEST
MenuItem "TX&Compatibility", CM_TXCOMP
MenuItem "TXOutOf&Memory", CM_TXMEM
MenuItem "x&alloc Exception", CM_XALLOC
MenuItem "&xmsg Exception", CM_XMSG
MenuItem "&Foreign Exception", CM_FOREIGN
MenuItem "&Unexpected Violation",CM_UNEXPECTED
MenuItem "Bad &Dynamic Cast", CM_BADCAST
MenuItem "typeid() Bad Object", CM_BADTYPEID
MenuItem "TXTest &SendMessage", CM_OWLSEND
END
POPUP "&Help"
BEGIN
MenuItem "OWL ExceptionView", 0, INACTIVE
MenuItem "TXTest Annotations:", 0, INACTIVE
MenuItem "# TXTest constructor",0, INACTIVE
MenuItem "+ copy constructor", 0, INACTIVE
MenuItem "~ destructor", 0, INACTIVE
MenuItem "= assignment", 0, INACTIVE
MenuItem "&& clone function", 0, INACTIVE
MenuItem "! throw function", 0, INACTIVE
MenuItem "? unhandled function",0, INACTIVE
END
END
#endif
#undef NO_IDM_XCPTVIEW
#if !defined(NO_IDA_XCPTVIEW) && !defined(__IDA_XCPTVIEW)
#define __IDA_XCPTVIEW
IDA_XCPTVIEW ACCELERATORS
BEGIN
VK_DELETE, CM_XCLEAR, VIRTKEY, CONTROL
END
#endif
#undef NO_IDA_XCPTVIEW
#if !defined(NO_IDS_XCPTVIEW) && !defined(__IDS_XCPTVIEW)
#define __IDS_XCPTVIEW
STRINGTABLE LOADONCALL MOVEABLE DISCARDABLE
BEGIN
CM_TXOWL, "Throw a TXOwl exception"
CM_TXTEST, "Throw a TXTest exception, monitor progress"
CM_TXCOMP, "Throw a TXCompatibility by setting Status"
CM_TXMEM, "Throw a TXOutOfMemory exception"
CM_XALLOC, "Throw an xalloc exception"
CM_XMSG, "Throw an xmsg exception"
CM_FOREIGN, "Throw a foreign exception"
CM_UNEXPECTED,"Throw an unexpected xmsg"
CM_BADCAST, "Perform an invalid dynamic cast to a reference"
CM_BADTYPEID, "Call typeid() on a non-rtti object"
CM_OWLSEND, "Throw a TXTest exception from SendMessage callback"
CM_XCLEAR, "Clear data from view"
XM_TXOWL, "TXOwl from TExceptionView"
XM_TXTEST, "TXTest from TExceptionView"
XM_XALLOC, "xalloc from TExceptionView"
XM_XMSG, "xmsg from TExceptionView"
XM_UNEXPECTED,"Unexpected xmsg forced"
XM_OWLSEND, "TXTest from SendMessage callback to TExceptionView"
END
#endif
#undef NO_IDS_XCPTVIEW
#endif // defined(RC_INVOKED)
Binary file not shown.
@@ -0,0 +1,506 @@
//----------------------------------------------------------------------------
// ObjectWindows - (C) Copyright 1991, 1993 by Borland International
//----------------------------------------------------------------------------
#include <owl\owlpch.h>
#include <owl\applicat.h>
#include <owl\framewin.h>
#include <owl\static.h>
#include <owl\edit.h>
#include <owl\inputdia.h>
#include <owl\opensave.h>
#include <owl\validate.h>
#include <fstream.h>
#include <cstring.h>
#include "editx.rh"
// Control ids:
//
const int ID_EXAMPLE_EDIT = 200;
// Message ids:
//
const int CN_UPDATE = 300;
class TExampleEdit : public TEdit {
public:
TExampleEdit(TWindow* parent,
int id,
const char far* text,
int x, int y, int w, int h,
UINT textLen = EditTextLen + 1,
BOOL multiline = TRUE,
TModule* module = 0 )
: TEdit(parent, id, text, x, y, w, h, textLen, multiline, module)
{
LastCBOpStr = " ";
}
// override to setup 'FileData' structure.
//
void SetupWindow();
// override to update text fields.
//
void CmEditCut(); // CM_EDITCUT
void CmEditCopy(); // CM_EDITCOPY
void CmEditPaste(); // CM_EDITPASTE
void CmEditDelete(); // CM_EDITDELETE
void CmEditClear(); // CM_EDITCLEAR
void CmEditUndo(); // CM_EDITUNDO
void EvKeyDown(UINT key, UINT repeatCount, UINT flags);
void EvLButtonDown(UINT modKeys, TPoint& point);
// Newly defined functions (not defined by base classes):
//
void NotifyParent(int notification);
void SaveText();
void RestoreText();
const string& GetLastCBOpStr() const {return LastCBOpStr;}
string LastCBOpStr; // string value of last CB operation.
static const unsigned EditTextLen; // length of edit control text.
private:
TOpenSaveDialog::TData FileData; // save/restore info.
DECLARE_RESPONSE_TABLE(TExampleEdit);
};
DEFINE_RESPONSE_TABLE1(TExampleEdit, TEdit)
EV_COMMAND(CM_EDITCUT, CmEditCut),
EV_COMMAND(CM_EDITCOPY, CmEditCopy),
EV_COMMAND(CM_EDITPASTE, CmEditPaste),
EV_COMMAND(CM_EDITDELETE, CmEditDelete),
EV_COMMAND(CM_EDITCLEAR, CmEditClear),
EV_COMMAND(CM_EDITUNDO, CmEditUndo),
EV_WM_KEYDOWN,
EV_WM_LBUTTONDOWN,
END_RESPONSE_TABLE;
const unsigned TExampleEdit::EditTextLen = 1000;
void
TExampleEdit::SetupWindow()
{
TEdit::SetupWindow();
FileData.Flags = OFN_FILEMUSTEXIST|OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT;
FileData.SetFilter("Text files (*.TXT)|*.TXT|AllFiles (*.*)|*.*|");
}
//
// The next function group simply notifies the app to update the text fields
// then calls the base class version to do the actual processing.
//
void
TExampleEdit::CmEditCut()
{
LastCBOpStr = "Cut";
NotifyParent(CN_UPDATE);
TEdit::CmEditCut();
NotifyParent(CN_UPDATE);
TEdit::CmEditCut();
}
void
TExampleEdit::CmEditCopy()
{
LastCBOpStr = "Copy";
NotifyParent(CN_UPDATE);
TEdit::CmEditCopy();
}
void
TExampleEdit::CmEditPaste()
{
LastCBOpStr = "Paste";
NotifyParent(CN_UPDATE);
TEdit::CmEditPaste();
NotifyParent(CN_UPDATE);
}
void
TExampleEdit::CmEditDelete()
{
LastCBOpStr = "Delete";
NotifyParent(CN_UPDATE);
TEdit::CmEditDelete();
NotifyParent(CN_UPDATE);
}
void
TExampleEdit::CmEditClear()
{
TEdit::CmEditClear();
LastCBOpStr = "Clear";
NotifyParent(CN_UPDATE);
}
void
TExampleEdit::CmEditUndo()
{
TEdit::CmEditUndo();
LastCBOpStr = "Undo";
NotifyParent(CN_UPDATE);
}
void
TExampleEdit::EvKeyDown(UINT key, UINT repeatCount, UINT flags)
{
TEdit::EvKeyDown(key, repeatCount, flags);
NotifyParent(CN_UPDATE);
}
void
TExampleEdit::EvLButtonDown(UINT modKeys, TPoint& point)
{
TEdit::EvLButtonDown(modKeys, point);
NotifyParent(CN_UPDATE);
}
//
// NotifyParent(). 'easy' method of notifing the parent of an event.
// Notifies immediately
void
TExampleEdit::NotifyParent(int notification)
{
Parent->SendNotification(Attr.Id, notification, HWindow);
}
//
// SaveText(). Save text portion of edit control to a file.
//
void
TExampleEdit::SaveText()
{
if (TFileSaveDialog(GetApplication()->MainWindow, FileData).Execute() == IDOK) {
ofstream ofs(FileData.FileName, ios::out|ios::binary);
unsigned maxLen = EditTextLen;
char far* buffer = LockBuffer();
unsigned size = min(maxLen, strlen(buffer));
for (unsigned i = 0; i < size && buffer[i]; i++)
ofs.put(buffer[i]);
UnlockBuffer(buffer);
}
}
//
// RestoreText(). Restore or read in text from a file. Uses the first
// 'EditTextLen' characters from file.
//
void
TExampleEdit::RestoreText()
{
if (TFileOpenDialog(GetApplication()->MainWindow, FileData).Execute() == IDOK) {
Clear();
ifstream ifs(FileData.FileName);
char far* buffer = LockBuffer(EditTextLen + 1);
for (unsigned i = 0; i < EditTextLen && !ifs.eof(); i++) {
buffer[i] = (char)ifs.get();
if (buffer[i] == '\n' && ifs.peek() != '\r') {
buffer[i] = '\r';
buffer[++i] = '\n';
}
}
if (i)
buffer[i-1] = 0;
UnlockBuffer(buffer, TRUE);
NotifyParent(CN_UPDATE);
}
}
//----------------------------------------------------------------------------
class TEditWindow : public TFrameWindow {
public:
TEditWindow(const char* title);
void SetupWindow();
// message response functions
//
void CmUpdate() {UpdateTextFields();} // Edit control notification.
void CmInsertText(); // insert text at char pos.
void CmDeleteSubText(); // delete subtext.
void CmDeleteLine(); // delete line of text.
void CmSaveText(); // save text in edit cntl.
void CmRestoreText(); // restore from file into edit cntl.
private:
TExampleEdit* EditCntl; // edit control
TStatic* NbrLinesText; // text of number of lines.
TStatic* CurLineNbrText; // current line number.
TStatic* CurLineText; // current line, 1st N chars.
TStatic* CurLineLenText; // length of current line.
TStatic* FirstVisibleLineText; // line # of 1st visible line.
TStatic* IsModifiedText; // has edit control been modified.
TStatic* LastCBOpText; // last clipboard operation.
TStatic* CurSelText; // first N chars of selected text.
static const unsigned InputTextLen; // length of input text.
static const unsigned FirstNChars; // first n characters to display.
void ResetTextFields(); // reset text fields to init values.
void UpdateTextFields(); // updates from edit control
int // read string from user.
InputString(char* prompt, char* s);
int // read number from user
InputNumber(char* prompt, unsigned& n);
DECLARE_RESPONSE_TABLE(TEditWindow);
};
DEFINE_RESPONSE_TABLE1(TEditWindow, TFrameWindow)
EV_CHILD_NOTIFY(ID_EXAMPLE_EDIT, CN_UPDATE, CmUpdate),
EV_EN_VSCROLL(ID_EXAMPLE_EDIT, CmUpdate),
EV_COMMAND(CM_INSERT_TEXT, CmInsertText),
EV_COMMAND(CM_DELETE_SUBTEXT, CmDeleteSubText),
EV_COMMAND(CM_DELETE_LINE, CmDeleteLine),
EV_COMMAND(CM_SAVE_TEXT, CmSaveText),
EV_COMMAND(CM_RESTORE_TEXT, CmRestoreText),
END_RESPONSE_TABLE;
const unsigned TEditWindow::InputTextLen = 51;
const unsigned TEditWindow::FirstNChars = 20;
//
// Constructor. Setup menu and text areas.
//
TEditWindow::TEditWindow(const char* title)
: TFrameWindow(0, title), TWindow(0, title)
{
const int labelStartX = 10,
textStartY = 225,
textHeight = 16,
textStartX = labelStartX + 250;
// setup menu
//
AssignMenu("IDM_EXAMPLE_EDIT");
// Create Edit control.
//
EditCntl = new TExampleEdit(this, ID_EXAMPLE_EDIT, "", 10, 10, 500, 200);
// setup static text areas.
//
new TStatic(this, -1, "Number of lines:", labelStartX, textStartY,
160, textHeight, 16);
NbrLinesText = new TStatic(this, -1, "0", textStartX, textStartY,
50, textHeight, 5);
new TStatic(this, -1, "current line number:", labelStartX,
textStartY + textHeight, 200, textHeight, 20);
CurLineNbrText = new TStatic(this, -1, "0", textStartX,
textStartY + textHeight, 50, textHeight, 5);
new TStatic(this, -1, "1st 20 chars of current line:", labelStartX,
textStartY + textHeight * 2, 290, textHeight, 29);
CurLineText = new TStatic(this, -1, "", textStartX,
textStartY + textHeight * 2, FirstNChars * 10, textHeight,
FirstNChars);
new TStatic(this, -1, "length of current line:", labelStartX,
textStartY + textHeight * 3, 230, textHeight, 23);
CurLineLenText = new TStatic(this, -1, "0", textStartX,
textStartY + textHeight * 3, 50, textHeight, 5);
new TStatic(this, -1, "line number of 1st visible list:", labelStartX,
textStartY + textHeight * 4, 320, textHeight, 32);
FirstVisibleLineText = new TStatic(this, -1, "0", textStartX,
textStartY + textHeight * 4, 50, textHeight, 5);
new TStatic(this, -1, "has edit control been modified:", labelStartX,
textStartY + textHeight * 5, 310, textHeight, 31);
IsModifiedText = new TStatic(this, -1, "No", textStartX,
textStartY + textHeight * 5, 50, textHeight, 5);
new TStatic(this, -1, "last clipboard operation:", labelStartX,
textStartY + textHeight * 6, 250, textHeight, 25);
LastCBOpText = new TStatic(this, -1, "", textStartX,
textStartY + textHeight * 6, 100, textHeight, 10);
new TStatic(this, -1, "1st 20 chars of last selected text:", labelStartX,
textStartY + textHeight * 7, 350, textHeight, 35);
CurSelText= new TStatic(this, -1, "", textStartX,
textStartY + textHeight * 7, FirstNChars * 10, textHeight,
FirstNChars);
}
void
TEditWindow::SetupWindow()
{
TFrameWindow::SetupWindow();
UpdateTextFields();
}
//
// CmInsertText(). Insert text at character position input be user. If pos
// is beyond end of edit buffer then the insert takes place at the end of
// buffer (append).
//
void
TEditWindow::CmInsertText()
{
char buf[InputTextLen] = "";
unsigned pos;
if (!InputNumber("Enter position:", pos))
return;
EditCntl->SetSelection(pos, pos);
buf[0] = 0;
if (!InputString("Enter string:", buf))
return;
EditCntl->Insert(buf);
UpdateTextFields();
}
//
// CmDeleteSubText(). Delete characters between start position and end
// position (input by user).
//
void
TEditWindow::CmDeleteSubText()
{
unsigned sPos, ePos;
if (!InputNumber("Enter starting position", sPos))
return;
if (!InputNumber("Enter ending position", ePos))
return;
EditCntl->DeleteSubText(sPos, ePos);
UpdateTextFields();
}
//
// CmDeleteLine(). Delete line of text. Line number input by user.
//
void
TEditWindow::CmDeleteLine()
{
unsigned line;
if (!InputNumber("Enter line number:", line))
return;
EditCntl->DeleteLine(line);
UpdateTextFields();
}
//
// SaveText(). Save text of edit control to a file.
//
void TEditWindow::CmSaveText()
{
EditCntl->SaveText();
}
//
// RestoreText(). retore text of edit control from a file.
//
void TEditWindow::CmRestoreText()
{
EditCntl->RestoreText();
UpdateTextFields();
}
//
// UpdateTextFields(). Updates text fields that reflex the edit control's state.
//
void
TEditWindow::UpdateTextFields()
{
char buf[FirstNChars+1] = "";
UINT sPos, ePos, curLine;
// get the line that the caret is currently on.
//
EditCntl->GetSelection(sPos, ePos);
curLine = EditCntl->GetLineFromPos(ePos);
itoa(curLine, buf, 10);
CurLineNbrText->SetText(buf);
itoa(EditCntl->GetNumLines(), buf, 10);
NbrLinesText->SetText(buf);
EditCntl->GetLine(buf, FirstNChars, curLine);
CurLineText->SetText(buf);
itoa(EditCntl->GetLineLength(curLine), buf, 10);
CurLineLenText->SetText(buf);
itoa(EditCntl->GetFirstVisibleLine(), buf, 10);
FirstVisibleLineText->SetText(buf);
if (EditCntl->IsModified())
IsModifiedText->SetText("Yes");
else
IsModifiedText->SetText("No");
LastCBOpText->SetText(EditCntl->LastCBOpStr.c_str());
EditCntl->GetSubText(buf, sPos, min(ePos, (unsigned)FirstNChars));
if (buf[0])
CurSelText->SetText(buf);
}
//
// ResetTextFields(). Reset text fields to blanks.
//
void
TEditWindow::ResetTextFields()
{
NbrLinesText->SetText("0");
CurLineNbrText->SetText("0");
CurLineText->SetText("");
CurLineLenText->SetText("0");
FirstVisibleLineText->SetText("0");
IsModifiedText->SetText("No");
LastCBOpText->SetText("");
CurSelText->SetText("");
}
//
// InputString(). Get string from user. Return 1 if successful, 0 otherwise.
// assumes buffer size of InputTextLen.
//
int
TEditWindow::InputString(char* prompt, char* s)
{
return TInputDialog(this, "String", prompt, s, InputTextLen).Execute() == IDOK;
}
//
// InputNumber(). Get number from user. Return 1 if successful, 0 otherwise.
//
int
TEditWindow::InputNumber(char* prompt, unsigned& n)
{
char buf[10] = "";
int ok = TInputDialog(this, "Number", prompt, buf, sizeof(buf), 0,
new TFilterValidator("0-9")).Execute() == IDOK;
if (ok)
n = atoi(buf);
return ok;
}
//----------------------------------------------------------------------------
class TExampleEditApp : public TApplication {
public:
void InitMainWindow();
};
void
TExampleEditApp::InitMainWindow()
{
MainWindow = new TEditWindow("Edit Control Example");
}
int
OwlMain(int /*argc*/, char* /*argv*/ [])
{
return TExampleEditApp().Run();
}
Binary file not shown.
@@ -0,0 +1,39 @@
//----------------------------------------------------------------------------
// ObjectWindows - (C) Copyright 1991, 1993 by Borland International
//----------------------------------------------------------------------------
#include <owl\inputdia.rh>
#include <owl\inputdia.rc>
#include <owl\editfile.rh>
#include <owl\editfile.rc>
#include "editx.rh"
#include <owl\owlapp.rc> // default owl app icon
IDM_EXAMPLE_EDIT MENU
{
POPUP "&File"
{
MenuItem "&Open...", CM_RESTORE_TEXT
MenuItem "&Save As...", CM_SAVE_TEXT
MenuItem SEPARATOR
MenuItem "&Exit", CM_EXIT
}
POPUP "Edi&t"
{
MenuItem "&Undo\aCtrl+Z", CM_EDITUNDO
MenuItem SEPARATOR
MenuItem "&Cut\aCtrl+X", CM_EDITCUT
MenuItem "C&opy\aCtrl+C", CM_EDITCOPY
MenuItem "&Paste\aCtrl+V", CM_EDITPASTE
MenuItem "&Delete\aDel", CM_EDITDELETE
MenuItem "C&lear All\aCtrl+Del", CM_EDITCLEAR
}
POPUP "&Operations"
{
MenuItem "&Insert text...", CM_INSERT_TEXT
MenuItem "Delete &Subtext...", CM_DELETE_SUBTEXT
MenuItem "Delete &Line...", CM_DELETE_LINE
}
}
@@ -0,0 +1,11 @@
//----------------------------------------------------------------------------
// ObjectWindows - (C) Copyright 1991, 1993 by Borland International
//----------------------------------------------------------------------------
// Menu item ids.
//
#define CM_INSERT_TEXT 400
#define CM_DELETE_SUBTEXT 401
#define CM_DELETE_LINE 402
#define CM_SAVE_TEXT 403
#define CM_RESTORE_TEXT 404
@@ -0,0 +1,7 @@
#----------------------------------------------------------------------------
# ObjectWindows - (C) Copyright 1991, 1993 by Borland International
#----------------------------------------------------------------------------
EXERES = editx
MODELS = mldf
!include $(BCEXAMPLEDIR)\owlmake.gen
@@ -0,0 +1,28 @@
//----------------------------------------------------------------------------
// ObjectWindows - (C) Copyright 1991, 1993 by Borland International
//----------------------------------------------------------------------------
#include <owl\owlpch.h>
#include <owl\applicat.h>
#include <owl\framewin.h>
#include <owl\editsear.h>
class TEditApp : public TApplication {
public:
TEditApp() : TApplication("Edit Search Application") {}
void InitMainWindow();
};
void
TEditApp::InitMainWindow()
{
MainWindow = new TFrameWindow(0, "EditWindow", new TEditSearch);
MainWindow->AssignMenu(IDM_EDITSEARCH);
MainWindow->Attr.AccelTable = TResId(IDA_EDITSEARCH);
MainWindow->Attr.Style |= DS_LOCALEDIT;
}
int
OwlMain(int /*argc*/, char* /*argv*/ [])
{
return TEditApp().Run();
}
@@ -0,0 +1,12 @@
//----------------------------------------------------------------------------
// ObjectWindows - (C) Copyright 1991, 1993 by Borland International
//----------------------------------------------------------------------------
#ifndef WORKSHOP_INVOKED
#include <windows.h>
#endif
#include <owl\editsear.rh>
#include <owl\inputdia.rh>
#include <owl\inputdia.rc>
#include <owl\editsear.rc>
#include <owl\owlapp.rc> // default owl app icon
@@ -0,0 +1,8 @@
#----------------------------------------------------------------------------
# ObjectWindows - (C) Copyright 1991, 1993 by Borland International
#----------------------------------------------------------------------------
EXERES=editseax
MODELS=mldf
!include $(BCEXAMPLEDIR)\owlmake.gen
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,154 @@
//----------------------------------------------------------------------------
// ObjectWindows - (C) Copyright 1991, 1993 by Borland International
//----------------------------------------------------------------------------
#include <owl\owlpch.h>
#include <owl\applicat.h>
#include <owl\framewin.h>
#include <owl\slider.h>
#include <owl\gauge.h>
#include <owl\static.h>
#include <owl\gdiobjec.h>
#include <stdio.h>
const WORD ID_SLIDER = 201;
const WORD ID_SOLIDGAUGE = 208;
const WORD ID_LEDGAUGE = 209;
class TTestWindow : public TWindow {
public:
TTestWindow();
protected:
TSlider* Slider;
TGauge* SolidGauge;
TGauge* LedGauge;
TBrush* BkBrush;
int Setting;
void SetupWindow();
void UpdateGauges(UINT);
BOOL EvEraseBkgnd(HDC);
HBRUSH EvCtlColor(HDC, HWND hWndChild, UINT ctlType);
void EvSysColorChange();
void EvTimer(UINT timerId);
DECLARE_RESPONSE_TABLE(TTestWindow);
};
DEFINE_RESPONSE_TABLE1(TTestWindow, TWindow)
EV_WM_ERASEBKGND,
EV_WM_CTLCOLOR,
EV_WM_SYSCOLORCHANGE,
EV_CHILD_NOTIFY_ALL_CODES(ID_SLIDER, UpdateGauges),
END_RESPONSE_TABLE;
TTestWindow::TTestWindow()
: TWindow(0, 0, 0)
{
Attr.X = 20;
Attr.Y = 20;
Attr.W = 280;
Attr.H = 160;
SolidGauge = new TGauge(this, "%d%%", ID_SOLIDGAUGE, 20, 20, 240, 34, TRUE, 2);
LedGauge = new TGauge(this, "", ID_LEDGAUGE, 20, 60, 240, 24, TRUE, 2);
Slider = new THSlider(this, ID_SLIDER, 20, 110, 240, 40);
BkBrush = new TBrush(::GetSysColor(COLOR_BTNFACE));
Setting = 50;
}
void
TTestWindow::SetupWindow()
{
TWindow::SetupWindow();
Slider->SetRange(0, 100);
Slider->SetRuler(10, FALSE);
Slider->SetPosition(50);
SolidGauge->SetRange(0, 100);
LedGauge->SetRange(0, 100);
LedGauge->SetLed(4, 80);
UpdateGauges(0);
}
void
TTestWindow::UpdateGauges(UINT)
{
Setting = Slider->GetPosition();
SolidGauge->SetValue(Setting);
LedGauge->SetValue(Setting);
}
//
// Paint a raised, grey, background
//
BOOL
TTestWindow::EvEraseBkgnd(HDC hDC)
{
TDC dc(hDC);
// SysColors that are bkgnds for text are never dithered & can use TextRect
//
dc.TextRect(GetClientRect(), ::GetSysColor(COLOR_BTNFACE));
// These sysColors might be dithered. PaBlt is an easy way to paint these
//
TBrush highlight(::GetSysColor(COLOR_BTNHIGHLIGHT));
dc.SelectObject(highlight);
dc.PatBlt(0, 0, Attr.W, 2);
dc.PatBlt(0, 2, 2, Attr.H-2);
TBrush shadow(::GetSysColor(COLOR_BTNSHADOW));
dc.SelectObject(shadow);
dc.PatBlt(1, Attr.H-2, Attr.W-1, 2);
dc.PatBlt(Attr.W-2, 1, 2, Attr.H-2-1);
return TRUE;
}
//
// Provide a background color & brush for child controls to use
//
HBRUSH
TTestWindow::EvCtlColor(HDC hDC, HWND /*hWndChild*/, UINT /*ctlType*/)
{
::SetBkColor(hDC, ::GetSysColor(COLOR_BTNFACE));
return *BkBrush;
}
//
// Colors have changed. Rebuild the background brush.
//
void
TTestWindow::EvSysColorChange()
{
delete BkBrush;
BkBrush = new TBrush(::GetSysColor(COLOR_BTNFACE));
}
//----------------------------------------------------------------------------
class TTestApp : public TApplication {
public:
TTestApp() : TApplication() {}
void InitMainWindow() {
MainWindow = new TFrameWindow(0, "Gauge Display", new TTestWindow, TRUE);
MainWindow->EnableKBHandler();
MainWindow->Attr.Style &= ~WS_THICKFRAME;
}
};
int
OwlMain(int /*argc*/, char* /*argv*/ [])
{
return TTestApp().Run();
}
@@ -0,0 +1,6 @@
//----------------------------------------------------------------------------
// ObjectWindows - (C) Copyright 1991, 1993 by Borland International
//----------------------------------------------------------------------------
#include <owl\slider.rc>
#include <owl\owlapp.rc> // default owl app icon

Some files were not shown because too many files have changed in this diff Show More