cxWidgets 1.0
cxFileViewer.h
Go to the documentation of this file.
1// Copyright (c) 2026 E. Oulashin
2#ifndef __CXFILEVIEWER_H__
3#define __CXFILEVIEWER_H__
4
5// Copyright (c) 2005-2007 Michael H. Kinney
6
7// Creates a new window, opens a file, and
8// displays it in that window.
9
10#include "cxScrolledWindow.h"
11#include "cxFunction.h"
12#include <string>
13#include <memory>
14
15namespace cx {
16
32{
33
34 public:
44 explicit cxFileViewer(cxWindow *pParentWindow, const std::string& pFilename,
45 int pRow = 0, int pCol = 0,
46 int pHeight = DEFAULT_HEIGHT,
47 int pWidth = DEFAULT_WIDTH);
48
54 cxFileViewer(const cxFileViewer& pThatFileViewer);
55
59 virtual ~cxFileViewer();
60
71 virtual long show(bool pBringToTop = true, bool pShowSubwindows = true) override;
72
76 void load();
77
82 int widestLine();
83
91 virtual std::string cxTypeStr() const override;
92
93 protected:
99 void copyCxFileViewerStuff(const cxFileViewer* pThatFileViewer);
100
101 private:
102 std::string mFilename;
103
104 // Displays the line numbers in the bottom border
105 void displayLineNumbers();
106
107 // Calls displayLineNumbers() on a cxFileViewer. This
108 // function is to be used as the 'loop function' to be
109 // run at the end of each cycle through the input loop
110 // in the parent class.
111 static std::string updateLineNumbers(cxFileViewer& pFileViewer);
112
113 // Disable the use of setLoopEndFunction from the outside
114 void setLoopEndFunction(const std::shared_ptr<cxFunction>& pFuncPtr) override;
115};
116
117} // namespace cx
118
119#endif
Represents a window that displays a file. While the object is being displayed with showModal(),...
Definition cxFileViewer.h:32
void load()
Loads the contents of the file.
Definition cxFileViewer.cpp:69
virtual long show(bool pBringToTop=true, bool pShowSubwindows=true) override
Shows the window.
Definition cxFileViewer.cpp:62
virtual std::string cxTypeStr() const override
Returns the name of the cxWidgets class. This can be used to.
Definition cxFileViewer.cpp:115
void copyCxFileViewerStuff(const cxFileViewer *pThatFileViewer)
Makes a copy of a cxFileViewer's member variables.
Definition cxFileViewer.cpp:122
int widestLine()
Definition cxFileViewer.cpp:99
cxFileViewer(cxWindow *pParentWindow, const std::string &pFilename, int pRow=0, int pCol=0, int pHeight=DEFAULT_HEIGHT, int pWidth=DEFAULT_WIDTH)
virtual ~cxFileViewer()
Definition cxFileViewer.cpp:58
Represents a text window with scrolling. This class is.
Definition cxScrolledWindow.h:54
Represents a text-based window on the screen. Can contain a title, status, and a message to appear wi...
Definition cxWindow.h:195
#define DEFAULT_HEIGHT
Definition cxWindow.h:68
#define DEFAULT_WIDTH
Definition cxWindow.h:69
cxBorderChars.h - Defines border characters to be used in drawing a box (i.e., in cxWindow and all it...
Definition cxApp.cpp:5