summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorComment <tim@gray.(none)>2012-12-26 00:53:14 +0000
committerComment <tim@gray.(none)>2012-12-26 00:53:14 +0000
commit57b3561cced6aaec85d7f638b0f881a9fe6274c9 (patch)
treee85fb94cd39c4e3f720b15b1604dc1956341b5db /src
initial commit
Diffstat (limited to 'src')
-rwxr-xr-xsrc/main.cpp16
-rwxr-xr-xsrc/testApp.cpp140
-rwxr-xr-xsrc/testApp.h49
3 files changed, 205 insertions, 0 deletions
diff --git a/src/main.cpp b/src/main.cpp
new file mode 100755
index 0000000..ee028c0
--- /dev/null
+++ b/src/main.cpp
@@ -0,0 +1,16 @@
+#include "ofMain.h"
+#include "testApp.h"
+#include "ofAppGlutWindow.h"
+
+//========================================================================
+int main( ){
+
+ ofAppGlutWindow window;
+ ofSetupOpenGL(ofxFensterManager::get(),600,600, OF_WINDOW); // <-------- setup the GL context
+
+ // this kicks off the running of my app
+ // can be OF_WINDOW or OF_FULLSCREEN
+ // pass in width and height too:
+ ofRunFensterApp( new testApp());
+
+}
diff --git a/src/testApp.cpp b/src/testApp.cpp
new file mode 100755
index 0000000..83620b9
--- /dev/null
+++ b/src/testApp.cpp
@@ -0,0 +1,140 @@
+#include "testApp.h"
+//--------------------------------------------------------------
+
+/*
+text editor functionality:
+
+keep text as 1 string? or as a vector of strings?
+prob faster to use a vector of strings for display
+makes it more awkward for selections? keep track of which line/char to start and end
+
+alternative - go through text and seperate into lines either by width or by /n every time it changes
+keep a display copy with /n's inserted?
+
+alternative - just have a horizontal scroll bar (contextual)
+maybe draw into an FBO in order to put a window in a window
+
+method to retreive text as a single string with \n's
+
+special key functions including ENTER, BACKSPACE, DELETE, ARROW KEYS
+
+drawing functionality: make line breaks (easier with mono font)
+
+set box size - draw scrollbar & set scrollpoint - drag to scroll
+
+insertion point/ selection - set with mouse -
+
+get and set clipboard (ofxFensterManager.h)
+
+
+*/
+editorWindow::~editorWindow(){
+ cout << "editor window destroyed" << endl;
+}
+void editorWindow::setup(){
+ ofxFenster* win=ofxFensterManager::get()->createFenster(0, 0, 600, 600, OF_WINDOW);
+ win->setWindowTitle("editor");
+ win->addListener(this);
+ selected=false;
+ text.push_back(string(""));
+}
+void editorWindow::draw(){
+
+ for (int i=0;i<text.size();i++) {
+ ofDrawBitmapString(text[i],10,15+(i*10));
+ }
+ //draw blinking cursor
+ /*
+ not trivial if we deal with 1 string with /ns in
+ we have to scan the file for /ns every time we display the blinking cursor
+ is easier with vectors?
+ the difficulty here is that its messy to remember row/column
+ can we even get the height of a string formatted block
+ shorter strings make inserting quicker
+ could have a single string and maintain a vector representing line breaks- however inserting a char meansn having to manipulate the entire vector
+ with a vector of strings and then row/column insertion point its prob better
+ */
+ if (selected) {
+ //draw selection
+ }
+ else {
+ //draw insertion point
+ }
+
+}
+void editorWindow::keyPressed(int key){
+ switch (key) {
+ case OF_KEY_RETURN:
+ text+="\n";
+ break;
+ default:
+ char buf[2];
+ sprintf(buf,"%c",key);
+ text+=buf;
+ }
+}
+void editorWindow::keyReleased(int key){
+ //key repeat?
+}
+//--------------------------------------------------------------
+
+void testApp::setup(){
+ ofBackground(0);
+ ofSetColor(255);
+ editorWin=new editorWindow();
+ editorWin->setup();
+}
+
+//--------------------------------------------------------------
+void testApp::update(){
+}
+
+//--------------------------------------------------------------
+void testApp::draw(){
+
+}
+
+//--------------------------------------------------------------
+void testApp::keyPressed(int key){
+
+}
+
+//--------------------------------------------------------------
+void testApp::keyReleased(int key){
+
+}
+
+//--------------------------------------------------------------
+void testApp::mouseMoved(int x, int y ){
+
+}
+
+//--------------------------------------------------------------
+void testApp::mouseDragged(int x, int y, int button){
+
+}
+
+//--------------------------------------------------------------
+void testApp::mousePressed(int x, int y, int button){
+
+}
+
+//--------------------------------------------------------------
+void testApp::mouseReleased(int x, int y, int button){
+
+}
+
+//--------------------------------------------------------------
+void testApp::windowResized(int w, int h){
+
+}
+
+//--------------------------------------------------------------
+void testApp::gotMessage(ofMessage msg){
+
+}
+
+//--------------------------------------------------------------
+void testApp::dragEvent(ofDragInfo dragInfo){
+
+}
diff --git a/src/testApp.h b/src/testApp.h
new file mode 100755
index 0000000..de24006
--- /dev/null
+++ b/src/testApp.h
@@ -0,0 +1,49 @@
+#pragma once
+
+#include "ofMain.h"
+#include "ofxFensterManager.h"
+
+struct vecTexPt {
+ vecTexPt(int r=0,int c=0) {row=r;column=c;};
+ int row;
+ int column;
+};
+
+class editorWindow;
+
+class testApp : public ofxFensterListener {
+
+ public:
+ void setup();
+ void update();
+ void draw();
+
+ void keyPressed (int key);
+ void keyReleased(int key);
+ void mouseMoved(int x, int y );
+ void mouseDragged(int x, int y, int button);
+ void mousePressed(int x, int y, int button);
+ void mouseReleased(int x, int y, int button);
+ void windowResized(int w, int h);
+ void dragEvent(ofDragInfo dragInfo);
+ void gotMessage(ofMessage msg);
+
+ editorWindow *editorWin;
+
+};
+
+class editorWindow: public ofxFensterListener{
+ public:
+ ~editorWindow();
+ void setup();
+ void draw();
+ void keyPressed(int key);
+ void keyReleased(int key);
+ private:
+ vector<string> text;
+ vecTexPt insertionPoint;
+ vecTexPt selectionStart;
+ vecTexPt selectionEnd;
+ bool selected;
+};
+